55 types : [created]
66
77jobs :
8- build :
9- runs-on : ubuntu-latest
10- steps :
11- - uses : actions/checkout@v5
12- - uses : actions/setup-node@v5
13- with :
14- node-version : 22
15- - run : npm ci
16- - run : npm test
17-
188 publish-npm :
19- needs : build
209 runs-on : ubuntu-latest
10+ permissions :
11+ contents : read
12+ id-token : write
2113 steps :
2214 - uses : actions/checkout@v5
2315 with :
2719 node-version : 22
2820 registry-url : https://registry.npmjs.org/
2921 - run : npm ci
30- - name : Get branch for tag
31- id : get_branch
32- env :
33- GITHUB_TOKEN : ${{ secrets.GH_PAT }}
34- run : |
35- TAG_NAME="${GITHUB_REF#refs/tags/}"
36- REPO="${GITHUB_REPOSITORY}"
37- # Get the commit SHA for the tag
38- TAG_SHA=$(gh api repos/$REPO/git/refs/tags/$TAG_NAME --jq .object.sha)
39- # Fetch all branches and tags so we can search
40- git fetch --all --tags
41- # Find the first branch containing this commit
42- BRANCH=$(git branch -r --contains "$TAG_SHA" | grep -v '\->' | head -n 1 | sed 's|origin/||' | xargs)
43- echo "branch=$BRANCH" >> $GITHUB_OUTPUT
44-
4522 - name : Set version from tag
4623 run : |
4724 git config user.name "github-actions[bot]"
@@ -53,10 +30,13 @@ jobs:
5330 git reset --hard "refs/tags/${TAG}" # Ensure code matches the tag
5431 git pull origin ${{ steps.get_branch.outputs.branch }}
5532 npm version $TAG --no-git-tag-version
56- git add package.json package-lock.json
33+ jq '.version = "'$TAG'"' jsr.json > jsr.json.tmp && mv jsr.json.tmp jsr.json
34+ jq '.version = "'$TAG'"' deno.json > deno.json.tmp && mv deno.json.tmp deno.json
35+ git add package.json package-lock.json jsr.json deno.json
5736 git commit -m "ci: set version to $TAG [skip ci]" || true
5837 git push origin ${{ steps.get_branch.outputs.branch }}
5938 - run : npm run build --if-present
6039 - run : npm publish --access public
6140 env :
62- NODE_AUTH_TOKEN : ${{ secrets.npm_token }}
41+ NODE_AUTH_TOKEN : ${{ secrets.npm_token }}
42+ - run : npx jsr publish
0 commit comments