|
| 1 | +name: Release Workflow |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: "New version to release (semver)" |
| 8 | + required: true |
| 9 | + visibility: |
| 10 | + description: "Release visibility" |
| 11 | + required: true |
| 12 | + type: choice |
| 13 | + default: "public" |
| 14 | + options: |
| 15 | + - public |
| 16 | + - restricted |
| 17 | + |
| 18 | +concurrency: |
| 19 | + group: ${{ github.workflow }} |
| 20 | + cancel-in-progress: true |
| 21 | + |
| 22 | +# Grant write permissions to the repository contents so we can push version updates |
| 23 | +permissions: |
| 24 | + contents: write |
| 25 | + |
| 26 | +env: |
| 27 | + TAG: ${{ github.event.inputs.version }} |
| 28 | + |
| 29 | +jobs: |
| 30 | + format: |
| 31 | + runs-on: ubuntu-latest |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 34 | + - name: Set up Node |
| 35 | + uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 |
| 36 | + with: |
| 37 | + node-version: lts/* |
| 38 | + cache: npm |
| 39 | + - name: Install dependencies |
| 40 | + run: npm ci |
| 41 | + - name: Format |
| 42 | + run: npm run format |
| 43 | + |
| 44 | + lint: |
| 45 | + runs-on: ubuntu-latest |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 48 | + - name: Set up Node |
| 49 | + uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 |
| 50 | + with: |
| 51 | + node-version: lts/* |
| 52 | + cache: npm |
| 53 | + - name: Install dependencies |
| 54 | + run: npm ci |
| 55 | + - name: Lint |
| 56 | + run: npm run lint |
| 57 | + |
| 58 | + test: |
| 59 | + runs-on: ubuntu-latest |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 62 | + - name: Set up Node |
| 63 | + uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 |
| 64 | + with: |
| 65 | + node-version: lts/* |
| 66 | + cache: npm |
| 67 | + - name: Install dependencies |
| 68 | + run: npm ci |
| 69 | + - name: Test |
| 70 | + run: npm run test |
| 71 | + |
| 72 | + publish: |
| 73 | + runs-on: ubuntu-latest |
| 74 | + needs: |
| 75 | + - format |
| 76 | + - lint |
| 77 | + - test |
| 78 | + steps: |
| 79 | + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 80 | + with: |
| 81 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 82 | + ref: ${{ github.event.repository.default_branch }} |
| 83 | + - name: Set up Node |
| 84 | + uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 |
| 85 | + with: |
| 86 | + node-version: lts/* |
| 87 | + cache: npm |
| 88 | + registry-url: https://registry.npmjs.org |
| 89 | + - name: Install dependencies |
| 90 | + run: npm ci |
| 91 | + - name: Update package.json with release tag, commit and push version update |
| 92 | + run: | |
| 93 | + git config user.name github-actions[bot] |
| 94 | + git config user.email 41898282+github-actions[bot]@users.noreply.github.com |
| 95 | + npm version "${{ env.TAG }}" --message "chore: bump version to %s" |
| 96 | + git push origin ${{ github.event.repository.default_branch }} |
| 97 | + - name: Publish to npm |
| 98 | + run: npm publish --access ${{ github.event.inputs.visibility }} |
| 99 | + env: |
| 100 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 101 | + - name: Create Github Release |
| 102 | + uses: ncipollo/release-action@b7eabc95ff50cbeeedec83973935c8f306dfcd0b # v1.20.0 |
| 103 | + with: |
| 104 | + name: "pdf-highlighter-kit ${{ env.TAG }}" |
| 105 | + allowUpdates: true |
| 106 | + generateReleaseNotes: true |
| 107 | + tag: ${{ env.TAG }} |
| 108 | + draft: ${{ github.event.inputs.visibility == 'restricted' }} |
0 commit comments