Skip to content

Commit 3766ab9

Browse files
Single-source versioning from package.json, drop github-tag-action (#3)
1 parent db58e54 commit 3766ab9

1 file changed

Lines changed: 24 additions & 8 deletions

File tree

.github/workflows/build-release.yaml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,41 @@ on:
88
jobs:
99
release:
1010
runs-on: ubuntu-latest
11+
permissions:
12+
id-token: write
13+
contents: write
14+
outputs:
15+
new_version: ${{ steps.version.outputs.version }}
16+
released: ${{ steps.version.outputs.released }}
1117
steps:
1218
- name: Repo checkout
1319
uses: actions/checkout@v4
14-
15-
- name: Bump version and push tag
16-
id: bump
17-
uses: mathieudutour/github-tag-action@v6.2
1820
with:
19-
github_token: ${{ secrets.GITHUB_TOKEN }}
20-
release_branches: main
21+
fetch-depth: 0
22+
23+
- name: Resolve version from package.json
24+
id: version
25+
run: |
26+
VERSION=$(jq -r .version package.json)
27+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
28+
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
29+
echo "released=false" >> "$GITHUB_OUTPUT"
30+
echo "Tag v$VERSION already exists — skipping release."
31+
else
32+
echo "released=true" >> "$GITHUB_OUTPUT"
33+
fi
2134
22-
- name: Release tag
35+
- name: Create release
36+
if: steps.version.outputs.released == 'true'
2337
uses: ncipollo/release-action@v1
2438
with:
25-
tag: ${{ steps.bump.outputs.new_tag }}
39+
tag: v${{ steps.version.outputs.version }}
2640
generateReleaseNotes: true
2741

2842
publish-npmjs:
2943
runs-on: ubuntu-latest
3044
needs: [release]
45+
if: needs.release.outputs.released == 'true'
3146
permissions:
3247
contents: read
3348
id-token: write
@@ -51,6 +66,7 @@ jobs:
5166
publish-github:
5267
runs-on: ubuntu-latest
5368
needs: [release]
69+
if: needs.release.outputs.released == 'true'
5470
permissions:
5571
contents: read
5672
id-token: write

0 commit comments

Comments
 (0)