Skip to content

Commit

Permalink
fix: GHA release pipeline bugs (#2372)
Browse files Browse the repository at this point in the history
* fix: attempt to pass boolean instead of string

* fix: syntax

* fix: account for jobs outputs always being strings

* fix: coerce all bools back to bools again

* fix: script name

* chore: remove duplicate git fetch
  • Loading branch information
ryandagg committed May 31, 2023
1 parent 2b4a95c commit c02850b
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 31 deletions.
30 changes: 16 additions & 14 deletions .github/workflows/full-release-pipeline.yml
Expand Up @@ -2,25 +2,27 @@ name: Full Release Pipeline

on:
workflow_dispatch:
isProdTrigger:
type: boolean
description: Triggered from prod watcher?
required: true
default: false
inputs:
isProdTrigger:
type: boolean
description: Triggered from prod watcher?
required: true
default: false
workflow_call:
isProdTrigger:
type: boolean
description: Triggered from prod watcher?
required: true
default: false
inputs:
isProdTrigger:
type: boolean
description: Triggered from prod watcher?
required: true
default: false

jobs:
get-version-channel:
runs-on: ubuntu-latest
outputs:
channel: ${{ steps.getVersion.outputs.channel }}
version: ${{ steps.getVersion.outputs.version }}
isProdRelease: ${{ inputs.isProdTrigger && !steps.getVersion.outputs.channel }}
isProdRelease: ${{ fromJSON(inputs.isProdTrigger) && !steps.getVersion.outputs.channel }}
steps:
- uses: actions/checkout@v3
- id: getVersion
Expand All @@ -31,10 +33,10 @@ jobs:
publish:
needs: [get-version-channel]
# channel is checked to avoid deploying from a malformed branch
if: needs.get-version-channel.outputs.isProdRelease || (!inputs.isProdTrigger && !!needs.get-version-channel.outputs.channel)
if: fromJSON(needs.get-version-channel.outputs.isProdRelease) || (!fromJSON(inputs.isProdTrigger) && !!needs.get-version-channel.outputs.channel)
uses: ./.github/workflows/publish-npm-gh.yml
with:
isProdRelease: ${{ needs.get-version-channel.outputs.isProdRelease }}
isProdRelease: ${{ fromJSON(needs.get-version-channel.outputs.isProdRelease) }}
secrets: inherit

pack-upload:
Expand All @@ -48,5 +50,5 @@ jobs:
uses: ./.github/workflows/promote-release.yml
with:
version: ${{ needs.get-version-channel.outputs.version }}
isProdRelease: ${{ needs.get-version-channel.outputs.isProdRelease }}
isProdRelease: ${{ fromJSON(needs.get-version-channel.outputs.isProdRelease) }}
secrets: inherit
6 changes: 3 additions & 3 deletions .github/workflows/promote-release.yml
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: ./.github/workflows/promote.yml
with:
version: ${{ inputs.version }}
isProdRelease: ${{ inputs.isProdRelease }}
isProdRelease: ${{ fromJSON(inputs.isProdRelease) }}
secrets: inherit

## POST release jobs
Expand All @@ -52,13 +52,13 @@ jobs:

release-homebrew:
needs: [ invalidate-cdn-cache ]
if: inputs.isProdRelease
if: fromJSON(inputs.isProdRelease)
uses: ./.github/workflows/release-homebrew.yml
secrets: inherit

change-management:
needs: [ promote ]
if: inputs.isProdRelease
if: fromJSON(inputs.isProdRelease)
runs-on: ubuntu-latest
environment: ChangeManagement
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/promote.yml
Expand Up @@ -31,7 +31,7 @@ on:

jobs:
promote:
name: Promote ${{ inputs.version }} to ${{ inputs.isProdRelease && 'stable' || 'beta' }}
name: Promote ${{ inputs.version }} to ${{ fromJSON(inputs.isProdRelease) && 'stable' || 'beta' }}
runs-on: ubuntu-latest
env:
CLOUDFRONT_DISTRIBUTION: ${{ secrets.CLOUDFRONT_DISTRIBUTION }}
Expand All @@ -57,7 +57,7 @@ jobs:
# get SHA directly from NPM
SHA=$(npm view heroku@${{ inputs.version }} --json | jq -r '.gitHead[0:7]')
fi
yarn oclif promote --deb --xz --root="./packages/cli" --indexes --version=${{ inputs.version }} --sha="$SHA" --channel=${{ inputs.isProdRelease && 'stable' || 'beta' }}
yarn oclif promote --deb --xz --root="./packages/cli" --indexes --version=${{ inputs.version }} --sha="$SHA" --channel=${{ fromJSON(inputs.isProdRelease) && 'stable' || 'beta' }}
shell: bash
- name: promote Linux install scripts
run: node ./scripts/postrelease/install_scripts.js
8 changes: 4 additions & 4 deletions .github/workflows/publish-npm-gh.yml
Expand Up @@ -39,15 +39,15 @@ jobs:
git config user.email "heroku-front-end+npm-releases@salesforce.com"
- name: Publish to NPM
run: |
if ${{ inputs.isProdRelease }}
if ${{ fromJSON(inputs.isProdRelease) }}
then
bash scripts/publish-release
bash scripts/publish-npm-latest
else
bash scripts/publish-prerelease
bash scripts/publish-npm-prerelease
fi
shell: bash
- name: Release to Github
if: inputs.isProdRelease
if: fromJSON(inputs.isProdRelease)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# the script below will fail if run in a separate shell file
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/watch-for-prerelease.yml
Expand Up @@ -10,4 +10,4 @@ jobs:
uses: ./.github/workflows/full-release-pipeline.yml
secrets: inherit
with:
isProdTrigger: false
isProdTrigger: ${{ false }}
2 changes: 1 addition & 1 deletion .github/workflows/watch-for-release.yml
Expand Up @@ -13,4 +13,4 @@ jobs:
uses: ./.github/workflows/full-release-pipeline.yml
secrets: inherit
with:
isProdTrigger: true
isProdTrigger: ${{ true }}
6 changes: 0 additions & 6 deletions scripts/publish-npm-prerelease
Expand Up @@ -10,12 +10,6 @@ if [[ "${CURRENT_BRANCH}" != *"${PRERELEASE_PREFIX}"* ]]; then
exit 1
fi

git pull --rebase origin "${CURRENT_BRANCH}"
# The --force overrides local tags.
# This is needed if you've published the CLI previously,
# otherwise git will exit with an error unnecessarily.
git fetch origin --force --tags

PACKAGE_VERSION=`node -e "console.log(require('./lerna.json').version)"`
TAG_NAME="v${PACKAGE_VERSION}"
EXISTING_REMOTE_TAG=$(git ls-remote origin "refs/tags/${TAG_NAME}")
Expand Down

0 comments on commit c02850b

Please sign in to comment.