forked from bromite/bromite
-
Notifications
You must be signed in to change notification settings - Fork 84
223 lines (195 loc) · 8.79 KB
/
build-images.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
permissions:
actions: none
checks: none
contents: none
deployments: none
issues: write
packages: none
pull-requests: none
repository-projects: none
security-events: none
statuses: none
on:
workflow_dispatch:
inputs:
version:
description: 'chromium version'
required: false
default: ''
type:
description: 'runner?'
required: false
default: 'ubuntu-latest'
schedule:
- cron: '0 1 * * *'
env:
CHR_VERSION: ${{ github.event.inputs.version }}
NEW_VERSION: ${{ null }}
name: Builds and pushes tagged image to DockerHub
jobs:
generate_build_deps:
name: Generate Build Deps
runs-on: ${{ fromJSON( format('["ubuntu-latest", "{0}"]', github.event.inputs.type) )[github.event.inputs.type != ''] }}
steps:
- name: Reclaiming disk space on / by removing dotnet/android/ghc
#if: ${{ github.event.inputs.type == '' }}
run: |
df -h
DIR=/usr/share/dotnet && sudo rm -rf $DIR
DIR=/usr/local/lib/android && sudo rm -rf $DIR
DIR=/opt/ghc && sudo rm -rf $DIR
DIR=/opt/hostedtoolcache/CodeQL && sudo rm -rf $DIR
DIR=/usr/local/.ghcup && sudo rm -rf $DIR
DIR=/usr/lib/jvm && test -d $DIR && sudo rm -rf $DIR
DIR=/usr/local/julia1.10.5 && test -d $DIR && sudo rm -rf $DIR
DIR=/usr/local/x86_64-linux-gnu && test -d $DIR && sudo rm -rf $DIR
DIR=/usr/local/gcc && test -d $DIR && sudo rm -rf $DIR
DIR=/usr/local/llvm-15 && test -d $DIR && sudo rm -rf $DIR
DIR=/usr/local/llvm-14 && test -d $DIR && sudo rm -rf $DIR
DIR=/usr/local/llvm-13 && test -d $DIR && sudo rm -rf $DIR
DIR=/usr/local/heroku && test -d $DIR && sudo rm -rf $DIR
DIR=/usr/share/swift && test -d $DIR && sudo rm -rf $DIR
DIR=/usr/share/miniconda && test -d $DIR && sudo rm -rf $DIR
DIR=/usr/share/az_12.1.0 && test -d $DIR && sudo rm -rf $DIR
DIR=/usr/local/share/powershell && test -d $DIR && sudo rm -rf $DIR
DIR=/usr/local/share/chromium && test -d $DIR && sudo rm -rf $DIR
DIR=/usr/lib/gcc && test -d $DIR && sudo rm -rf $DIR
DIR=/usr/lib/llvm-15 && test -d $DIR && sudo rm -rf $DIR
DIR=/usr/lib/llvm-14 && test -d $DIR && sudo rm -rf $DIR
DIR=/usr/lib/llvm-13 && test -d $DIR && sudo rm -rf $DIR
sudo apt-get remove google-cloud-cli azure-cli google-chrome-stable \
firefox mysql-server-core-8.0 mono-devel podman \
powershell || true
sudo apt-get autoremove
df -h
- name: Enable proxy on container
shell: bash
if: ${{ github.event.inputs.type != '' && github.event.inputs.type != 'ubuntu-latest' }}
run: |
if ! [[ -z "${HTTP_PROXY}" ]]; then
PROXY_ADDR=http://$(hostname -I | cut -d' ' -f1 | xargs):8118
echo "PROXY_ADDR=$PROXY_ADDR" >> $GITHUB_ENV
sudo iptables -D INPUT -p tcp -s localhost --dport 8118 -j ACCEPT
sudo iptables -D INPUT -p tcp --dport 8118 -j DROP
fi
- name: Checkout repo
uses: actions/checkout@v2
with:
path: cromite
fetch-depth: 1
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Check versions
shell: bash
run: |
if [ -z $CHR_VERSION ]; then
LATEST_WIN=$(curl -s 'https://versionhistory.googleapis.com/v1/chrome/platforms/win64/channels/stable/versions/all/releases' | jq -rc '.releases[].version' | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | tail -n 1)
LATEST_ANDROID=$(curl -s 'https://versionhistory.googleapis.com/v1/chrome/platforms/android/channels/stable/versions/all/releases' | jq -rc '.releases[].version' | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | tail -n 1)
CHR_VERSION=$(echo -e "$LATEST_ANDROID\n$LATEST_WIN" | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | tail -n 1)
echo "LATEST_WIN=$LATEST_WIN" >> $GITHUB_ENV
echo "LATEST_ANDROID=$LATEST_ANDROID" >> $GITHUB_ENV
echo "CHR_VERSION=$CHR_VERSION" >> $GITHUB_ENV
fi
- name: Building build-deps container ${{ env.VERSION }}
shell: bash
run: |
IS_PRESENT=$(docker inspect --type=image uazo/build-deps:$CHR_VERSION > /dev/null ; echo $?)
if [ $IS_PRESENT -ne "0" ]; then
IS_PRESENT=$(docker manifest inspect uazo/build-deps:$CHR_VERSION > /dev/null ; echo $?)
if [ $IS_PRESENT -ne "0" ]; then
DOCKER_BUILDKIT=1 docker build -t uazo/build-deps:$CHR_VERSION \
--progress plain \
--build-arg VERSION=$CHR_VERSION \
--build-arg HTTP_PROXY="$PROXY_ADDR" \
--no-cache \
cromite/tools/images/build-deps/.
docker push uazo/build-deps:$CHR_VERSION
echo "NEW_VERSION=$CHR_VERSION" >> $GITHUB_ENV
fi
fi
- name: Building chromium container ${{ env.VERSION }}
shell: bash
run: |
IS_PRESENT=$(docker inspect --type=image uazo/chromium:$CHR_VERSION > /dev/null ; echo $?)
if [ $IS_PRESENT -ne "0" ]; then
IS_PRESENT=$(docker manifest inspect uazo/chromium:$CHR_VERSION > /dev/null ; echo $?)
if [ $IS_PRESENT -ne "0" ]; then
DOCKER_BUILDKIT=1 docker build -t uazo/chromium:$CHR_VERSION \
--progress plain \
--build-arg VERSION=$CHR_VERSION \
--build-arg HTTP_PROXY="$PROXY_ADDR" \
cromite/tools/images/chr-source/.
docker push uazo/chromium:$CHR_VERSION
echo "NEW_VERSION=$CHR_VERSION" >> $GITHUB_ENV
fi
fi
- name: Update files under control
shell: bash
run: |
cd cromite
RELEASE=$(cat build/RELEASE | xargs)
cd tools/under-control
DO_UPDATE=0
if [ -n "$NEW_VERSION" ]; then
if [ "$RELEASE" != "$NEW_VERSION" ]; then
DO_UPDATE=1
fi
elif [ "$RELEASE" != "$(cat src/RELEASE | xargs)" ]; then
DO_UPDATE=1
NEW_VERSION=$RELEASE
fi
if [[ DO_UPDATE -eq 1 ]]; then
echo "Found new version $NEW_VERSION"
echo "Under control: $(cat src/RELEASE | xargs)"
echo "Current: $RELEASE"
test -d src && rm -rf src
docker build --progress=plain --build-arg "TAG=$NEW_VERSION" -o . .
echo $NEW_VERSION >src/RELEASE
fi
CHANGES=0 && git diff --quiet || CHANGES=1
echo "CHANGES=$CHANGES" >> $GITHUB_ENV
if [[ CHANGES -eq 1 ]]; then
git add src
git diff --name-only --staged
fi
- name: Create Pull Request
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c #v6.1.0
if: env.CHANGES == '1'
with:
token: ${{ secrets.CROMITE_PULLS }}
path: cromite
add-paths: |
tools/under-control/*
commit-message: '[AUTO][FILECONTROL] - version ${{ env.NEW_VERSION }}'
title: '[AUTO][FILECONTROL] - version ${{ env.NEW_VERSION }}'
body: ${{ env.MESSAGE }}
delete-branch: true
branch-suffix: short-commit-hash
- name: Create issue ${{ env.VERSION }}
if: "${{ env.NEW_VERSION != '' }}"
shell: bash
run: |
GH=../../gh_2.18.1_linux_amd64/bin/gh
wget https://github.com/cli/cli/releases/download/v2.18.1/gh_2.18.1_linux_amd64.tar.gz
tar xfz gh_2.18.1_linux_amd64.tar.gz
cd cromite/tools
echo ${{ secrets.GITHUB_TOKEN }} | $GH auth login --with-token
echo Custom Release $CHR_VERSION >body.txt
if [[ "$LATEST_WIN" == "$CHR_VERSION" ]]; then
echo Using Windows Release >body.txt
echo "\`\`\`" >>body.txt
curl -s 'https://chromiumdash.appspot.com/fetch_releases?channel=Stable&platform=Windows&num=10&offset=0' | \
jq --arg LATEST "$LATEST_WIN" '.[] | select( .version == $LATEST )' >>body.txt
echo "\`\`\`" >>body.txt
fi
if [[ "$LATEST_ANDROID" == "$CHR_VERSION" ]]; then
echo Using Android Release >body.txt
echo "\`\`\`" >>body.txt
curl -s 'https://chromiumdash.appspot.com/fetch_releases?channel=Stable&platform=Android&num=10&offset=0' | \
jq --arg LATEST "$LATEST_ANDROID" '.[] | select( .version == $LATEST )' >>body.txt
echo "\`\`\`" >>body.txt
fi
$GH issue create -t "$CHR_VERSION: new chromium version" -F body.txt