-
Notifications
You must be signed in to change notification settings - Fork 4
247 lines (207 loc) · 7.34 KB
/
release.yaml
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
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Release
on:
workflow_dispatch:
# Manual triggering.
jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install deps
run: |
sudo apt -y update
sudo apt -y install \
coreutils debhelper devscripts fakeroot gpg reprepro
- name: Set version number
run: |
# This uses the "dch" tool from Debian to set the package version in
# the Debian package metadata.
export DEBEMAIL="[email protected]"
export DEBFULLNAME="Shaka Lab Team"
PACKAGE_VERSION=$(date -u +%Y%m%d.%H%M%S)
for linux_package in shaka-*/linux; do
dch --nomultimaint \
-c "$linux_package/debian/changelog" \
-v "$PACKAGE_VERSION" ""
done
- name: Import GPG key
run: |
# A GPG key is used to sign the debian packages for distribution.
echo "${{ secrets.DEB_GPG_KEY }}" | gpg --import
- name: Build packages
run: |
for linux_package in shaka-*/linux; do
(
cd "$linux_package"
fakeroot debian/rules binary
)
done
- name: Stage packages
run: |
# This uses the reprepro tool to sign packages and build the
# necessarily layout for Debian package distribution.
mkdir staging
mkdir staging/conf
cp distribution/linux/reprepro.conf staging/conf/distributions
reprepro --basedir staging includedeb stable shaka-*/*.deb
gpg -o staging/public.key --armor --export [email protected]
- name: Upload packages
uses: actions/upload-pages-artifact@v1
with:
path: staging
deploy-linux:
needs: build-linux
# Linux packages are deployed as static content to GitHub Pages.
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- id: deployment
uses: actions/deploy-pages@v1
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Set version number
shell: bash
run: |
PACKAGE_VERSION=$(date -u +%Y%m%d.%H%M%S)
for windows_package in shaka-*/windows; do
# Set the package version by editing the .nuspec file.
sed -e "s@\(<version>\).*\(</version>\)@\1$PACKAGE_VERSION\2@" \
-i.bk "$windows_package"/*.nuspec
done
- name: Build packages
shell: bash
run: |
for windows_package in shaka-*/windows; do
(
cd "$windows_package"
choco pack *.nuspec
)
done
- name: Stage packages
shell: bash
run: |
mkdir staging
cp shaka-*/windows/*.nupkg staging/
- name: Upload packages
uses: actions/upload-artifact@v3
with:
name: windows-packages
path: staging/
deploy-windows:
needs: build-windows
# Windows packages are deployed to App Engine and served via
# express-chocolatey-server.
runs-on: ubuntu-latest
steps:
- name: Download packages
uses: actions/download-artifact@v3
with:
name: windows-packages
- name: Prepare app engine
run: |
# Create a package.json file with the deps for our App Engine
# instance (express-chocolatey-server), and a script to start the
# server.
cat >package.json <<EOF
{
"dependencies": {
"express-chocolatey-server": "^1.0.0"
},
"scripts": {
"start": "express-chocolatey-server *.nupkg"
},
"engines": {
"node": "22.x.x"
}
}
EOF
# Create the app.yaml definition for App Engine.
cat >app.yaml <<EOF
runtime: nodejs22
handlers:
- url: /.*
secure: always
redirect_http_response_code: 301
script: auto
EOF
- uses: google-github-actions/auth@v2
with:
credentials_json: '${{ secrets.APPENGINE_DEPLOY_KEY }}'
- uses: google-github-actions/deploy-appengine@v2
with:
project_id: '${{ secrets.APPENGINE_PROJECT_ID }}'
version: '${{ secrets.APPENGINE_PROJECT_VERSION }}'
promote: false
deploy-macos:
# macOS packages are distributed through a tap repo. Check out the tap
# repo instead of the source repo, then import source from the source repo,
# and finish by pushing an update to the tap repo.
runs-on: ubuntu-latest
steps:
- name: Check out tap repo
uses: actions/checkout@v3
with:
repository: '${{ secrets.HOMEBREW_TAP_REPO }}'
fetch-depth: 0 # The entire repo history, so we can push an update
- name: Wipe source and formula folders
run: |
# Source, formula, and cask folders in the tap repo are about to be
# replaced.
git rm -rf shaka-lab-source || true
git rm -rf Formula || true
git rm -rf Casks || true
- name: Check out source repo
# This puts the source repo contents at the expected location in the
# tap repo.
uses: actions/checkout@v3
with:
path: shaka-lab-source
- name: Finish staging tap repo
run: |
PACKAGE_VERSION=$(date -u +%Y%m%d.%H%M%S)
# Wipe out the internal .git folder from the source repo.
rm -rf shaka-lab-source/.git
# Recreate Cask folders.
mkdir -p Casks
# Copy all casks to their required locations in the tap repo.
cp shaka-lab-source/*/macos/*.rb Casks/
# Set the package version by editing the homebrew casks
for i in Casks/*; do
sed -e "s/^\(\s*version\s\+\"\).*\(\"\s*\)$/\1$PACKAGE_VERSION\2/" \
-i "$i"
done
# Update the tap repo with a new commit.
git add Casks/
git add shaka-lab-source/
git config user.email [email protected]
git config user.name "Shaka Bot"
git commit -m "Release $PACKAGE_VERSION"
- name: Push homebrew repo
run: |
# Remove default authentication headers from GitHub Actions
# environment, since we're pushing to a different repo as a different
# user.
git config --unset-all http.https://github.com/.extraheader
git push https://shaka-bot:${{ secrets.HOMEBREW_DEPLOY_TOKEN }}@github.com/${{ secrets.HOMEBREW_TAP_REPO }}