Skip to content

Commit

Permalink
feat: add release-homebrew workflow (runfinch#202)
Browse files Browse the repository at this point in the history
Signed-off-by: Anqi Pang <anqipans@amazon.com>

Issue #, if available:

*Description of changes:*

*Testing done:*
Tested on self-hosted runners except PR to homebrew.


- [x] I've reviewed the guidance in CONTRIBUTING.md


#### License Acceptance

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

---------

Signed-off-by: Anqi Pang <anqipans@amazon.com>
  • Loading branch information
AnqiPang authored Feb 6, 2023
1 parent 7edb374 commit cc4bae7
Show file tree
Hide file tree
Showing 2 changed files with 162 additions and 2 deletions.
149 changes: 149 additions & 0 deletions .github/workflows/release-homebrew.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# "release" runner tag is to make target hosts deterministic for easy clean up.
# TODO: Remove the "release" runner tag when installer tests are stable.
name: Release Homebrew
on:
workflow_dispatch:

jobs:
get-latest-tag:
name: Get the latest release tag
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.latesttag.outputs.tag }}
version: ${{ steps.latestversion.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 'Get the latest tag'
id: latesttag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
- name: 'Convert tag to version'
id: latestversion
run: |
version=${{ steps.latesttag.outputs.tag }}
if [ -z $version ]; then
echo ERROR: Failed to get the latest tag
exit 1
fi
if [[ $version == v* ]]; then
version="${version:1}"
fi
echo "version=$version" >> ${GITHUB_OUTPUT}
# TODO: fix the arm64 test installer.
# Currently the first time of calling any Finch command in arm64 hosts triggered by Github action will fail by
# the error "Error: Process completed with exit code 137." So the arm64 job will fail.
# We temporarily use follow-up manual steps to complete and clean up it.
macos-arm64-test-installer:
needs: get-latest-tag
strategy:
fail-fast: false
matrix:
os:
[
[self-hosted, macos, arm64, 11.7, release],
[self-hosted, macos, arm64, 12.6, release],
[self-hosted, macos, arm64, 13.0, release],
]
runs-on: ${{ matrix.os }}
timeout-minutes: 60
env:
FINCH_TAG: ${{ needs.get-latest-tag.outputs.tag }}
FINCH_VESRION: ${{ needs.get-latest-tag.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.FINCH_TAG }}
- name: Clean up previous files
run: |
cd $(brew --repo homebrew/cask)
brew uninstall --cask ./Casks/finch.rb || true
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Bump local cask version
run: |
brew update-reset
cd $(brew --repo homebrew/cask)
echo "Update the local Finch cask with version ${FINCH_VERSION}"
brew bump-cask-pr --write-only -f --version=${FINCH_VERSION} finch
- name: Silently install
run: |
cd $(brew --repo homebrew/cask)
brew install --cask ./Casks/finch.rb
- name: Run e2e tests
run: INSTALLED=true make test-e2e
- name: Silently uninstall
if: ${{ always() }}
run: |
cd $(brew --repo homebrew/cask)
brew uninstall --cask ./Casks/finch.rb
if [ -d "/Applications/Finch" ]; then
echo ERROR: Finch is not uninstalled
exit 1
fi
macos-amd64-test-installer:
needs: get-latest-tag
strategy:
fail-fast: false
matrix:
os:
[
[self-hosted, macos, amd64, 10.15, release],
[self-hosted, macos, amd64, 11.7, release],
[self-hosted, macos, amd64, 12.6, release],
[self-hosted, macos, amd64, 13.0, release],
]
runs-on: ${{ matrix.os }}
timeout-minutes: 60
env:
FINCH_TAG: ${{ needs.get-latest-tag.outputs.tag }}
FINCH_VESRION: ${{ needs.get-latest-tag.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.FINCH_TAG }}
- name: Clean up previous files
run: |
cd $(brew --repo homebrew/cask)
brew uninstall --cask ./Casks/finch.rb || true
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Bump local cask version
run: |
brew update-reset
cd $(brew --repo homebrew/cask)
echo "Update the local Finch cask with version ${FINCH_VERSION}"
brew bump-cask-pr --write-only -f --version=${FINCH_VERSION} finch
- name: Silently install
run: |
cd $(brew --repo homebrew/cask)
brew install --cask ./Casks/finch.rb
- name: Run e2e tests
run: INSTALLED=true make test-e2e
- name: Silently uninstall
if: ${{ always() }}
run: |
cd $(brew --repo homebrew/cask)
brew uninstall --cask ./Casks/finch.rb
if [ -d "/Applications/Finch" ]; then
echo ERROR: Finch is not uninstalled
exit 1
fi
pr-to-homebrew:
needs: [macos-arm64-test-installer, macos-amd64-test-installer]
runs-on: ubuntu-latest
steps:
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Open a pull request to homebrwe-cask
run: brew bump-cask-pr --version=${FINCH_VERSION} finch
env:
FINCH_VERSION: ${{ needs.get-latest-tag.outputs.version }}
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.FINCH_BOT_TOKEN }}

15 changes: 13 additions & 2 deletions .github/workflows/release-installer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# This not only refers to the cleanup described in /~https://github.com/runfinch/finch/issues/106 for arm hosts.
# Currently tests on amd64 hosts sometimes also need manual cleanup via SSHing to the host.
# TODO: Remove the "release" runner tag when installer tests are stable.
# TODO: Trigger release-homebrew.yaml workflow after this workflow completes successfully.
# TODO: Add a job to upload the installer to the github release.
name: Release Installer
on:
workflow_dispatch:
Expand All @@ -27,7 +29,11 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [[self-hosted, macos, arm64, 11.7, release], [self-hosted, macos, arm64, 12.6, release], [self-hosted, macos, arm64, 13.0, release]]
os: [
[self-hosted, macos, arm64, 11.7, release],
[self-hosted, macos, arm64, 12.6, release],
[self-hosted, macos, arm64, 13.0, release]
]
runs-on: ${{ matrix.os }}
timeout-minutes: 60
env:
Expand Down Expand Up @@ -69,7 +75,12 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [[self-hosted, macos, amd64, 10.15, release], [self-hosted, macos, amd64, 11.7, release], [self-hosted, macos, amd64, 12.6, release], [self-hosted, macos, amd64, 13.0, release]]
os: [
[self-hosted, macos, amd64, 10.15, release],
[self-hosted, macos, amd64, 11.7, release],
[self-hosted, macos, amd64, 12.6, release],
[self-hosted, macos, amd64, 13.0, release]
]
runs-on: ${{ matrix.os }}
timeout-minutes: 60
env:
Expand Down

0 comments on commit cc4bae7

Please sign in to comment.