Skip to content

brew bottle

brew bottle #32

Workflow file for this run

name: brew bottle
on:
workflow_call:
inputs:
formula:
type: string
default: viam
description: which formula to bottle
secrets:
GIT_ACCESS_TOKEN:
required: true
workflow_dispatch:
inputs:
formula:
type: string
default: viam
description: which formula to bottle
env:
# if you don't override root-url it will upload to / download from the wrong place
ROOT_URL: https://ghcr.io/v2/${{ github.repository }}
jobs:
bottle:
strategy:
matrix:
runs-on: [ubuntu-22.04, macos-14, macos-15]
runs-on: ${{ matrix.runs-on }}
steps:
- uses: Homebrew/actions/setup-homebrew@master
- uses: actions/checkout@v4
- name: pull
run: |
# see note below on why we need to pull
git pull
- name: build bottle
run: |
brew tap viamrobotics/brews
# note: this fails on the nlopt dep to viam-server when viam-server already exists as bottle in the formula file.
# weird edge case. recovery is to remove the bottle stanza and delete the uploaded package, then rerun.
brew install --only-dependencies ${{ inputs.formula }}
brew install --build-bottle ${{ inputs.formula }}
brew bottle --json --root-url $ROOT_URL ${{ inputs.formula }}
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.runs-on }}
if-no-files-found: error
path: '*.bottle.*'
upload:
needs: bottle
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: Homebrew/actions/setup-homebrew@master
- uses: actions/checkout@v4
with:
token: ${{ secrets.GIT_ACCESS_TOKEN }}
- name: git setup
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "actions bot"
git config push.autoSetupRemote true
git branch
# why pull: for the case where we are bottling two formulae, formula 1 will push a new commit.
# Then formula 2's bottle job will check out the original commit, try to push, and collid with
# formula 1's commit.
git pull
- name: download artifacts
env:
GH_TOKEN: ${{ github.token }}
run: |
brew tap viamrobotics/brews
gh run download ${{ github.run_id }}
mv */*.bottle.* .
ls
- name: upload
env:
HOMEBREW_GITHUB_PACKAGES_USER: ${{ github.repository_owner }}
HOMEBREW_GITHUB_PACKAGES_TOKEN: ${{ github.token }}
run: brew pr-upload --root-url $ROOT_URL
- name: push changes
run: |
cd $(brew --prefix)/Homebrew/Library/Taps/${{ github.repository }}
# note: the tap is on the current branch rather than main. not sure why, seems sensitive to whether we run actions/checkout.
git log | head
git status
git push