-
Notifications
You must be signed in to change notification settings - Fork 35
176 lines (174 loc) · 9.07 KB
/
chromium-build.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
name: Build VisibleV8
on:
push:
branches:
- 'master'
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
build_vv8:
runs-on: [self-hosted, vv8-builder]
timeout-minutes: 2880
# Lets give ourselves 2 day to build VisibleV8 (github by default gives 6 hrs which is not enough time to build Chrome three times unless we use Google magic)
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract short SHA
id: short_sha
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- uses: actions/github-script@v7
id: get_release
with:
script: |
const release = await github.rest.repos.getLatestRelease({
owner: 'wspr-ncsu',
repo: 'visiblev8'
});
const tag = release.data.tag_name;
const currentGitCommit = '${{ steps.short_sha.outputs.sha_short }}'
const [_, commit, fullVersion, majorVersion] = tag.match(/visiblev8_([0-9a-f]+)-(([0-9]+)\.[0-9.]+)/);
const chromeReleaseVersion = (await (await fetch('https://chromiumdash.appspot.com/fetch_releases?channel=Stable&platform=Linux&num=1&offset=0')).json())[0]['version'];
const chromeMajorVersion = chromeReleaseVersion.split('.')[0];
console.log(`tag: ${tag}`);
console.log(`commit: ${commit}`);
console.log(`oldVersion: ${fullVersion}`);
console.log(`majorVersion: ${chromeMajorVersion}`);
console.log(`currentGitCommit: ${currentGitCommit}`);
console.log(`chromeReleaseVersion: ${chromeReleaseVersion}`);
core.setOutput('tag', tag);
core.setOutput('commit', commit);
core.setOutput('fullVersion', fullVersion);
core.setOutput('majorVersion', majorVersion);
core.setOutput('chromeReleaseVersion', chromeReleaseVersion);
core.setOutput('currentGitCommit', currentGitCommit);
core.setOutput('chromeMajorVersion', chromeMajorVersion);
- name: Diff our changes
id: diff
uses: actions/github-script@v7
env:
oldCommit: ${{ steps.get_release.outputs.commit }}
currentCommit: ${{ steps.get_release.outputs.currentGitCommit }}
with:
script: |
let output = '';
const options = {};
options.listeners = {
stdout: (data) => {
output += data.toString();
}
};
await exec.exec( 'git', [ '--no-pager', 'diff', process.env.oldCommit + '..' + process.env.currentCommit, 'patches', 'builder', '.github' ], options );
core.setOutput('diff', output[0] || 'empty');
# Hack: We send the first letter or the string 'empty' since Github runners hang if we send over the entire diff
- name: Should we publish ?
id: shouldPublish
uses: actions/github-script@v7
env:
GIT_DIFF: ${{ steps.diff.outputs.diff }}
with:
script: |
const shouldPublish = '${{ steps.get_release.outputs.chromeReleaseVersion }}' != '${{ steps.get_release.outputs.fullVersion }}' || ( '${{ steps.get_release.outputs.currentGitCommit }}' != '${{ steps.get_release.outputs.commit }}' && process.env.GIT_DIFF != 'empty' );
console.log(`shouldPublish: ${shouldPublish}`);
core.setOutput('shouldPublish', shouldPublish);
- name: Build VisibleV8
if: steps.shouldPublish.outputs.shouldPublish == 'true'
env:
VERSION: ${{ steps.get_release.outputs.chromeReleaseVersion }}
run: |
cd builder && make build VERSION=$VERSION DEBUG=0 PUBLISH_ASSETS=0 TESTS=1 ANDROID=1 ARM=1
- name: Get VV8 artifact name
if: steps.shouldPublish.outputs.shouldPublish == 'true'
id: artifact_name
run: |
PACKAGE_NAME_AMD64=`find ./builder/artifacts -name '*amd64.deb' -printf "%f\n" | sort -V | tail -n 1`
PACKAGE_NAME_ARM64=`find ./builder/artifacts -name '*arm64.deb' -printf "%f\n" | sort -V | tail -n 1`
echo "artifact_name_amd64=$PACKAGE_NAME_AMD64" >> $GITHUB_OUTPUT
echo "artifact_name_arm64=$PACKAGE_NAME_ARM64" >> $GITHUB_OUTPUT
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: visiblev8
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
if: steps.shouldPublish.outputs.shouldPublish == 'true'
uses: docker/metadata-action@v5
with:
images: visiblev8/vv8-base
tags: |
type=raw,value=latest,enable=true
type=raw,value=${{ steps.short_sha.outputs.sha_short }}_${{ steps.get_release.outputs.chromeReleaseVersion }},enable=true
- name: Build and push Docker image
uses: docker/build-push-action@v5
if: steps.shouldPublish.outputs.shouldPublish == 'true'
with:
context: ./builder/
build-args: |
VERSION=${{ steps.get_release.outputs.chromeReleaseVersion }}
ARTIFACT_DIR=./artifacts
PACKAGE_NAME_AMD64=${{ steps.artifact_name.outputs.artifact_name_amd64 }}
PACKAGE_NAME_ARM64=${{ steps.artifact_name.outputs.artifact_name_arm64 }}
platforms: linux/amd64,linux/arm64
file: ./builder/vv82dockerhub.dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Prepare artifacts for upload
if: steps.shouldPublish.outputs.shouldPublish == 'true'
id: artifact
env:
VERSION: ${{ steps.get_release.outputs.chromeReleaseVersion }}
GIT_COMMIT: ${{ steps.short_sha.outputs.sha_short }}
run: |
ARTIFACT_FILE=../visiblev8_$GIT_COMMIT-$VERSION.tar.gz
ARTIFACT_NAME=visiblev8_$GIT_COMMIT-$VERSION.tar.gz
cd builder/artifacts && tar -czvf $ARTIFACT_FILE $VERSION/*.deb $VERSION/*.pickle $VERSION/*.json $VERSION/*.apk
echo "artifact_file=$ARTIFACT_FILE" >> $GITHUB_OUTPUT
echo "artifact_name=$ARTIFACT_NAME" >> $GITHUB_OUTPUT
- name: Create a release
if: steps.shouldPublish.outputs.shouldPublish == 'true'
id: create_release
uses: actions/github-script@v7
with:
script: |
const name = 'visiblev8_${{ steps.get_release.outputs.currentGitCommit }}-${{ steps.get_release.outputs.chromeReleaseVersion }}';
const release = await github.rest.repos.createRelease({
owner: 'wspr-ncsu',
repo: 'visiblev8',
tag_name: name,
name: name,
body: 'This is the release for VisibleV8 commit ${{ steps.get_release.outputs.currentGitCommit }} based on Chromium ${{ steps.get_release.outputs.chromeReleaseVersion }} (major version ${{ steps.get_release.outputs.chromeMajorVersion }}).',
draft: false,
prerelease: false
});
console.log(release);
core.setOutput('releaseUploadURL', release.data.upload_url);
core.setOutput('release_id', release.data.id);
- name: Upload artifacts
if: steps.shouldPublish.outputs.shouldPublish == 'true'
run: |
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/gzip" \
--data-binary @./builder/artifacts/${{ steps.artifact.outputs.artifact_file }} \
"${{ steps.create_release.outputs.releaseUploadURL }}=${{ steps.artifact.outputs.artifact_name }}&label=${{ steps.artifact.outputs.artifact_name }}"
rm -rf ./builder/artifacts/${{ steps.artifact.outputs.artifact_name }}
- name: Notify slack that the build succeeded
if: steps.shouldPublish.outputs.shouldPublish == 'true' && success()
run: |
curl -X POST -H 'Content-type: application/json' --data '{"text":"VisibleV8 build '${{ steps.get_release.outputs.currentGitCommit }}' for Chromium version '${{ steps.get_release.outputs.chromeReleaseVersion }}' has been successful!"}' ${{ secrets.SLACK_WEBHOOK }}
- name: Cleaning up docker environment
if: steps.shouldPublish.outputs.shouldPublish == 'true' && ( success() || failure() )
run: |
docker system prune -f
- name: Cleaning built data
if: steps.shouldPublish.outputs.shouldPublish == 'true' && ( success() || failure() )
run: |
rm -rf ./builder/visiblev8_*-*.tar.gz
- name: Clean up everything
if: steps.shouldPublish.outputs.shouldPublish == 'true' && always()
uses: docker://ubuntu:latest
with:
entrypoint: /usr/bin/rm
args: -rf ./builder/artifacts ./builder/build