Publish Package #2
Workflow file for this run
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: | |
| release: | |
| types: | |
| - published | |
| permissions: | |
| contents: write | |
| id-token: write | |
| concurrency: | |
| group: npm-publish | |
| cancel-in-progress: false | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout default branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.repository.default_branch }} | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| cache: npm | |
| registry-url: https://registry.npmjs.org | |
| - name: Set package version from release tag | |
| id: version | |
| shell: bash | |
| run: | | |
| version="${GITHUB_REF_NAME#v}" | |
| if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.-]+)?$ ]]; then | |
| echo "Release tag '$GITHUB_REF_NAME' is not a valid package version." >&2 | |
| exit 1 | |
| fi | |
| npm version "$version" --no-git-tag-version --allow-same-version | |
| echo "value=$version" >> "$GITHUB_OUTPUT" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Commit package version | |
| env: | |
| VERSION: ${{ steps.version.outputs.value }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add package.json package-lock.json | |
| git commit -m "chore: Package updated to version ${VERSION}" | |
| git push | |
| - name: Publish package | |
| run: npm publish --access public |