Skip to content

Commit

Permalink
fix: try to get rp working (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
zanussbaum authored Nov 14, 2024
1 parent f72fbcb commit 41f415c
Showing 1 changed file with 24 additions and 47 deletions.
71 changes: 24 additions & 47 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# .github/workflows/release-please.yml
name: Release Please

on:
push:
branches:
- main
- test-release
workflow_run:
workflows: ["Test"]
types:
Expand All @@ -18,69 +13,51 @@ permissions:

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'))
# 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:
- 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 }}
# 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
target-branch: ${{ steps.branch-name.outputs.branch }}
config-file: .release-please-config.json
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 }}"
publish:
# 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 ||
startsWith(github.event.head_commit.message, 'chore(main): release')
if: ${{ needs.release-please.outputs.release_created }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0


- uses: actions/setup-node@v4
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"

# Generate package-lock.json first
- name: Generate package-lock.json
run: npm install --package-lock-only

# Now npm ci should work
- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: NPM Publish Dry Run
run: npm publish --dry-run
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

- name: NPM Publish
- run: npm ci
- run: npm run build

- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 comments on commit 41f415c

Please sign in to comment.