-
Notifications
You must be signed in to change notification settings - Fork 11
99 lines (89 loc) · 3.03 KB
/
bottle.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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 }}
# without this link step this fails on macos-15 runner
brew link --overwrite pkgconf
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