Publish #186
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 | |
| 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 |