name: Publish package on: push: tags: - 'v*' workflow_dispatch: inputs: release_tag: description: Existing tag to publish (must match package.json version, e.g. v1.1.0) required: true type: string jobs: publish: runs-on: ubuntu-latest env: PACKAGE_REGISTRY: https://git.warky.dev/api/packages/${{ gitea.repository_owner }}/npm/ steps: - uses: https://github.com/actions/checkout@v4 with: ref: ${{ inputs.release_tag || gitea.ref }} - uses: https://github.com/pnpm/action-setup@v4 - uses: https://github.com/actions/setup-node@v4 with: node-version: 22 registry-url: https://git.warky.dev/api/packages/${{ gitea.repository_owner }}/npm/ scope: '@warkypublic' cache: pnpm - name: Verify release tag env: EVENT_NAME: ${{ gitea.event_name }} TRIGGER_REF: ${{ gitea.ref }} RELEASE_TAG: ${{ inputs.release_tag }} run: | node --input-type=module <<'JS' import { readFileSync } from 'node:fs'; const { version } = JSON.parse(readFileSync('package.json', 'utf8')); const tag = process.env.EVENT_NAME === 'workflow_dispatch' ? process.env.RELEASE_TAG : process.env.TRIGGER_REF.replace(/^refs\/tags\//, ''); if (tag !== `v${version}`) { throw new Error(`Release tag must be v${version}; received ${tag || '(empty)'}`); } JS - run: pnpm install --frozen-lockfile - run: pnpm test - run: pnpm check:bundle - name: Publish to Gitea Packages env: # npm uses token authentication; PACKAGE_REGISTRY_USERNAME is not required. NODE_AUTH_TOKEN: ${{ secrets.PACKAGE_REGISTRY_TOKEN }} run: | set -eu : "${NODE_AUTH_TOKEN:?Set the PACKAGE_REGISTRY_TOKEN Actions secret with package write access}" version=$(node -p "require('./package.json').version") case "$version" in *-*) dist_tag=next ;; *) dist_tag=latest ;; esac pnpm publish --no-git-checks --registry "$PACKAGE_REGISTRY" --tag "$dist_tag"