Release homebrew pact from facae89425cbba07c34da701dcf7f1f1a19c2f0b #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release - Bump Version | |
## Release automation for pact's published packages in brew | |
# Designed to run systems in kadena-io/homebrew-pact | |
# There is a | |
run-name: "Release homebrew pact ${{ inputs.release_sha }} from ${{ github.sha}}" | |
on: | |
workflow_dispatch: | |
inputs: | |
pact_intel: | |
description: "url of latest pact release package for intel" | |
type: string | |
required: false | |
pact_arm: | |
description: "url of latest pact release package for arm" | |
type: string | |
required: false | |
pact_head: | |
description: "url of latest pact-5 release package for arm" | |
type: string | |
required: false | |
workflow_call: | |
inputs: | |
pact_intel: | |
description: "url of latest pact release package for intel" | |
type: string | |
required: false | |
pact_arm: | |
description: "url of latest pact release package for arm" | |
type: string | |
required: false | |
pact_head: | |
description: "url of latest pact-5 release package for arm" | |
type: string | |
required: false | |
jobs: | |
Update-References: | |
runs-on: ubuntu-latest | |
outputs: | |
release_branch: ${{ steps.set-branch.outputs.release_branch }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: kadena-io/homebrew-pact | |
ssh-key: ${{ secrets.GH_DEPLOYKEY_PACTBREW }} | |
- name: Set release branch name | |
id: set-branch | |
run: | | |
RELEASE_SHA=$(echo ${{ github.sha }} | cut -c1-7) | |
echo "release_branch=release/${RELEASE_SHA}" >> $GITHUB_OUTPUT | |
- name: Update GHC version if needed | |
run: | | |
replace_in_rb() { | |
ON_TARGET=$1 | |
RELEASE_URL=$2 | |
HEAD_SEARCH=$3 | |
if [[ -z "$RELEASE_URL" ]]; then | |
echo "$ON_TARGET is blank, not updating url" | |
return 0 | |
else | |
echo "$ON_TARGET will be updated to $RELEASE_URL" | |
fi | |
curl -L "$RELEASE_URL" --output target.tar.gz || exit 1 | |
RELEASE_SHA=`sha256sum target.tar.gz | awk '{ print $1 }'` | |
RELEASE_URL=$(printf '%s\n' "$RELEASE_URL" | sed 's:[\\/&]:\\&:g; $!s/$/\\/') | |
sed -i --regexp-extended -z "s/($HEAD_SEARCH)($ON_TARGET do\n[ ]*)url \"([a-z0-9:\/\.\-]+)\"(\n[ ]*sha256 \")([0-9a-f]+)\"/\1\2url \"$RELEASE_URL\"\4$RELEASE_SHA\"/" pact.rb | |
ON_TARGET="" | |
RELEASE_URL="" | |
HEAD_SEARCH="" | |
} | |
replace_in_rb on_intel "${{ inputs.pact_intel }}" | |
replace_in_rb on_arm "${{ inputs.pact_arm }}" | |
replace_in_rb on_arm "${{ inputs.pact_head }}" '\<head do\>\n[ ]*' | |
- name: Create and push release branch | |
run: | | |
git config --local user.name "Kadena DevOps" | |
git config --local user.email "devops@kadena.io" | |
git checkout -b ${{ steps.set-branch.outputs.release_branch }} | |
git add pact.rb | |
git commit -m "pact package version update" | |
git push origin ${{ steps.set-branch.outputs.release_branch }} | |
Validate-and-Merge: | |
needs: Update-References | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: kadena-io/homebrew-pact | |
ssh-key: ${{ secrets.GH_DEPLOYKEY_PACTBREW }} | |
fetch-depth: 0 | |
- name: Checkout release branch | |
run: | | |
git checkout ${{ needs.Update-References.outputs.release_branch }} | |
- name: Validate pact arm nightly release | |
run: | | |
brew install --build-from-source pact.rb --head | |
pact -v | |
brew unlink pact | |
brew uninstall pact | |
- name: Validate pact arm release | |
run: | | |
brew install --build-from-source pact.rb | |
pact -v | |
brew unlink pact | |
brew uninstall pact | |
- name: Merge release branch to master | |
if: success() | |
run: | | |
git config --local user.name "Kadena DevOps" | |
git config --local user.email "devops@kadena.io" | |
git checkout master | |
git merge --no-ff ${{ needs.Update-References.outputs.release_branch }} -m "Merge release ${{ needs.Update-References.outputs.release_branch }}" | |
git push origin master | |
git push --delete origin ${{ needs.Update-References.outputs.release_branch }} |