Skip to content

Commit c640687

Browse files
authored
Implement GitHub release step in CI workflow
Added GitHub release step to CI workflow for automatic versioning and release creation.
1 parent d1f0eb3 commit c640687

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,37 @@ jobs:
9494
- name: Publish to npm
9595
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
9696
run: npm publish --tag latest
97+
98+
github-release:
99+
needs: [npm-publish-latest]
100+
runs-on: ubuntu-latest
101+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
102+
permissions:
103+
contents: write
104+
steps:
105+
- uses: actions/checkout@v6
106+
with:
107+
fetch-depth: 0
108+
109+
- name: Compute release tag from package version
110+
id: release_tag
111+
run: echo "tag=v$(node -p \"require('./package.json').version\")" >> "$GITHUB_OUTPUT"
112+
113+
- name: Create GitHub release with generated notes
114+
env:
115+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116+
run: |
117+
TAG="v$(node -p "require('./package.json').version")"
118+
119+
if gh release view "$TAG" >/dev/null 2>&1; then
120+
echo "Release $TAG already exists. Skipping."
121+
exit 0
122+
fi
123+
124+
if git ls-remote --exit-code --tags origin "refs/tags/$TAG" >/dev/null 2>&1; then
125+
echo "Tag $TAG already exists on origin. Creating release from existing tag."
126+
gh release create "$TAG" --verify-tag --generate-notes
127+
else
128+
echo "Creating tag and release $TAG from commit $GITHUB_SHA."
129+
gh release create "$TAG" --target "$GITHUB_SHA" --generate-notes
130+
fi

0 commit comments

Comments
 (0)