Publish Package #15
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 Package | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Semver version to publish" | |
| type: string | |
| required: true | |
| dryRun: | |
| description: "Enable dry run (default: true)" | |
| type: boolean | |
| default: true | |
| # push: | |
| # tags: | |
| # - "v*" | |
| permissions: | |
| id-token: write # Required for OIDC | |
| contents: write # Required to create git tags | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| # checkout a full working copy so we can tag the commit | |
| fetch-depth: 0 | |
| # Uses NPM Trusted Publishers for access to the registry | |
| # See https://docs.npmjs.com/trusted-publishers | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: .node-version | |
| registry-url: https://registry.npmjs.org | |
| # Ensure npm 11.5.1 or later is installed | |
| - name: Update npm | |
| run: npm install -g npm@11.6.1 | |
| - name: Install | |
| run: npm ci | |
| - name: Build | |
| run: npm run build | |
| - name: Test | |
| run: npm test | |
| - name: Configure Git | |
| run: | | |
| git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
| git config --global user.name "${GITHUB_ACTOR}" | |
| - name: Version | |
| run: npm version "${{ inputs.version }}" --git-tag-version=${{ !inputs.dryRun }} | |
| - name: Publish | |
| run: npm publish --provenance --access public --dry-run=${{ inputs.dryRun }} | |
| - name: Push Tag | |
| if: ${{ ! inputs.dryRun }} | |
| run: git push origin v${{ inputs.version }} | |
| - name: GitHub Release | |
| if: ${{ ! inputs.dryRun }} | |
| uses: ncipollo/release-action@v1.20.0 | |
| with: | |
| generateReleaseNotes: true | |
| makeLatest: true | |
| tag: v${{ inputs.version }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish (internal) | |
| env: | |
| NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | |
| run: | | |
| echo "//npm.pkg.github.com/:_authToken=${NPM_AUTH_TOKEN}" > ~/.npmrc | |
| npm publish --provenance --access public --dry-run=${{ inputs.dryRun }} --registry=https://npm.pkg.github.com/ |