ci: Give the workflow access to the ID token #14
This file contains 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: Package Release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
npm-package: | |
name: Build and push npm package | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write | |
steps: | |
- name: Create bot access token | |
id: app-token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ vars.RPF3_BOT_APP_ID }} | |
private-key: ${{ secrets.RPF3_BOT_PRIVATE_KEY }} | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
token: ${{ steps.app-token.outputs.token }} | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/setup@v0 | |
with: | |
versionSpec: 5.x | |
- name: Calculate the build version | |
id: gitversion | |
uses: gittools/actions/gitversion/execute@v0 | |
with: | |
useConfigFile: true | |
- name: Install and configure Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install pnpm | |
uses: pnpm/action-setup@v3 | |
with: | |
version: 8 | |
run_install: true | |
- name: Increment package version | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
npm version ${{ steps.gitversion.outputs.semver }} -m "chore: Bump package version [no ci]" | |
git push | |
- name: Build | |
run: pnpm build | |
- name: Package | |
run: pnpm package | |
- name: Publish | |
run: npm publish --provenance --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |