-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
267 lines (232 loc) · 10.1 KB
/
pkg-installer.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
name: Installer Package
on:
push:
branches:
- '**'
tags-ignore:
- '**'
paths:
- .github/workflows/pkg-installer.yml
- package/**/*
release:
types:
- published
env:
PKG_APPLE_DEVELOPER_TEAM_ID: ${{ secrets.PKG_APPLE_DEVELOPER_TEAM_ID }}
HOMEBREW_NO_ANALYTICS_THIS_RUN: 1
HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT: 1
defaults:
run:
shell: bash -xeuo pipefail {0}
jobs:
build:
if: github.repository_owner == 'Homebrew' && github.actor != 'dependabot[bot]'
runs-on: macos-15
outputs:
installer_path: "Homebrew-${{ steps.homebrew-version.outputs.version }}.pkg"
env:
TEMPORARY_CERTIFICATE_FILE: 'homebrew_developer_id_installer_certificate.p12'
TEMPORARY_KEYCHAIN_FILE: 'homebrew_installer_signing.keychain-db'
# Set to the oldest supported version of macOS
HOMEBREW_MACOS_OLDEST_SUPPORTED: '13.0'
permissions:
contents: read # for code access
attestations: write # for actions/attest-build-provenance
id-token: write # for actions/attest-build-provenance
steps:
- name: Remove existing API cache (to force update)
run: rm -rvf ~/Library/Caches/Homebrew/api
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
with:
core: false
cask: false
test-bot: false
- name: Install Pandoc
run: brew install pandoc
- name: Create and unlock temporary macOS keychain
run: |
TEMPORARY_KEYCHAIN_PASSWORD="$(openssl rand -base64 20)"
TEMPORARY_KEYCHAIN_PATH="${RUNNER_TEMP}/${TEMPORARY_KEYCHAIN_FILE}"
security create-keychain -p "${TEMPORARY_KEYCHAIN_PASSWORD}" "${TEMPORARY_KEYCHAIN_PATH}"
security set-keychain-settings -l -u -t 21600 "${TEMPORARY_KEYCHAIN_PATH}"
security unlock-keychain -p "${TEMPORARY_KEYCHAIN_PASSWORD}" "${TEMPORARY_KEYCHAIN_PATH}"
- name: Create temporary certificate file
env:
PKG_APPLE_SIGNING_CERTIFICATE_BASE64: ${{ secrets.PKG_APPLE_SIGNING_CERTIFICATE_BASE64 }}
run: echo -n "${PKG_APPLE_SIGNING_CERTIFICATE_BASE64}" |
base64 --decode --output="${RUNNER_TEMP}/${TEMPORARY_CERTIFICATE_FILE}"
- name: Import certificate file into macOS keychain
env:
PKG_APPLE_SIGNING_CERTIFICATE_PASSWORD: ${{ secrets.PKG_APPLE_SIGNING_CERTIFICATE_PASSWORD }}
run: security import "${RUNNER_TEMP}/${TEMPORARY_CERTIFICATE_FILE}"
-k "${RUNNER_TEMP}/${TEMPORARY_KEYCHAIN_FILE}"
-P "${PKG_APPLE_SIGNING_CERTIFICATE_PASSWORD}"
-t cert
-f pkcs12
-A
- name: Clean up temporary certificate file
if: ${{ always() }}
run: rm -f "${RUNNER_TEMP}/${TEMPORARY_CERTIFICATE_FILE}"
- name: Checkout another Homebrew to brew subdirectory
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
path: brew
fetch-depth: 0
persist-credentials: false
- name: Get Homebrew version from Git
id: homebrew-version
run: echo "version=$(git -C brew describe --tags --always)" >> "${GITHUB_OUTPUT}"
- name: Copy Homebrew API cache to brew subdirectory
run: cp -vR ~/Library/Caches/Homebrew/api brew/cache_api
- name: Open macOS keychain
run: security list-keychain -d user -s "${RUNNER_TEMP}/${TEMPORARY_KEYCHAIN_FILE}"
- name: Build Homebrew installer component package
env:
HOMEBREW_VERSION: ${{ steps.homebrew-version.outputs.version }}
# Note: `Library/Homebrew/test/support/fixtures/` contains unsigned
# binaries so it needs to be excluded from notarization.
run: pkgbuild --root brew
--scripts brew/package/scripts
--identifier sh.brew.homebrew
--version "${HOMEBREW_VERSION}"
--install-location /opt/homebrew
--filter .DS_Store
--filter "(.*)/Library/Homebrew/test/support/fixtures/"
--min-os-version "${HOMEBREW_MACOS_OLDEST_SUPPORTED}"
--sign "${PKG_APPLE_DEVELOPER_TEAM_ID}"
Homebrew.pkg
- name: Convert Homebrew license file to RTF
run: (printf "### " && cat brew/LICENSE.txt) |
pandoc --from markdown --standalone --output brew/package/resources/LICENSE.rtf
- name: Build Homebrew installer product package
env:
HOMEBREW_VERSION: ${{ steps.homebrew-version.outputs.version }}
run: productbuild --resources brew/package/resources
--distribution brew/package/Distribution.xml
--package-path Homebrew.pkg
--sign "${PKG_APPLE_DEVELOPER_TEAM_ID}"
"Homebrew-${HOMEBREW_VERSION}.pkg"
- name: Clean up temporary macOS keychain
if: ${{ always() }}
run: |
if [[ -f "${RUNNER_TEMP}/${TEMPORARY_KEYCHAIN_FILE}" ]]
then
security delete-keychain "${RUNNER_TEMP}/${TEMPORARY_KEYCHAIN_FILE}"
fi
- name: Generate build provenance
uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3
with:
subject-path: Homebrew-${{ steps.homebrew-version.outputs.version }}.pkg
- name: Upload installer to GitHub Actions
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: Homebrew-${{ steps.homebrew-version.outputs.version }}.pkg
path: Homebrew-${{ steps.homebrew-version.outputs.version }}.pkg
test:
needs: build
name: "test (${{matrix.name}})"
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
# Intel
- runner: macos-13
name: macos-13-x86_64
# Apple Silicon
- runner: macos-14
name: macos-14-arm64
- runner: macos-15
name: macos-15-arm64
steps:
- name: Download installer from GitHub Actions
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: "${{ needs.build.outputs.installer_path }}"
- name: Unset global Git safe directory setting
run: git config --global --unset-all safe.directory
- name: Remove existing Homebrew installations
run: |
sudo rm -rf brew /{usr/local,opt/homebrew}/{Cellar,Caskroom,Homebrew/Library/Taps}
brew cleanup --prune-prefix
sudo rm -rf /usr/local/{bin/brew,Homebrew} /opt/homebrew /home/linuxbrew
- name: Zero existing installer logs
run: echo | sudo tee /var/log/install.log
- name: Install Homebrew from installer package
env:
INSTALLER_PATH: ${{ needs.build.outputs.installer_path }}
run: sudo installer -verbose -pkg "${INSTALLER_PATH}" -target /
- name: Output installer logs
if: ${{ always() }}
run: sudo cat /var/log/install.log
- run: brew config
- run: brew doctor
- name: Zero existing installer logs (again)
run: echo | sudo tee /var/log/install.log
- name: Reinstall Homebrew from installer package
env:
INSTALLER_PATH: ${{ needs.build.outputs.installer_path }}
run: sudo installer -verbose -pkg "${INSTALLER_PATH}" -target /
- name: Output installer logs (again)
if: ${{ always() }}
run: sudo cat /var/log/install.log
- run: brew config
- run: brew doctor
upload:
needs: [build, test]
runs-on: macos-15
permissions:
# To write assets to GitHub release
contents: write
steps:
- name: Download installer from GitHub Actions
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: "${{ needs.build.outputs.installer_path }}"
- name: Notarize Homebrew installer package
env:
PKG_APPLE_ID_EMAIL: ${{ secrets.PKG_APPLE_ID_EMAIL }}
PKG_APPLE_ID_APP_SPECIFIC_PASSWORD: ${{ secrets.PKG_APPLE_ID_APP_SPECIFIC_PASSWORD }}
INSTALLER_PATH: ${{ needs.build.outputs.installer_path }}
run: xcrun notarytool submit "${INSTALLER_PATH}"
--team-id "${PKG_APPLE_DEVELOPER_TEAM_ID}"
--apple-id "${PKG_APPLE_ID_EMAIL}"
--password "${PKG_APPLE_ID_APP_SPECIFIC_PASSWORD}"
--wait
- name: Install gh
run: brew install gh
- name: Upload installer to GitHub release
if: github.event_name == 'release'
env:
GH_TOKEN: ${{ github.token }}
INSTALLER_PATH: ${{ needs.build.outputs.installer_path }}
run: gh release upload --repo Homebrew/brew
"${GITHUB_REF//refs\/tags\//}"
"${INSTALLER_PATH}"
issue:
needs: [build, test, upload]
if: always() && github.event_name == 'release'
runs-on: ubuntu-latest
env:
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
permissions:
# To create or update issues
issues: write
steps:
- name: Open, update, or close pkg installer issue
uses: Homebrew/actions/create-or-update-issue@master
with:
title: Failed to publish pkg installer
body: >
The pkg installer workflow [failed](${{ env.RUN_URL }}) for release
${{ github.ref_name }}. No pkg installer was uploaded to the GitHub
release.
labels: bug,release blocker
update-existing: ${{ contains(needs.*.result, 'failure') }}
close-existing: ${{ needs.upload.result == 'success' }}
close-from-author: github-actions[bot]
close-comment: >
The pkg installer workflow [succeeded](${{ env.RUN_URL }}) for
release ${{ github.ref_name }}. Closing this issue.