Skip to content

Commit 931346d

Browse files
committed
chore: add check to publish workflow to avoid version conflict
1 parent f722a0f commit 931346d

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

.github/workflows/publish_jsr.yml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,34 @@ jobs:
1111
timeout-minutes: 30
1212

1313
permissions:
14-
contents: read
14+
contents: write
1515
id-token: write
1616

1717
steps:
18-
- name: Clone repository
18+
- name: Checkout repository
1919
uses: actions/checkout@v4
2020
with:
21-
submodules: true
21+
fetch-depth: 0 # Needed for tags and logs
2222

2323
- name: Set up Deno
2424
uses: denoland/setup-deno@v1
2525
with:
2626
deno-version: v2.x
2727

28+
- name: Extract version from deno.json
29+
id: get_version
30+
run: |
31+
VERSION=$(jq -r .version < deno.json)
32+
echo "version=$VERSION" >> $GITHUB_OUTPUT
33+
34+
- name: Check if version tag already exists
35+
run: |
36+
TAG="v${{ steps.get_version.outputs.version }}"
37+
if git rev-parse "$TAG" >/dev/null 2>&1; then
38+
echo "🚫 Tag $TAG already exists. Aborting."
39+
exit 1
40+
fi
41+
2842
- name: Check Format
2943
run: deno fmt --check
3044

@@ -43,10 +57,20 @@ jobs:
4357
- name: Run doc tests
4458
run: docker compose run doc_tests
4559

46-
- name: Publish (dry run)
47-
if: startsWith(github.ref, 'refs/tags/') == false
48-
run: deno publish --dry-run --allow-dirty
60+
- name: Create tag for release
61+
run: |
62+
TAG="v${{ steps.get_version.outputs.version }}"
63+
git config user.name "github-actions"
64+
git config user.email "[email protected]"
65+
git tag "$TAG"
66+
git push origin "$TAG"
67+
68+
- name: Create GitHub Release
69+
run: |
70+
gh release create "v${{ steps.get_version.outputs.version }}" \
71+
--title "v${{ steps.get_version.outputs.version }}"
72+
env:
73+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4974

50-
- name: Publish (real)
51-
if: startsWith(github.ref, 'refs/tags/')
75+
- name: Publish to JSR
5276
run: deno publish --allow-dirty

0 commit comments

Comments
 (0)