-
Notifications
You must be signed in to change notification settings - Fork 36
383 lines (337 loc) · 16.4 KB
/
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
name: Build for a release
on:
push:
tags:
- '*'
workflow_dispatch:
jobs:
push-to-aur:
if: ${{ startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest
steps:
- name: Checkout latest commit
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
path: packaging
- name: Publish AUR package
run: |
mkdir -p ~/.ssh/
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_$SSH_KEY_ALGORITHM
sudo chmod 600 ~/.ssh/id_$SSH_KEY_ALGORITHM
echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
git clone ssh://[email protected]/ungoogled-chromium.git aur-upstream
source packaging/PKGBUILD
rm -rf packaging/aur
rm packaging/README.md
mv packaging/* aur-upstream
cd aur-upstream
# To avoid conflicts with other steps in this job, makepkg for generating .SRCINFO is the only command running in an arch environment
docker run --mount type=bind,source=$(pwd)/PKGBUILD,target=/home/build/PKGBUILD --entrypoint sh archlinux -c "pacman -Syu --needed --noconfirm binutils && useradd -m build && chown -R build /home/build && su build -c 'cd && makepkg --printsrcinfo > .SRCINFO'"
docker cp $(docker container ls --latest --format '{{.ID}}'):/home/build/.SRCINFO .
git config user.name "$GIT_NAME"
git config user.email "$GIT_EMAIL"
git add .
git commit -m "Upgrade to $pkgver-$pkgrel"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }}
SSH_KEY_ALGORITHM: ${{ secrets.SSH_KEY_ALGORITHM }}
GIT_NAME: ${{ secrets.GIT_NAME }}
GIT_EMAIL: ${{ secrets.GIT_EMAIL }}
build:
runs-on: self-hosted
steps:
- name: test
run: |
echo hi
build-container:
if: ${{ startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest
container:
image: archlinux
volumes:
- /:/host
steps:
- name: Checkout latest commit
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install dependencies
run: pacman -Syu --needed --noconfirm docker base-devel
- name: Free space on runner
run: |
sudo rm -rf /host/usr/share/dotnet
sudo rm -rf /host/usr/local/lib/android
sudo rm -rf /host/opt/ghc
sudo rm -rf /host/opt/hostedtoolcache/CodeQL
sudo docker image prune --all --force
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build container
id: build
run: |
# Add non root user to run makepkg with
useradd makepkg --no-create-home
chown -R makepkg .
echo "::group::Generating source archive..."
if [ $(su -c "makepkg --printsrcinfo" makepkg | grep -c "fetch-chromium-release") -eq 0 ]; then
SOURCE_TARBALL_URL="$(su -c "makepkg --printsrcinfo" makepkg | grep commondatastorage.googleapis.com | awk '{ print $3 }')"
SOURCE_TARBALL_FILENAME="$(echo "$SOURCE_TARBALL_URL" | awk -F'/' '{ print $NF }')"
SOURCE_TARBALL_INNER_DIRECTORY_NAME="$(echo "$SOURCE_TARBALL_FILENAME" | sed 's/.tar.xz//')"
SOURCE_TARBALL_CHECKSUM="$(su -c "makepkg --printsrcinfo" makepkg | grep sha256sums -m 1 | awk '{ print $3 }')"
# Taken from https://github.com/NixOS/nixpkgs/blob/7a14a916f856dc4acda391a9febc3bfb37f2a732/pkgs/applications/networking/browsers/chromium/recompress-tarball.nix#L31-L54
curl "$SOURCE_TARBALL_URL" \
| xz -d --threads=0 \
| tar xf - \
--warning=no-timestamp \
--exclude=third_party/llvm \
--exclude=third_party/rust-src \
--exclude='build/linux/debian_*-sysroot' \
--exclude='*.tar.[a-zA-Z0-9][a-zA-Z0-9]' \
--exclude='*.tar.[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]' \
--exclude=third_party/llvm-build \
--exclude=third_party/rust-toolchain \
--exclude=third_party/instrumented_libs \
--strip-components=1 \
--one-top-level="$SOURCE_TARBALL_INNER_DIRECTORY_NAME"
tar \
--use-compress-program "zstd -T0" \
--sort name \
--mtime "1970-01-01" \
--owner=root --group=root \
--numeric-owner --mode=go=rX,u+rw,a-s \
--remove-files \
-cf "$SOURCE_TARBALL_FILENAME" "$SOURCE_TARBALL_INNER_DIRECTORY_NAME"
RECOMPRESSED_TARBALL_CHECKSUM="$(sha256sum "$SOURCE_TARBALL_FILENAME" | awk '{ print $1 }')"
sed -i "s/$SOURCE_TARBALL_CHECKSUM/$RECOMPRESSED_TARBALL_CHECKSUM/" PKGBUILD
fi
# Generate archive with all required sources for the build
# This either includes local or downloads files using an url
su -c "makepkg --allsource" makepkg
echo "::endgroup::"
CHROMIUM_VERSION="$(compgen -G "*.src.tar.gz" | grep -Po '([0-9\.]+-[0-9]*)')"
REGISTRY="ghcr.io/${{ github.repository_owner }}"
NAME="ungoogled-chromium-archlinux"
ID="$(echo $REGISTRY/$NAME | tr '[A-Z]' '[a-z]')"
REF="$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')"
[[ "${{ github.ref }}" == "refs/tags/"* ]] && REF=$(echo $REF | sed -e 's/^v//')
[ "$REF" == "master" ] && REF=latest
VERSION_TAG="$ID:$CHROMIUM_VERSION"
LATEST_TAG="$ID:latest"
echo "CHROMIUM_VERSION=$CHROMIUM_VERSION"
echo "REGISTRY=$REGISTRY"
echo "NAME=$NAME"
echo "ID=$ID"
echo "REF=$REF"
echo "VERSION_TAG=$REF_TAG"
echo "LATEST_TAG=$LATEST_TAG"
echo "::group::Building container image..."
# Build container from source files
docker build . \
--file .github/workflows/container/Dockerfile \
--tag "$VERSION_TAG" \
--tag "$LATEST_TAG"
# Reduce worker space used
rm -rf *
echo "::endgroup::"
echo "chromium-version=$CHROMIUM_VERSION" >> $GITHUB_OUTPUT
echo "version-tag=$VERSION_TAG" >> $GITHUB_OUTPUT
echo "latest-tag=$LATEST_TAG" >> $GITHUB_OUTPUT
- name: Push image
run: |
docker push "${{ steps.build.outputs.version-tag }}"
docker push "${{ steps.build.outputs.latest-tag }}"
outputs:
chromium-version: "${{ steps.build.outputs.chromium-version }}"
image-tag: "${{ steps.build.outputs.version-tag }}"
build-1:
runs-on: ubuntu-latest
needs: build-container
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Stage
run: npm run setup --prefix ./.github/actions/stage
- name: Run Stage
id: stage
uses: ./.github/actions/stage
with:
chromium-version: "${{ join(needs.*.outputs.chromium-version) }}"
use-registry: true
registry-token: "${{ secrets.GITHUB_TOKEN }}"
image-tag: "${{ join(needs.*.outputs.image-tag) }}"
outputs:
finished: "${{ steps.stage.outputs.finished }}"
chromium-version: "${{ steps.stage.outputs.chromium-version }}"
image-tag: "${{ steps.stage.outputs.image-tag }}"
build-2:
runs-on: ubuntu-latest
needs: build-1
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Stage
run: npm run setup --prefix ./.github/actions/stage
- name: Run Stage
id: stage
uses: ./.github/actions/stage
with:
finished: "${{ join(needs.*.outputs.finished) }}"
progress-name: build-1
chromium-version: "${{ join(needs.*.outputs.chromium-version) }}"
use-registry: true
registry-token: "${{ secrets.GITHUB_TOKEN }}"
image-tag: "${{ join(needs.*.outputs.image-tag) }}"
outputs:
finished: "${{ steps.stage.outputs.finished }}"
chromium-version: "${{ steps.stage.outputs.chromium-version }}"
image-tag: "${{ steps.stage.outputs.image-tag }}"
build-3:
runs-on: ubuntu-latest
needs: build-2
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Stage
run: npm run setup --prefix ./.github/actions/stage
- name: Run Stage
id: stage
uses: ./.github/actions/stage
with:
finished: "${{ join(needs.*.outputs.finished) }}"
progress-name: build-2
chromium-version: "${{ join(needs.*.outputs.chromium-version) }}"
use-registry: true
registry-token: "${{ secrets.GITHUB_TOKEN }}"
image-tag: "${{ join(needs.*.outputs.image-tag) }}"
outputs:
finished: "${{ steps.stage.outputs.finished }}"
chromium-version: "${{ steps.stage.outputs.chromium-version }}"
image-tag: "${{ steps.stage.outputs.image-tag }}"
build-4:
runs-on: ubuntu-latest
needs: build-3
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Stage
run: npm run setup --prefix ./.github/actions/stage
- name: Run Stage
id: stage
uses: ./.github/actions/stage
with:
finished: "${{ join(needs.*.outputs.finished) }}"
progress-name: build-3
chromium-version: "${{ join(needs.*.outputs.chromium-version) }}"
use-registry: true
registry-token: "${{ secrets.GITHUB_TOKEN }}"
image-tag: "${{ join(needs.*.outputs.image-tag) }}"
outputs:
finished: "${{ steps.stage.outputs.finished }}"
chromium-version: "${{ steps.stage.outputs.chromium-version }}"
image-tag: "${{ steps.stage.outputs.image-tag }}"
build-5:
runs-on: ubuntu-latest
needs: build-4
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Stage
run: npm run setup --prefix ./.github/actions/stage
- name: Run Stage
id: stage
uses: ./.github/actions/stage
with:
finished: "${{ join(needs.*.outputs.finished) }}"
progress-name: build-4
chromium-version: "${{ join(needs.*.outputs.chromium-version) }}"
use-registry: true
registry-token: "${{ secrets.GITHUB_TOKEN }}"
image-tag: "${{ join(needs.*.outputs.image-tag) }}"
outputs:
finished: "${{ steps.stage.outputs.finished }}"
chromium-version: "${{ steps.stage.outputs.chromium-version }}"
image-tag: "${{ steps.stage.outputs.image-tag }}"
build-6:
runs-on: ubuntu-latest
needs: build-5
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Stage
run: npm run setup --prefix ./.github/actions/stage
- name: Run Stage
id: stage
uses: ./.github/actions/stage
with:
finished: "${{ join(needs.*.outputs.finished) }}"
progress-name: build-5
chromium-version: "${{ join(needs.*.outputs.chromium-version) }}"
use-registry: true
registry-token: "${{ secrets.GITHUB_TOKEN }}"
image-tag: "${{ join(needs.*.outputs.image-tag) }}"
outputs:
finished: "${{ steps.stage.outputs.finished }}"
chromium-version: "${{ steps.stage.outputs.chromium-version }}"
image-tag: "${{ steps.stage.outputs.image-tag }}"
publish-release:
runs-on: ubuntu-latest
needs: build-6
steps:
- name: Download package
uses: actions/[email protected]
with:
name: "${{ join(needs.*.outputs.chromium-version) }}"
- name: Format GitHub release body
run: |
echo '```' >> body.md
cat sum.txt >> body.md
echo '```' >> body.md
- name: Publish GitHub release
uses: softprops/action-gh-release@cd28b0f5ee8571b76cfdaa62a30d51d752317477
with:
name: "${{ join(needs.*.outputs.chromium-version) }}"
body_path: body.md
files: |
*.pkg.*
sum.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout latest commit
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
path: packaging
- name: Publish AUR package
run: |
mkdir -p ~/.ssh/
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_$SSH_KEY_ALGORITHM
sudo chmod 600 ~/.ssh/id_$SSH_KEY_ALGORITHM
echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
git clone ssh://[email protected]/ungoogled-chromium-bin.git aur-upstream
source packaging/PKGBUILD
CHECKSUM=($(sha256sum ungoogled-chromium-$pkgver-$pkgrel-x86_64.pkg.tar.zst | head -c 64))
sed -i "s/--pkgver--/$pkgver/g" packaging/aur/PKGBUILD
sed -i "s/--pkgrel--/$pkgrel/g" packaging/aur/PKGBUILD
sed -i "s/--checksum--/$CHECKSUM/g" packaging/aur/PKGBUILD
mv packaging/aur/PKGBUILD aur-upstream/PKGBUILD
cd aur-upstream
# To avoid conflicts with other steps in this job, makepkg for generating .SRCINFO is the only command running in an arch environment
docker run --mount type=bind,source=$(pwd)/PKGBUILD,target=/home/build/PKGBUILD --entrypoint sh archlinux -c "pacman -Syu --needed --noconfirm binutils && useradd -m build && chown -R build /home/build && su build -c 'cd && makepkg --printsrcinfo > .SRCINFO'"
docker cp $(docker container ls --latest --format '{{.ID}}'):/home/build/.SRCINFO .
git config user.name "$GIT_NAME"
git config user.email "$GIT_EMAIL"
git add PKGBUILD .SRCINFO
git commit PKGBUILD .SRCINFO -m "Upgrade to $pkgver-$pkgrel"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }}
SSH_KEY_ALGORITHM: ${{ secrets.SSH_KEY_ALGORITHM }}
GIT_NAME: ${{ secrets.GIT_NAME }}
GIT_EMAIL: ${{ secrets.GIT_EMAIL }}
CHECKSUM: ${{ steps.aur-archive.outputs.checksum }}