chore: replace token-based with OIDC #1
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: Create Version Tag and Release | |
| on: | |
| push: | |
| branches: main | |
| permissions: | |
| contents: write | |
| jobs: | |
| tag: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get package version | |
| id: version | |
| run: echo "version=v$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | |
| - name: Check if tag exists | |
| id: check | |
| run: | | |
| if git rev-parse "${{ steps.version.outputs.version }}" >/dev/null 2>&1; then | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Extract changelog for version | |
| if: steps.check.outputs.exists == 'false' | |
| id: changelog | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| VERSION_NUMBER="${VERSION#v}" | |
| # Extract the section for this version from CHANGELOG.md | |
| NOTES=$(awk -v ver="$VERSION_NUMBER" ' | |
| /^## \[/ { | |
| if (found) exit | |
| if (index($0, ver)) found=1 | |
| next | |
| } | |
| found { print } | |
| ' CHANGELOG.md) | |
| # Save to file for gh release | |
| echo "$NOTES" > release_notes.md | |
| - name: Create tag and release | |
| if: steps.check.outputs.exists == 'false' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag ${{ steps.version.outputs.version }} | |
| git push origin ${{ steps.version.outputs.version }} | |
| gh release create ${{ steps.version.outputs.version }} \ | |
| --title "${{ steps.version.outputs.version }}" \ | |
| --notes-file release_notes.md |