Update Homebrew #663
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 | |
- uses: navikt/github-app-token-generator@v1 | |
id: get-brew-token | |
with: | |
private-key: ${{ secrets.NAIS_APP_PRIVATE_KEY }} | |
app-id: ${{ secrets.NAIS_APP_ID }} | |
repo: nais/homebrew-tap | |
- name: Checkout homebrew-tap | |
uses: actions/checkout@v4 | |
with: | |
repository: nais/homebrew-tap | |
token: ${{ steps.get-brew-token.outputs.token }} | |
path: taprepo | |
- 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 }} | |
run: | | |
echo "Version ${LATEST} was released at ${LATEST_DATE}" | |
if [[ "${LATEST}" == "null" ]]; then | |
echo "Invalid version!" | |
exit 1 | |
fi | |
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 |