Publish #8
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: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to publish' | |
| default: 'minor' | |
| required: true | |
| tag: | |
| description: 'NPM tag to publish to' | |
| default: 'latest' | |
| required: true | |
| dry-run: | |
| description: 'Dry run (do not publish)' | |
| required: true | |
| type: boolean | |
| default: true | |
| jobs: | |
| build: | |
| permissions: | |
| contents: read | |
| uses: ./.github/workflows/ci.yml | |
| publish: | |
| permissions: | |
| contents: write | |
| id-token: write # Required for OIDC | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/create-github-app-token@v1 | |
| id: generate-token | |
| with: | |
| app-id: ${{ vars.RELEASES_APP_ID }} | |
| private-key: ${{ secrets.RELEASES_APP_KEY }} | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| token: ${{ steps.generate-token.outputs.token }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version-file: '.node-version' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install dependencies | |
| run: yarn | |
| - name: Get author name | |
| id: get_author | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: echo name=`gh api users/${{ github.actor }} | jq -j .name` >> $GITHUB_OUTPUT | |
| - name: Set version | |
| env: | |
| GIT_AUTHOR_NAME: ${{steps.get_author.outputs.name || github.actor}} | |
| GIT_AUTHOR_EMAIL: ${{github.actor_id}}+${{github.actor}}@users.noreply.github.com | |
| GIT_COMMITTER_NAME: github-actions[bot] | |
| GIT_COMMITTER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com | |
| run: npm version ${{ github.event.inputs.version }} | |
| - name: Get version | |
| id: get_version | |
| run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | |
| - name: Update npm to latest version # Required for OIDC | |
| run: npm install -g npm@latest | |
| - name: Publish tag | |
| run: git push origin HEAD --tags ${{ github.event.inputs['dry-run'] == 'true' && '--dry-run' || '' }} | |
| - name: Publish package | |
| run: npm publish --tag ${{ github.event.inputs.tag }} ${{ github.event.inputs['dry-run'] == 'true' && '--dry-run' || '' }} | |
| - name: Publish release | |
| uses: softprops/action-gh-release@v2 | |
| if: ${{ github.event.inputs['dry-run'] != 'true' }} | |
| with: | |
| token: ${{ steps.generate-token.outputs.token }} | |
| generate_release_notes: true | |
| make_latest: ${{ github.event.inputs.tag == 'latest' }} | |
| tag_name: v${{ steps.get_version.outputs.version }} | |
| draft: false | |
| prerelease: ${{ github.event.inputs.tag != 'latest' }} |