Release Please #33
This file contains 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: Release Please | |
on: | |
workflow_run: | |
workflows: ["Test"] | |
types: | |
- completed | |
permissions: | |
contents: write | |
pull-requests: write | |
id-token: write | |
jobs: | |
release-please: | |
# Only run if the test workflow succeeded | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
runs-on: ubuntu-latest | |
outputs: | |
release_created: ${{ steps.release.outputs.release_created }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# Need to checkout the branch that triggered the workflow_run | |
ref: ${{ github.event.workflow_run.head_branch }} | |
# Run release-please to either create/update release PR or perform release | |
- uses: googleapis/release-please-action@v4 | |
id: release | |
with: | |
release-type: node | |
package-name: your-package-name | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# Debug step to help understand what's happening | |
- name: Debug Release Outputs | |
run: | | |
echo "release_created: ${{ steps.release.outputs.release_created }}" | |
echo "pr created/updated: ${{ steps.release.outputs.pr }}" | |
echo "branch: ${{ github.event.workflow_run.head_branch }}" | |
echo "commit message: ${{ github.event.workflow_run.head_commit.message }}" | |
# Separate job for npm publishing that only runs after a release is created | |
publish-npm: | |
needs: release-please | |
if: ${{ needs.release-please.outputs.release_created }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: "20.x" | |
registry-url: "https://registry.npmjs.org" | |
- run: npm ci | |
- run: npm run build | |
- name: Publish to NPM | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |