Release Workflow #5
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 Workflow | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "New version to release (semver)" | |
| required: true | |
| visibility: | |
| description: "Release visibility" | |
| required: true | |
| type: choice | |
| default: "public" | |
| options: | |
| - public | |
| - restricted | |
| concurrency: | |
| group: ${{ github.workflow }} | |
| cancel-in-progress: true | |
| # Grant write permissions to the repository contents so we can push version updates | |
| permissions: | |
| contents: write | |
| env: | |
| TAG: ${{ github.event.inputs.version }} | |
| jobs: | |
| format: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - name: Set up Node | |
| uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 | |
| with: | |
| node-version: lts/* | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Format | |
| run: npm run format | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - name: Set up Node | |
| uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 | |
| with: | |
| node-version: lts/* | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Lint | |
| run: npm run lint | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - name: Set up Node | |
| uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 | |
| with: | |
| node-version: lts/* | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Test | |
| run: npm run test | |
| publish: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - format | |
| - lint | |
| - test | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| ref: ${{ github.event.repository.default_branch }} | |
| - name: Set up Node | |
| uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 | |
| with: | |
| node-version: lts/* | |
| cache: npm | |
| registry-url: https://registry.npmjs.org | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Update package.json with release tag, commit and push version update | |
| run: | | |
| git config user.name github-actions[bot] | |
| git config user.email 41898282+github-actions[bot]@users.noreply.github.com | |
| npm version "${{ env.TAG }}" --message "chore: bump version to %s" | |
| git push origin ${{ github.event.repository.default_branch }} | |
| - name: Publish to npm | |
| run: npm publish --access ${{ github.event.inputs.visibility }} | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Create Github Release | |
| uses: ncipollo/release-action@b7eabc95ff50cbeeedec83973935c8f306dfcd0b # v1.20.0 | |
| with: | |
| name: "pdf-highlighter-kit ${{ env.TAG }}" | |
| allowUpdates: true | |
| generateReleaseNotes: true | |
| tag: ${{ env.TAG }} | |
| draft: ${{ github.event.inputs.visibility == 'restricted' }} |