-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
208 lines (186 loc) · 6.89 KB
/
ci-homebrew.yml
File metadata and controls
208 lines (186 loc) · 6.89 KB
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
---
name: CI-Homebrew
permissions:
contents: read
on:
workflow_call:
inputs:
publish_release:
required: true
type: string
release_commit:
required: true
type: string
release_tag:
required: true
type: string
release_version:
required: true
type: string
secrets:
GH_TOKEN:
required: true
GIT_EMAIL:
required: true
GIT_USERNAME:
required: true
jobs:
build_homebrew:
name: ${{ matrix.os_name }}-${{ matrix.os_version }}${{ matrix.release == true && ' (Release)' || '' }}
runs-on: ${{ matrix.os_name }}-${{ matrix.os_version }}
strategy:
fail-fast: false
matrix:
include:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
# while GitHub has larger macOS runners, they are not available for our repos :(
- os_name: "macos"
os_version: "14"
- os_name: "macos"
os_version: "15"
- os_name: "macos"
os_version: "26"
- os_name: "ubuntu"
os_version: "22.04"
- os_name: "ubuntu"
os_version: "latest"
release: true # this job will only configure the formula for release, no validation
steps:
- name: More space
if: runner.os == 'Linux'
uses: LizardByte/actions/actions/more_space@c2e99809a28d738261f986b884cad52fe3a91d5b # v2025.1227.191137
with:
analyze-space-savings: true
clean-all: true
safe-packages: brew
- name: Checkout
uses: actions/checkout@v6
- name: Configure formula
env:
INPUT_RELEASE_VERSION: ${{ inputs.release_version }}
INPUT_RELEASE_COMMIT: ${{ inputs.release_commit }}
INPUT_RELEASE_TAG: ${{ inputs.release_tag }}
MATRIX_RELEASE: ${{ matrix.release }}
PR_CLONE_URL: ${{ github.event.pull_request.head.repo.clone_url }}
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
PR_DEFAULT_BRANCH: ${{ github.event.pull_request.head.repo.default_branch }}
REPOSITORY_CLONE_URL: ${{ github.event.repository.clone_url }}
REPOSITORY_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
run: |
# variables for formula
branch="${GITHUB_HEAD_REF}"
build_version="${INPUT_RELEASE_VERSION}"
clone_url="${REPOSITORY_CLONE_URL}"
commit="${INPUT_RELEASE_COMMIT}"
default_branch="${REPOSITORY_DEFAULT_BRANCH}"
tag="${GITHUB_REF_NAME}"
if [ "${GITHUB_EVENT_NAME}" == "push" ]; then
echo "This is a PUSH event"
if [ "${MATRIX_RELEASE}" == "true" ]; then
# we will publish the formula with the release tag
tag="${INPUT_RELEASE_TAG}"
fi
elif [ "${GITHUB_EVENT_NAME}" == "pull_request" ]; then
echo "This is a PR event"
clone_url=${PR_CLONE_URL}
branch="${PR_HEAD_REF}"
default_branch="${PR_DEFAULT_BRANCH}"
tag="${PR_HEAD_REF}"
fi
echo "Branch: ${branch}"
echo "Clone URL: ${clone_url}"
echo "Tag: ${tag}"
export BRANCH=${branch}
export BUILD_VERSION=${build_version}
export CLONE_URL=${clone_url}
export COMMIT=${commit}
export TAG=${tag}
mkdir -p build
cmake \
-B build \
-S . \
-DGITHUB_DEFAULT_BRANCH="${default_branch}" \
-DSUNSHINE_CONFIGURE_HOMEBREW=ON \
-DSUNSHINE_CONFIGURE_ONLY=ON
# copy formula to artifacts
mkdir -p homebrew
cp -f ./build/sunshine.rb ./homebrew/sunshine.rb
# testing
cat ./homebrew/sunshine.rb
- name: Upload Artifacts
if: matrix.release
uses: actions/upload-artifact@v6
with:
name: build-Homebrew
path: homebrew/
if-no-files-found: error
- name: Setup Xvfb
if: matrix.release != true && runner.os == 'Linux'
run: |
sudo apt-get update -y
sudo apt-get install -y \
xvfb
export DISPLAY=:1
Xvfb ${DISPLAY} -screen 0 1024x768x24 &
echo "DISPLAY=${DISPLAY}" >> "${GITHUB_ENV}"
- run: echo "::add-matcher::.github/matchers/gcc-strip3.json"
- name: Validate Homebrew Formula
id: test
if: matrix.release != true
uses: LizardByte/actions/actions/release_homebrew@copilot/fix-homebrew-action-fork-token
with:
formula_file: ${{ github.workspace }}/homebrew/sunshine.rb
git_email: ${{ secrets.GIT_EMAIL }}
git_username: ${{ secrets.GIT_USERNAME }}
publish: false
token: ${{ secrets.GH_TOKEN }}
validate: true
- run: echo "::remove-matcher owner=gcc-strip3::"
- name: Upload coverage artifact
if: >-
always() &&
matrix.release != true &&
(steps.test.outcome == 'success' || steps.test.outcome == 'failure')
uses: actions/upload-artifact@v6
with:
name: coverage-Homebrew-${{ matrix.os_name }}-${{ matrix.os_version }}
path: |
${{ steps.test.outputs.testpath }}/coverage.xml
${{ steps.test.outputs.testpath }}/tests/test_results.xml
if-no-files-found: error
- name: Patch homebrew formula
# create beta version of the formula
# don't run this on macOS, as the sed command fails
if: matrix.release
run: |
# variables
formula_file="homebrew/sunshine-beta.rb"
# rename the file
mv homebrew/sunshine.rb $formula_file
# update the formula
sed -i 's/class Sunshine < Formula/class SunshineBeta < Formula/' $formula_file
sed -i 's/conflicts_with "sunshine-beta"/conflicts_with "sunshine"/' $formula_file
sed -i '/^ version .*$/d' $formula_file
# update livecheck to check for latest stable or pre-release
# shellcheck disable=SC1004
sed -i '/strategy :github_latest do |json, regex|/,/^ end$/c\
strategy :github_releases do |json, regex|\
json.map do |release|\
next if release["draft"]\
\
match = release["tag_name"]&.match(regex)\
next if match.blank?\
\
match[1]\
end\
end' $formula_file
# print new file
echo "New formula:"
cat $formula_file
- name: Upload Artifacts (Beta)
if: matrix.release
uses: actions/upload-artifact@v6
with:
name: beta-Homebrew
path: homebrew/
if-no-files-found: error