Skip to content

Publish package

Publish package #26

Workflow file for this run

# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
name: Publish package
on:
release:
types: [created]
workflow_dispatch:
permissions:
id-token: write
contents: write
jobs:
publish-npm:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./api
steps:
- uses: actions/checkout@v4
name: Checkout
with:
ref: ${{ github.ref }}
- uses: actions/setup-node@v4
name: Setup Node.js
with:
node-version: 21
registry-url: https://registry.npmjs.org/
- uses: pnpm/action-setup@v4
name: Setup pnpm
with:
version: 9
- name: Update package.json
if: github.event_name == 'release'
run: pnpm version from-git --no-commit-hooks --no-git-tag-version --allow-same-version
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Generate JSON schemas and build library
run: pnpm run generate && pnpm run build:lib
- name: Publish to npm
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
pnpm publish --provenance --no-git-checks --tag ${{ github.event.release.prerelease && 'next' || 'latest' }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish to JSR
run: npx jsr publish --allow-slow-types
- name: Push version changes to main branch
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "bump @kulupu-linku/sona version ${{ github.event.release.tag_name }}"
branch: ${{ github.event.repository.default_branch }}
file_pattern: api/package.json