Skip to content

Commit

Permalink
fix: execute publish steps only on release (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaLanziani authored Sep 21, 2023
1 parent b12c919 commit abb4439
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
private_key: ${{ secrets.RELEASE_PLEASE_APP_PRIVATE_KEY }}

- uses: google-github-actions/release-please-action@v3
id: release_please
id: release
with:
release-type: go
token: ${{ steps.get_installation_token.outputs.token }}
Expand All @@ -30,19 +30,27 @@ jobs:
extra-files: |
npm/package.json
# The logic below handles the npm publication:
- uses: actions/checkout@v2
# these if statements ensure that a publication only occurs when
# a new release is created:
if: ${{ steps.release.outputs.release_created }}

- name: Get commit author
id: commit_author
run: |
author=$(gh pr list --search ${{ github.sha }} --state merged --json mergedBy --jq '.[0].mergedBy.login')
echo "author=${author}" >> $$GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ steps.get_installation_token.outputs.token }}
if: ${{ steps.release.outputs.release_created }}

- uses: actions/setup-node@v3
# This sets up the .npmrc file for publishing to npm
with:
node-version: "18.x"
registry-url: "https://registry.npmjs.org"
if: ${{ steps.release.outputs.release_created }}

# we want the good pipefail behaviour https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell
- shell: bash
Expand All @@ -51,4 +59,5 @@ jobs:
./publish.sh
env:
NPM_TOKEN: ${{ secrets[format('NPM_TOKEN_{0}', steps.commit_author.outputs.author)] || secrets.NPM_TOKEN }}
OPTIC_TOKEN: ${{ secrets[format('OPTIC_TOKEN_{0}', steps.commit_author.outputs.author)] || secrets.OPTIC_TOKEN }}
OPTIC_TOKEN: ${{ secrets[format('OPTIC_TOKEN_{0}', steps.commit_author.outputs.author)] || secrets.OPTIC_TOKEN }}
if: ${{ steps.release.outputs.release_created }}

0 comments on commit abb4439

Please sign in to comment.