-
Notifications
You must be signed in to change notification settings - Fork 52
190 lines (182 loc) · 7.25 KB
/
build-tvos.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
name: build-tvos
on:
push:
paths-ignore:
- '**/README.md'
pull_request:
paths-ignore:
- '**/README.md'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
TARGET: "tvos"
NO_FORCE: 1
GA_CI_SECRET: ${{ secrets.CI_SECRET }}
USE_ARTIFACT: true
jobs:
build-macos-platforms:
runs-on: macos-14
strategy:
matrix:
bundle: [1, 2, 3]
env:
BUNDLE: ${{ matrix.bundle }}
DEVELOPER_DIR: "/Applications/Xcode_15.4.app/Contents/Developer"
steps:
- name: Determine Release
id: vars
shell: bash
run: |
if [[ "${{ github.ref }}" == "refs/heads/master" ]]; then
echo "RELEASE=nightly" >> $GITHUB_ENV
echo "PRERELEASE=false" >> $GITHUB_ENV
elif [[ "${{ github.ref }}" == "refs/heads/bleeding" ]]; then
echo "RELEASE=bleeding" >> $GITHUB_ENV
echo "PRERELEASE=true" >> $GITHUB_ENV
else
echo "RELEASE=bleeding" >> $GITHUB_ENV
echo "PRERELEASE=true" >> $GITHUB_ENV
fi
- uses: actions/checkout@v4
- name: Scripts Calc Formula - ${{ env.TARGET }} Bundle ${{ matrix.bundle }}
run: ./scripts/calculate_formulas.sh
- name: Scripts Install
run: ./scripts/tvos/install.sh
- name: 'Download artifacts'
uses: actions/github-script@v7
if: env.USE_ARTIFACT == 'true'
with:
script: |
const fs = require('fs');
const path = require('path');
// https://api.github.com/repos/openframeworks/apothecary/actions/artifacts?per_page=100
// Ensure the output directory exists
const outputDir = path.join(process.env.GITHUB_WORKSPACE, 'out');
if (!fs.existsSync(outputDir)){
fs.mkdirSync(outputDir);
}
// List all artifacts for the repository
const artifacts = await github.rest.actions.listArtifactsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
sort: 'created_at',
direction: 'desc',
per_page: 20
});
const artifactNamesToDownload = ['libs-tvos-tvos-1', 'libs-tvos-tvos-2', 'libs-tvos-tvos-3'];
let count = 0;
const max=3;
for (const artifact of artifacts.data.artifacts) {
if (artifactNamesToDownload.includes(artifact.name) && !artifact.expired) {
// Download the artifact
const download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id,
archive_format: 'zip',
});
const artifactPath = path.join(outputDir, `${artifact.name}.zip`);
fs.writeFileSync(artifactPath, Buffer.from(download.data));
console.log(`Downloaded ${artifact.name} to ${artifactPath}`);
count++;
if (count >= max) {
break;
}
}
}
- name: Extract Artifacts to /out
if: env.USE_ARTIFACT == 'true'
run: |
mkdir -p out
if ls out/*.zip 1> /dev/null 2>&1; then
for zip in out/*.zip; do
echo "Extracting $zip..."
unzip -o "$zip" -d out/
done
echo "Extraction complete."
rm out/*.zip
else
echo "No zip files to extract."
fi
if ls out/*.tar.bz2 1> /dev/null 2>&1; then
for tarball in out/*.tar.bz2; do
echo "Extracting $tarball..."
tar -xjf "$tarball" -C out/
done
echo ".tar.bz2 extraction complete."
rm -f out/*.tar.bz2
else
echo "No .tar.bz2 files to extract."
fi
rm -f xout/*.tar.bz2
rm -f out/*.tar.bz2
- name: Build tvOS arm64
working-directory: ${{ env.GITHUB_WORKSPACE }}
run: scripts/build.sh
env:
BUNDLE: ${{ matrix.bundle }}
ARCH: arm64
- name: Build tvOS x86_64
working-directory: ${{ env.GITHUB_WORKSPACE }}
run: scripts/build.sh
env:
BUNDLE: ${{ matrix.bundle }}
ARCH: x86_64
- name: Build tvOS SIMULATOR arm64
working-directory: ${{ env.GITHUB_WORKSPACE }}
run: scripts/build.sh
env:
BUNDLE: ${{ matrix.bundle }}
ARCH: SIM_arm64
- name: List output directory
run: ls -lah out/
- name: Cleanup out of bundle
working-directory: ${{ env.GITHUB_WORKSPACE }}
run: scripts/artifact-clean.sh
env:
BUNDLE: ${{ matrix.bundle }}
ARCH: SIM_arm64
- name: Package Binaries for Artifact
if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bleeding')
working-directory: ${{ env.GITHUB_WORKSPACE }}
run: scripts/artifact.sh
env:
BUNDLE: ${{ matrix.bundle }}
GA_CI_SECRET: ${{ secrets.CI_SECRET }}
- name: Upload binaries as Artifact
if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bleeding')
uses: actions/upload-artifact@v4
with:
name: libs-tvos-${{ env.TARGET }}-${{ matrix.bundle }}
path: out/openFrameworksLibs_${{ env.RELEASE }}_${{ env.TARGET }}_${{ matrix.bundle }}.tar.bz2
retention-days: 31
- name: Remove .tar.bz2 files
if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bleeding')
run: |
echo "Removing .tar.bz2 files from out/ directory..."
rm -f out/*.tar.bz2
rm -f xout/*.tar.bz2
echo "Cleanup complete."
- name: Merge our tvOS libaries into XC Framework
working-directory: ${{ env.GITHUB_WORKSPACE }}
run: scripts/tvos/xcframework_all.sh
env:
BUNDLE: ${{ matrix.bundle }}
GA_CI_SECRET: ${{ secrets.CI_SECRET }}
- name: Package
if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bleeding')
working-directory: ${{ env.GITHUB_WORKSPACE }}
run: scripts/package.sh
env:
BUNDLE: ${{ matrix.bundle }}
GA_CI_SECRET: ${{ secrets.CI_SECRET }}
- name: Update Release XCFramework
if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bleeding')
uses: johnwbyrd/update-release@v1.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.RELEASE }}
release: ${{ env.RELEASE }}
prerelease: ${{ env.PRERELEASE }}
files: xout/openFrameworksLibs_${{ env.RELEASE }}_${{ env.TARGET }}_${{ matrix.bundle }}.tar.bz2