Skip to content

Publish package

Publish package #6

Workflow file for this run

name: Publish Package
on:
release:
types: [published]
jobs:
prepare:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh-key: ${{ secrets.MERGE_BYPASS_KEY }}
ref: ${{ github.event.repository.default_branch }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://registry.npmjs.org
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Run tests
run: npm test
- name: Configure git
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
- name: Update package.json with release tag
run: |
TAG="${{ github.event.release.tag_name }}"
echo "Updating package.json version to $TAG"
npm version "$TAG"
- name: Commit and push version update
run: |
TAG="${{ github.event.release.tag_name }}"
git add package.json package-lock.json
git commit -m "Update package.json to version $TAG"
git push origin ${{ github.event.repository.default_branch }}
git push origin tag $TAG --force
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-npm:
needs: prepare
permissions:
id-token: write
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '>=24.5.0'
registry-url: https://registry.npmjs.org
- run: npm ci
- run: npm run release
publish-github:
needs: prepare
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
registry-url: 'https://npm.pkg.github.com'
- run: npm ci
- run: npm run release
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}