Merge pull request #14 from doubleangels/feat/feature-additions-and-t… #15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| # Publish a GitHub Release for each new package.json version. Runs on every push to | |
| # main but is idempotent - it only creates a release when one doesn't already exist | |
| # for the current version, so each version is released exactly once (and pushing an | |
| # existing version is a no-op). Notes come straight from CHANGELOG.md. Can also be | |
| # run manually from the Actions tab. | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write # create tags + releases | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - id: version | |
| run: echo "value=$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT" | |
| - id: check | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| if gh release view "v${{ steps.version.outputs.value }}" >/dev/null 2>&1; then | |
| echo "exists=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "exists=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Build release notes from CHANGELOG | |
| if: steps.check.outputs.exists == 'false' | |
| run: node scripts/changelog-notes.js "${{ steps.version.outputs.value }}" > release-notes.md | |
| - name: Create GitHub Release | |
| if: steps.check.outputs.exists == 'false' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: > | |
| gh release create "v${{ steps.version.outputs.value }}" | |
| --title "v${{ steps.version.outputs.value }}" | |
| --notes-file release-notes.md | |
| --target "$GITHUB_SHA" |