Skip to content

Commit

Permalink
feat: Added github actions to release homebrew to github with updated…
Browse files Browse the repository at this point in the history
… cli version. (#11)

* feat: Added github actions to release homebrew to github with updated cli version

* Updated script with git conigurations

Co-authored-by: lakshmiravali <[email protected]>
  • Loading branch information
ravali-rimmalapudi and lakshmiravalir authored Sep 14, 2021
1 parent f3afa4a commit 3064da6
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/scripts/update-formula.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version_pattern="[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*"
formula=$1
version=$2
sha=$3
if [ "$version" == '' ] || [ "$sha" == '' ]; then
exit
fi
formula_path="Formula/$formula.rb"
sed -i.bak "s/$formula-v$version_pattern/$formula-v$version/g" "$formula_path"
sed -i.bak "s/version .*/version $version/" "$formula_path"
sed -i.bak "s/sha256 .*/sha256 $sha/" "$formula_path"
echo "Git configurations"
git config --global user.email "[email protected]"
git config --global user.name "twilio-dx"
branch=$(git branch --show-current)
echo "Current branch: $branch"
git add -A
if [ -n "$(git status --porcelain)" ]; then
echo "There are changes to commit.";
git commit -m "Release $version"
git push origin "$branch"
else
echo "No changes to commit";
fi
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Homebrew Release
on:
workflow_dispatch:
inputs:
formula:
description: 'Formula to release Homebrew'
default: twilio
version:
description: 'Release version - Same as CLI version'
required: true
sha:
description: 'SHA of tar file created by oclif'
pre-release:
description: 'If it is a prerelease send true as input'
default: 'false'

jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout to homebrew
uses: actions/checkout@v2
- name: Update Home Brew with latest sha and version
run: |
source .github/scripts/update-formula.sh "${{github.event.inputs.formula}}" "${{github.event.inputs.version}}" "${{github.event.inputs.sha}}"
release:
runs-on: ubuntu-latest
needs: [update]
steps:
- name: Checkout to homebrew
uses: actions/checkout@v2
- run: git pull
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{github.event.inputs.version}}
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: ${{github.event.inputs.pre-release}}

0 comments on commit 3064da6

Please sign in to comment.