Update Homebrew #648
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: Update Homebrew | |
on: | |
workflow_run: | |
workflows: ["Release naisdevice"] | |
types: | |
- completed | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
update-cask: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get Latest version | |
id: latest_version | |
uses: abatilo/release-info-action@5774bec4e3eabad433b4ae8f625e83afa0e7bb22 | |
with: | |
owner: nais | |
repo: device | |
- name: Update version and checksum in cask | |
id: update_cask | |
env: | |
LATEST: ${{ steps.latest_version.outputs.latest_tag }} | |
LATEST_DATE: ${{ steps.latest_version.outputs.latest_tag_published_at }} | |
HOMEBREW_TAP_KEY: ${{ secrets.HOMEBREW_TAP_KEY }} | |
run: | | |
echo "Version ${LATEST} was released at ${LATEST_DATE}" | |
if [[ "${LATEST}" == "null" ]]; then | |
echo "Invalid version!" | |
exit 1 | |
fi | |
eval "$(ssh-agent -s)" | |
ssh-add - <<< "${HOMEBREW_TAP_KEY}" | |
git clone [email protected]:nais/homebrew-tap.git taprepo | |
cd taprepo | |
git config user.email "[email protected]" | |
git config user.name "naisdevice pipeline" | |
for pkg in naisdevice naisdevice-tenant ; do | |
url=https://github.com/nais/device/releases/download/${LATEST}/${pkg}.pkg | |
checksum=$(curl --location ${url}.sha256) | |
sed -E -i "s#version \".*?\"#version \"${LATEST}\"#" Casks/${pkg}.rb | |
sed -E -i "s#sha256 \".*?\"#sha256 \"${checksum}\"#" Casks/${pkg}.rb | |
done | |
git add Casks/naisdevice*.rb | |
if ! git --no-pager diff --cached --exit-code; then | |
git commit -a -m "Bump naisdevice.pkg version to ${LATEST}" | |
git push | |
fi |