Publish #18
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: ["Release Please"] | |
| types: | |
| - completed | |
| workflow_dispatch: | |
| inputs: | |
| ref: | |
| description: "Git ref (tag or SHA) to publish" | |
| required: true | |
| jobs: | |
| test: | |
| name: Test before publish | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || github.event.workflow_run.head_sha }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: "22" | |
| - name: Run tests | |
| run: npm test | |
| publish: | |
| name: Publish to npm | |
| runs-on: ubuntu-latest | |
| needs: test | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || github.event.workflow_run.head_sha }} | |
| fetch-tags: true | |
| - name: Check release was created | |
| id: check | |
| run: | | |
| TAG=$(git tag --points-at HEAD | grep -E '^v|^opencode-llm-proxy-v' | head -1) | |
| if [ -z "$TAG" ]; then | |
| echo "No release tag on this commit, skipping publish" | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
| echo "skip=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Setup Node.js | |
| if: steps.check.outputs.skip == 'false' | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: "22" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Publish | |
| if: steps.check.outputs.skip == 'false' | |
| run: npm publish --provenance --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |