Commit 6d8edb1e authored by Santhosh Nagaraj S's avatar Santhosh Nagaraj S
Browse files

Build: Add gh action to update homebrew


this patch adds a gh action to create PR
which updatest headlamp version and
sha of assets for homebrew
Signed-off-by: default avatarSanthosh Nagaraj S <santhosh@kinvolk.io>
parent 153fd4c7
Showing with 86 additions and 0 deletions
+86 -0
name: PR to update homebrew
# This action will run after a tag starting with "v" is published
on:
push:
tags:
- 'v*'
workflow_dispatch:
env:
LATEST_HEADLAMP_TAG: latest
jobs:
create_pr_to_upgrade_homebrew:
name: Create PR to upgrade homebrew
runs-on: ubuntu-latest
steps:
- name: Checkout headlamp repo
uses: actions/checkout@v2
with:
path: headlamp
fetch-depth: 0
- name: Configure Git
run: |
user=${{github.actor}}
if [ -z $user ]; then
user=yolossn
fi
git config --global user.name "$user"
git config --global user.email "$user@users.noreply.github.com"
- name: Get headlamp latest tag
run: |
cd headlamp
latestTag=$(git tag --list --sort=version:refname 'v*' | tail -1)
echo "LATEST_HEADLAMP_TAG=$latestTag" >> $GITHUB_ENV
echo $latestTag
- name: Sync homebrew-cask fork from upstream
run: |
gh repo sync kinvolk/homebrew-cask
env:
GITHUB_TOKEN: ${{ secrets. KINVOLK_REPOS_TOKEN }}
- name: Check out homebrew-cask repo
uses: actions/checkout@v2
with:
repository: kinvolk/homebrew-cask
path: homebrew-cask
token: ${{ secrets. KINVOLK_REPOS_TOKEN }}
- name: Update headlamp version in homebrew-cask
run: |
user=${{github.actor}}
if [ -z $user ]; then
user=yolossn
fi
cd homebrew-cask
HEADLAMP_VERSION=${LATEST_HEADLAMP_TAG:1}
wget "https://github.com/kinvolk/headlamp/releases/download/$LATEST_HEADLAMP_TAG/checksums.txt"
ARM_SHA=$(cat checksums.txt | grep .arm64.dmg | awk -F" " '{print $1}')
INTEL_SHA=$(cat checksums.txt | grep .x64.dmg | awk -F" " '{print $1}')
git checkout -b "update_headlamp_$HEADLAMP_VERSION"
sed -i "s/version\ .*/version \"$HEADLAMP_VERSION\"/g" ./Casks/headlamp.rb
if [ $ARM_SHA ]; then
echo "replacing ARM SHA"
sed -i "s/sha256 arm:\ \".*/sha256 arm:\ \"$ARM_SHA\",/g" ./Casks/headlamp.rb
fi
if [ $INTEL_SHA ]; then
echo "replacing Intel SHA"
sed -i "s/ intel:\ \".*/ intel:\ \"$INTEL_SHA\"/g" ./Casks/headlamp.rb
fi
git diff
rm ./checksums.txt
git add ./Casks/headlamp.rb
git status
git commit --signoff -m "Update Headlamp version to $HEADLAMP_VERSION"
git status
git log -1
git push origin "update_headlamp_$HEADLAMP_VERSION" -f
gh pr create \
--title "Upgrade Headlamp version to $HEADLAMP_VERSION" \
--repo "Homebrew/homebrew-cask" \
--head "kinvolk:update_headlamp_$HEADLAMP_VERSION" \
--base "master" \
--assignee "$user" \
--body "Upgrade Headlamp version to $HEADLAMP_VERSION
cc: @$user" \
env:
LATEST_HEADLAMP_TAG: ${{ env.LATEST_HEADLAMP_TAG }}
GITHUB_TOKEN: ${{ secrets. KINVOLK_REPOS_TOKEN }}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment