Release Please #25
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
# .github/workflows/release-please.yml | |
name: Release Please | |
on: | |
push: | |
branches: | |
- main | |
- test-release | |
workflow_run: | |
workflows: ["Test"] | |
types: | |
- completed | |
permissions: | |
contents: write | |
pull-requests: write | |
id-token: write | |
jobs: | |
release-please: | |
if: | | |
(github.event_name == 'push' && !startsWith(github.event.head_commit.message, 'chore(main): release')) || | |
(github.event_name == 'workflow_run' && | |
github.event.workflow_run.conclusion == 'success' && | |
!startsWith(github.event.workflow_run.head_commit.message, 'chore(main): release')) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get branch name | |
id: branch-name | |
run: | | |
if [ "${{ github.event_name }}" = "push" ]; then | |
echo "branch=${{ github.ref_name }}" >> $GITHUB_OUTPUT | |
else | |
echo "branch=${{ github.event.workflow_run.head_branch }}" >> $GITHUB_OUTPUT | |
fi | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ steps.branch-name.outputs.branch }} | |
- uses: googleapis/release-please-action@v4 | |
id: release | |
with: | |
release-type: node | |
target-branch: ${{ steps.branch-name.outputs.branch }} | |
config-file: .release-please-config.json | |
# Only proceed with npm steps if a release was created | |
- uses: actions/setup-node@v4 | |
if: ${{ steps.release.outputs.release_created }} | |
with: | |
node-version: "20.x" | |
registry-url: "https://registry.npmjs.org" | |
# Generate package-lock.json first | |
- name: Generate package-lock.json | |
if: ${{ steps.release.outputs.release_created }} | |
run: npm install --package-lock-only | |
# Now npm ci should work | |
- name: Install dependencies | |
if: ${{ steps.release.outputs.release_created }} | |
run: npm ci | |
- name: Build | |
if: ${{ steps.release.outputs.release_created }} | |
run: npm run build | |
- name: NPM Publish Dry Run | |
if: ${{ steps.release.outputs.release_created }} | |
run: npm publish --dry-run | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | |
- name: NPM Publish | |
if: ${{ steps.release.outputs.release_created }} | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |