Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 27 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Release

on:
push:
tags:
- "v*"
release:
types: [published]

permissions:
contents: write
Expand All @@ -15,20 +14,21 @@ jobs:
runs-on: ubuntu-latest
environment: release
steps:
- name: Checkout code
- name: Checkout main
uses: actions/checkout@v6
with:
ref: main
fetch-depth: 0

- name: Verify tag matches package.json version
- name: Resolve version from release tag
env:
TAG: ${{ github.ref_name }}
TAG: ${{ github.event.release.tag_name }}
run: |
pkg=$(node -p "require('./package.json').version")
if [ "v$pkg" != "$TAG" ]; then
echo "::error::Tag $TAG does not match package.json version $pkg. Tag the version-bump commit (git push --follow-tags), and delete the bad tag."
if ! echo "$TAG" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$'; then
echo "::error::Release tag '$TAG' is not a vSEMVER tag (e.g. v0.0.6, v10.1.11)."
exit 1
fi
echo "VERSION=${TAG#v}" >> "$GITHUB_ENV"

- name: Setup Bun
uses: oven-sh/setup-bun@v2
Expand All @@ -54,19 +54,30 @@ jobs:
- name: Run tests
run: bun run test

- name: Bump to the released version
env:
TAG: ${{ github.event.release.tag_name }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
npm version "$VERSION" --no-git-tag-version --allow-same-version
printf '/** SDK version string sent with every API request. */\nexport const SDK_VERSION: string = "%s";\n' "$VERSION" > src/version.ts
if git diff --quiet; then
echo "Already at $VERSION"
else
git commit -am "chore: release v$VERSION"
git push origin HEAD:main
fi
git tag -f "$TAG"
git push -f origin "refs/tags/$TAG"

- name: Build
run: bun run build

- name: Generate changelog
run: bunx changelogithub
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# No NODE_AUTH_TOKEN: auth comes from OIDC trusted publishing.
# Requires a trusted publisher configured on npmjs.com for this repo,
# workflow (release.yml), and the "release" environment.
- name: Publish packages to npm
- name: Publish to npm
run: npm pack && npm publish ./*.tgz --access public --provenance
env:
NPM_CONFIG_PROVENANCE: true
23 changes: 0 additions & 23 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"dev": "vp pack --watch",
"test": "vp test",
"check": "vp check",
"release": "bumpp --commit --push --tag",
"prepublishOnly": "vp run build",
"prepare": "vp config"
},
Expand All @@ -47,7 +46,6 @@
"@types/node": "^25.6.0",
"@types/react": "^19.2.14",
"@typescript/native-preview": "7.0.0-dev.20260505.1",
"bumpp": "^11.0.1",
"pino": "^10.3.1",
"pino-pretty": "^13.1.2",
"react": "^19.2.5",
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/** SDK version string sent with every API request. */
export const SDK_VERSION: string = "2.0.8";
export const SDK_VERSION: string = "0.0.5";
10 changes: 10 additions & 0 deletions tests/version.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { describe, expect, it } from "vite-plus/test";

import pkg from "../package.json" with { type: "json" };
import { SDK_VERSION } from "src/version";

describe("SDK_VERSION", () => {
it("matches package.json", () => {
expect(SDK_VERSION).toBe(pkg.version);
});
});
Loading