Skip to content

Commit

Permalink
πŸ› Fix variable handling using job outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
phatblat committed Jul 31, 2024
1 parent 97fa10f commit 47c935c
Showing 1 changed file with 50 additions and 20 deletions.
70 changes: 50 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ on:
jobs:
start:
runs-on: macos-14
outputs:
dry_run: ${{ steps.dry_run.outputs.test }}
mas_version: ${{ steps.mas_version.outputs.test }}
release_branch: ${{ steps.release_branch.outputs.test }}
release_commit: ${{ steps.release_commit.outputs.test }}
steps:
# Logs event details and sets `DRY_RUN` env var
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
Expand All @@ -27,15 +32,21 @@ jobs:
echo "release.target_commitish: ${{ github.event.release.target_commitish }}"
echo -e "release.body: \n${{ github.event.release.body }}"
echo "DRY_RUN=false" >>$GITHUB_ENV
echo "MAS_VERSION=${{ github.event.release.tag_name }}" >>${GITHUB_ENV}
echo "RELEASE_COMMIT=${{ github.event.release.target_commitish }}" >>${GITHUB_ENV}
- id: dry_run
run: |
echo "DRY_RUN=false
- id: mas_version
run: |
echo "MAS_VERSION=${{ github.event.release.tag_name }}" >>"$GITHUB_OUTPUT"
- name: πŸ”ˆ Log environment variables
- id: release_branch
run: |
echo "DRY_RUN: ${DRY_RUN}"
echo "MAS_VERSION: ${MAS_VERSION}"
echo "RELEASE_COMMIT: ${RELEASE_COMMIT}"
echo "RELEASE_BRANCH=releases/release-${{ github.event.release.tag_name }}" >>"$GITHUB_OUTPUT"
- id: release_commit
run: |
echo "RELEASE_COMMIT=${{ github.event.release.target_commitish }}" >>"$GITHUB_OUTPUT"
prepare-release:
runs-on: macos-14
Expand All @@ -47,17 +58,22 @@ jobs:
fetch-depth: 0

- name: πŸ”€ Create release branch
env:
RELEASE_BRANCH: ${{ needs.start.outputs.release_branch }}
run: |
branch_name="releases/release-${MAS_VERSION}"
echo "RELEASE_BRANCH=${branch_name}" >>${GITHUB_ENV}
git branch "${branch_name}"
git switch "${branch_name}"
git branch "${RELEASE_BRANCH}"
git switch "${RELEASE_BRANCH}"
- name: πŸ”– Update version
env:
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
RELEASE_COMMIT: ${{ needs.start.outputs.release_commit }}
run: |
script/version_bump "${MAS_VERSION}" "${RELEASE_COMMIT}"
- name: πŸ’Ύ Commit changes
env:
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
run: |
git add \
"Homebrew/mas.rb" \
Expand All @@ -69,6 +85,8 @@ jobs:
- name: ‴️ Open PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
RELEASE_BRANCH: ${{ needs.start.outputs.release_branch }}
run: |
gh pr create \
--base main \
Expand All @@ -78,7 +96,7 @@ jobs:
pkg-installer:
runs-on: macos-14
needs: [prepare-release]
needs: [start, prepare-release]
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -100,14 +118,17 @@ jobs:
script/package
- name: πŸš€ Upload mas.pkg
if: ${{ env.DRY_RUN == 'false' }}
env:
DRY_RUN: ${{ needs.start.outputs.dry_run }}
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
if: ${{ needs.start.outputs.dry_run == 'false' }}
run: |
gh release upload ${MAS_VERSION} \
.build/mas.pkg
homebrew-tap:
runs-on: macos-14
needs: [prepare-release]
needs: [start, prepare-release]
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -119,19 +140,25 @@ jobs:
script/bootstrap -f
- name: 🚰 Update mas tap formula
env:
DRY_RUN: ${{ needs.start.outputs.dry_run }}
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
run: |
DRY_RUN=${{ env.DRY_RUN }} \
script/brew_tap_update ${{ env.MAS_VERSION }}
DRY_RUN=${DRY_RUN} \
script/brew_tap_update ${MAS_VERSION}
- name: πŸš€ Upload Bottles
if: ${{ env.DRY_RUN == 'false' }}
env:
DRY_RUN: ${{ needs.start.outputs.dry_run }}
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
if: ${{ needs.start.outputs.dry_run == 'false' }}
run: |
gh release upload ${MAS_VERSION} \
.build/bottles/mas-*.bottle.tar.gz
homebrew-core:
runs-on: macos-14
needs: [prepare-release, homebrew-tap]
needs: [start, prepare-release, homebrew-tap]
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -143,7 +170,10 @@ jobs:
script/bootstrap -f
- name: 🍺 Update Homebrew mas formula
env:
DRY_RUN: ${{ needs.start.outputs.dry_run }}
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
run: |
DRY_RUN=${{ env.DRY_RUN }} \
script/brew_core_update ${{ env.MAS_VERSION }}
DRY_RUN=${DRY_RUN} \
script/brew_core_update ${MAS_VERSION}

0 comments on commit 47c935c

Please sign in to comment.