Release homebrew pact from 35b227928c49369c2573e771bee7db04f6794efb #8
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: macos-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: kadena-io/homebrew-pact | |
ssh-key: ${{ secrets.GH_DEPLOYKEY_PACTBREW }} | |
- name: Update GHC version if needed | |
run: | | |
# we fire this function for every possible url so stop if no url was passed to script | |
# get release to calculate sha (and exit if the curl fails) | |
# escape the release URL / characters | |
# replace the release url and sha | |
# blank out variables to prevent conflicts | |
cat pact.rb | |
echo "Updating values in the above file to below:" | |
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=$(shasum -a 256 target.tar.gz | awk '{ print $1 }') | |
# Escape special characters in RELEASE_URL for sed | |
RELEASE_URL_ESCAPED=$(printf '%s\n' "$RELEASE_URL" | sed -e 's/[\/&]/\\&/g') | |
# Use awk for the replacement | |
awk -v target="$ON_TARGET" -v url="$RELEASE_URL_ESCAPED" -v sha="$RELEASE_SHA" -v search="$HEAD_SEARCH" ' | |
$0 ~ search { | |
p = 1 | |
} | |
p && /url/ { | |
sub(/url "[^"]+"/, "url \"" url "\"") | |
} | |
p && /sha256/ { | |
sub(/sha256 "[^"]+"/, "sha256 \"" sha "\"") | |
p = 0 | |
} | |
{print} | |
' pact.rb > pact.rb.tmp && mv pact.rb.tmp 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[ ]*' | |
cat pact.rb | |
- name: Validate pact arm nightly release | |
run: | | |
brew install --build-from-source pact.rb --head | |
pact -v | |
brew uninstall pact | |
- name: Validate pact arm release | |
run: | | |
brew install --build-from-source pact.rb --head | |
pact -v | |
brew uninstall pact | |
- name: Update master branch with new homebrew | |
run: | | |
git config --local user.name "Kadena DevOps" | |
git config --local user.email "devops@kadena.io" | |
git add pact.rb | |
git commit --allow-empty -m "pact package version update" | |
# allow empty in case this is a re-run | |
git status | |
git tag chainweb-${{ inputs.VERSION_NEW }} | |
git push | |
git push --force origin --tags | |