Repository navigation
270 lines (260 loc) · 9.78 KB
/
Copy pathmake-release.yml
File metadata and controls
270 lines (260 loc) · 9.78 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
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
268
269
270
on:
push:
tags:
- v*
permissions:
contents: write
name: make-release
jobs:
prepare:
name: Prepare release builds
runs-on: ubuntu-latest
outputs:
version: ${{ steps.prepare.outputs.version }}
prerelease: ${{ steps.prepare.outputs.prerelease }}
steps:
- uses: actions/checkout@v7.0.1
- name: Prepare sources and tools
id: prepare
uses: ./.github/actions/prepare-cross
makerelease:
needs: prepare
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: ubuntu-latest
target: x86_64-pc-windows-gnu
# Start fresh when switching from host MinGW to the container toolchain.
cache-version: v2
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
name: make release (${{ matrix.target }})
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v7.0.1
- name: Install Rust
id: rust
uses: dtolnay/rust-toolchain@stable
- if: ${{ matrix.os == 'macos-latest' }}
name: Install deps
shell: bash
run: |
brew install coreutils
echo "$(brew --prefix coreutils)/libexec/gnubin" >> "$GITHUB_PATH"
- name: Restore shared cargo sources
uses: actions/cache/restore@v6.1.0
with:
path: |
~/.cargo/registry
~/.cargo/git/db
key: cross-sources-v1-${{ hashFiles('Cargo.lock') }}
- name: Download Linux cross tool
if: matrix.os == 'ubuntu-latest'
uses: actions/download-artifact@v8
with:
name: cross-tool-Linux-X64
path: ${{ runner.temp }}/cross-tools
- name: Enable Linux cross tool
if: matrix.os == 'ubuntu-latest'
run: |
chmod +x "$RUNNER_TEMP/cross-tools/cross"
echo "$RUNNER_TEMP/cross-tools" >> "$GITHUB_PATH"
# Share matching PR build caches. Include the host as well as the target:
# target/ also contains host-built
# proc macros and build scripts. Never fall back to another host/target.
- name: Cache cargo build
uses: actions/cache@v6.1.0
with:
path: target/release-builds/${{ matrix.target }}
key: cross-build-${{ matrix.cache-version || 'v1' }}-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target }}-${{ steps.rust.outputs.cachekey }}-${{ hashFiles('Cargo.lock') }}-${{ github.sha }}
restore-keys: |
cross-build-${{ matrix.cache-version || 'v1' }}-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target }}-${{ steps.rust.outputs.cachekey }}-${{ hashFiles('Cargo.lock') }}-
- name: Run make release
env:
RELEASE_VERSION: ${{ needs.prepare.outputs.version }}
RELEASE_TARGET: ${{ matrix.target }}
run: |
make release CROSS_TARGETS="$RELEASE_TARGET" VERSION="$RELEASE_VERSION"
ls -la cross
shell: bash
- name: Name target installation instructions
env:
RELEASE_TARGET: ${{ matrix.target }}
run: mv cross/README.md "cross/$RELEASE_TARGET-README.md"
- name: Upload target release files
uses: actions/upload-artifact@v7
with:
name: release-${{ matrix.target }}
path: cross
if-no-files-found: error
createrelease:
runs-on: ubuntu-latest
needs: [prepare, makerelease]
name: createrelease
env:
VERSION: v${{ needs.prepare.outputs.version }}
steps:
- uses: actions/checkout@v7.0.1
- name: Download all target release files
uses: actions/download-artifact@v8
with:
pattern: release-*
path: build
merge-multiple: true
- name: Combine installation instructions and check artifacts
shell: bash
run: |
echo 'These instructions are meant as an easy way to install. Unix snippets use `sha256sum`; macOS users may need `coreutils` for that command.' > release.md
echo "" >> release.md
targets=(
x86_64-apple-darwin
aarch64-apple-darwin
x86_64-pc-windows-gnu
x86_64-unknown-linux-musl
aarch64-unknown-linux-musl
)
for target in "${targets[@]}"; do
test -s "build/zoo-$target"
for algorithm in md5 sha256; do
hash=$(awk '{print $1}' "build/zoo-$target.$algorithm")
echo "$hash build/zoo-$target" | "${algorithm}sum" -c -
done
cat "build/$target-README.md" >> release.md
rm "build/$target-README.md"
done
# Keep the download site's combined README and GitHub release body identical.
cp release.md build/README.md
mkdir -p "releases/cli/$VERSION"
cp build/* "releases/cli/$VERSION/"
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v3.0.0
with:
credentials_json: '${{ secrets.GOOGLE_CLOUD_DL_SA }}'
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v3.0.1
with:
project_id: kittycadapi
- name: Upload binary files
uses: google-github-actions/upload-cloud-storage@v3.0.0
with:
path: releases
destination: dl.kittycad.io
- name: Create a Release
uses: softprops/action-gh-release@v3.0.4
with:
body_path: ${{ github.workspace }}/release.md
prerelease: ${{ needs.prepare.outputs.prerelease }}
files: ./build/zoo-*
createhomebrew:
runs-on: ubuntu-latest
needs: [prepare, createrelease]
name: createhomebrew
env:
VERSION: v${{ needs.prepare.outputs.version }}
steps:
- uses: actions/checkout@master
- name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v3.0.0'
with:
credentials_json: '${{ secrets.GOOGLE_CLOUD_DL_SA }}'
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v3.0.1
with:
project_id: kittycadapi
- name: bundle binaries and make formula
shell: bash
run: |
mkdir homebrew
cp homebrew-template.rb homebrew/kittycad.rb
input_names=(
"x86_64-apple-darwin"
"aarch64-apple-darwin"
"x86_64-unknown-linux-musl"
"aarch64-unknown-linux-musl"
)
homebrew_names=(
"x86_64_darwin"
"aarch64_darwin"
"x86_64_linux"
"aarch64_linux"
)
to_zip_files=""
version="$VERSION"
sed -i "s#replace-semver#$version#g" "./homebrew/kittycad.rb"
for i in "${!input_names[@]}"; do
input_name="${input_names[$i]}"
homebrew_name="${homebrew_names[$i]}"
mkdir "./homebrew/$homebrew_name"
curl -L "https://dl.zoo.dev/releases/cli/$version/zoo-$input_name" -o "./homebrew/$homebrew_name/zoo"
sha256=$(sha256sum "./homebrew/$homebrew_name/zoo")
hash=$(printf '%s\n' "$sha256" | cut -d' ' -f1)
sed -i "s#replace-$homebrew_name-sha#$hash#g" "./homebrew/kittycad.rb"
to_zip_files="$to_zip_files $homebrew_name/zoo"
done
(cd ./homebrew && tar -czvf kittycad-cli.tar.gz $to_zip_files)
sha256=$(sha256sum "./homebrew/kittycad-cli.tar.gz")
hash=$(printf '%s\n' "$sha256" | cut -d' ' -f1)
sed -i "s#replace-tarball-sha#$hash#g" "./homebrew/kittycad.rb"
# clean up
for homebrew_name in "${homebrew_names[@]}"; do
rm -rf "./homebrew/$homebrew_name"
done
# verify output, debug code remove later.
echo "tarball and formula"
(cd ./homebrew && ls)
echo "formula contents"
cat ./homebrew/kittycad.rb
- name: move files to dir for upload
shell: bash
run: |
mkdir -p releases/$(basename $(pwd))
cp -r homebrew releases/$(basename $(pwd))/${VERSION}
- name: 'upload binary files'
id: upload-files
uses: google-github-actions/upload-cloud-storage@v3.0.0
with:
path: releases
destination: dl.kittycad.io
- uses: actions/create-github-app-token@v3.3.0
id: app-token
with:
# required
app-id: ${{ secrets.GH_ORG_APP_ID }}
private-key: ${{ secrets.GH_ORG_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- uses: actions/checkout@v7.0.1
with:
repository: 'kittycad/homebrew-kittycad'
path: 'homebrew-kittycad'
token: ${{ steps.app-token.outputs.token }}
- name: 'replacing Formula/kittycad.rb with ./hombrew/kittycad.rb'
shell: bash
run: |
cp ./homebrew/kittycad.rb homebrew-kittycad/Formula/kittycad.rb
- name: commit the changes in the repo
shell: bash
run: |
cd homebrew-kittycad
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git commit -am "YOYO BREW FORMULAR! 🍻" || exit 0
git fetch origin
git rebase origin/main || exit 0
export NEW_BRANCH="update-tap-formula"
git checkout -b "$NEW_BRANCH"
git push -f origin "$NEW_BRANCH"
gh pr create --title "Update tap formula" \
--body "Updating the formula for our homebrew tap" \
--reviewer jessfraz \
--head "$NEW_BRANCH" \
--base main || true
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}