Continuous Delivery #49
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: Continuous Delivery | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to release, matching the release tag (e.g., v1.2.3)' | |
| required: true | |
| type: string | |
| permissions: | |
| contents: read | |
| jobs: | |
| build-package-and-publish-release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| registry-url: "https://registry.npmjs.org" | |
| # RELEASE_VERSION is the v-prefixed tag (e.g. v3.0.3) on a release, or the | |
| # manual input on dispatch. The leading "v" lands in package.json but npm | |
| # strips it on publish, so the published version is clean (e.g. 3.0.3). | |
| - name: Bump version to release | |
| run: sed -i "s/v0.0.0/$RELEASE_VERSION/" ./package.json | |
| env: | |
| RELEASE_VERSION: ${{ github.event_name == 'workflow_dispatch' && inputs.version || github.ref_name }} | |
| - name: Install dependencies required to build package | |
| run: npm ci | |
| - name: Build package | |
| run: npm run build | |
| - name: Publish package | |
| run: npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |