-
Notifications
You must be signed in to change notification settings - Fork 4
258 lines (247 loc) · 8.99 KB
/
make-release.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
on:
push:
tags:
- v*
permissions:
contents: write
name: make-release
jobs:
makerelease:
strategy:
matrix:
os: [macos-latest, ubuntu-latest]
name: make release
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v2.1.7'
with:
credentials_json: '${{ secrets.GOOGLE_CLOUD_DL_SA }}'
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2.1.2
with:
project_id: kittycadapi
- name: Install latest nightly
uses: dtolnay/rust-toolchain@stable
- if: ${{ matrix.os == 'ubuntu-latest' }}
name: Install deps
shell: bash
run: |
./.github/workflows/cross-deps.sh
- if: ${{ matrix.os == 'macos-latest' }}
name: Install deps
shell: bash
run: |
brew install \
coreutils \
jq
cargo install toml-cli
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Run make cross
run: |
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
make release
ls -la cross
shell: bash
- name: move files to dir for upload
shell: bash
run: |
export VERSION=v$(toml get Cargo.toml package.version | jq -r .)
mkdir -p releases/$(basename $(pwd))
cp -r cross releases/$(basename $(pwd))/${VERSION}
cp cross/README.md cross/${{matrix.os}}-${{github.ref_name}}-README.md
- name: 'upload binary files'
id: upload-files
uses: google-github-actions/upload-cloud-storage@v2.2.1
with:
path: releases
destination: dl.kittycad.io
# Store the binary artifacts for retrival later.
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.os }}-${{github.ref_name}}
path: ./cross
# Store the readme as an artifact so we can combine the two.
- name: Archive the README.md data
uses: actions/upload-artifact@v4
with:
name: ${{matrix.os}}-${{github.ref_name}}-README.md
path: ${{github.workspace}}/cross/${{matrix.os}}-${{github.ref_name}}-README.md
createrelease:
runs-on: ubuntu-latest
needs: [makerelease]
name: createrelease
steps:
- uses: actions/checkout@v4
- name: Install latest nightly
uses: dtolnay/rust-toolchain@stable
- uses: actions/download-artifact@v4
with:
name: release-macos-latest-${{github.ref_name}}
path: build
- uses: actions/download-artifact@v4
with:
name: release-ubuntu-latest-${{github.ref_name}}
path: build
- uses: actions/download-artifact@v4
with:
name: ubuntu-latest-${{github.ref_name}}-README.md
- uses: actions/download-artifact@v4
with:
name: macos-latest-${{github.ref_name}}-README.md
- name: combine readmes
shell: bash
run: |
ls -la
echo 'These instructions are meant as an easy way to install. Note: you likely need to install `coreutils` in order to have the `sha256sum` command.' > release.md
echo "" >> release.md
cat macos-latest-${{github.ref_name}}-README.md \
ubuntu-latest-${{github.ref_name}}-README.md \
>> release.md
rm build/*-README.md
rm build/README.md
- name: Get if prerelease
shell: bash
id: extract_prerelease
run: |
cargo install toml-cli
export VERSION=v$(toml get Cargo.toml package.version | jq -r .)
if echo $VERSION | grep -q "rc"; then
echo "##[set-output name=prerelease;]$(echo true)";
else
if echo $VERSION | grep -q "pre"; then
echo "##[set-output name=prerelease;]$(echo true)";
else
echo "##[set-output name=prerelease;]$(echo false)";
fi
fi
- name: Create a Release
uses: softprops/action-gh-release@v2
with:
body_path: ${{github.workspace}}/release.md
prerelease: ${{steps.extract_prerelease.outputs.prerelease}}
files: ./build/*
createhomebrew:
runs-on: ubuntu-latest
needs: [makerelease]
name: createhomebrew
steps:
- uses: actions/checkout@master
- name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v2.1.7'
with:
credentials_json: '${{ secrets.GOOGLE_CLOUD_DL_SA }}'
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2.1.2
with:
project_id: kittycadapi
- name: Install deps
shell: bash
run: |
./.github/workflows/cross-deps.sh
- 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=v$(toml get Cargo.toml package.version | jq -r .)
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: |
export VERSION=v$(toml get Cargo.toml package.version | jq -r .)
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@v2.2.1
with:
path: releases
destination: dl.kittycad.io
- uses: actions/create-github-app-token@v1
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@v4
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 formular for our homebrew tap" \
--head "$NEW_BRANCH" \
--base main || true
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}