Skip to content

Publish

Publish #186

Workflow file for this run

name: Publish
on:
workflow_run:
workflows: ["Publish Assets"]
types: [completed]
permissions:
id-token: write # Required for OIDC
contents: write # Required for checking out code and editing release state
jobs:
publish:
name: Publish to NPM
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' && startsWith(github.event.workflow_run.head_branch, 'release/v')
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
ref: main
- name: Setup mise
uses: jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # v2
with:
experimental: true
- name: Install dependencies
run: pnpm install --ignore-scripts
- name: Publish to npm
run: pnpm publish
- name: Publish target draft release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
run: |
TAG="${HEAD_BRANCH#release/}"
if ! echo "$TAG" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "::error::Invalid release tag derived from branch: $HEAD_BRANCH"
exit 1
fi
gh release edit "$TAG" --draft=false --latest