[Release] v0.2.1 #2
Workflow file for this run
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: Publish | |
| on: | |
| pull_request: | |
| types: | |
| - closed | |
| branches: | |
| - main | |
| - "v**" | |
| workflow_dispatch: | |
| jobs: | |
| publish: | |
| if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && github.event.pull_request.head.label == 'fetchet:release') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: "Release PR info" | |
| if: github.event_name != 'workflow_dispatch' | |
| run: echo "PR ${{ github.event.number }}" | |
| - uses: actions/checkout@v4 | |
| - name: git config | |
| run: | | |
| git config user.name "${GITHUB_ACTOR}" | |
| git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 18 | |
| registry-url: https://registry.npmjs.org/ | |
| - run: npm ci | |
| - name: get-npm-version | |
| id: package-version | |
| uses: martinbeentjes/npm-get-version-action@main | |
| - name: Extract release notes | |
| id: extract-release-notes | |
| uses: ffurrer2/extract-release-notes@v2 | |
| # TODO: Check/verify versions | |
| # Tag Release | |
| - name: "Push tag v${{ steps.package-version.outputs.current-version }}" | |
| uses: rickstaa/action-create-tag@v1 | |
| id: tag_version | |
| with: | |
| tag: "v${{ steps.package-version.outputs.current-version }}" | |
| # Resolve NPM Tag | |
| - name: NPM TAG | |
| id: "npm_tag" | |
| run: | | |
| version="${{ steps.package-version.outputs.current-version }}" | |
| if [[ "$version" == *-* ]]; then | |
| echo "tag=beta" >> $GITHUB_OUTPUT | |
| else | |
| echo "tag=latest" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Set fallback tag if empty | |
| id: fallback_tag | |
| run: | | |
| echo "tag=${{ steps.npm_tag.outputs.tag || 'latest' }}" >> $GITHUB_OUTPUT | |
| # GitHub Release | |
| - name: "Create a GitHub release v${{ steps.package-version.outputs.current-version }}" | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| tag: "v${{ steps.package-version.outputs.current-version }}" | |
| name: "Release v${{ steps.package-version.outputs.current-version }}" | |
| body: | | |
| ## Release notes: | |
| ${{ steps.extract-release-notes.outputs.release_notes }} | |
| # NPM Release | |
| - name: Publish the release to NPM | |
| run: npm publish --provenance --access public --tag ${{ steps.fallback_tag.outputs.tag }} | |
| env: | |
| NODE_AUTH_TOKEN: ${{secrets.npm_token}} | |
| # TODO: notify release notify - add release comments and tags to published PRs: |