Skip to content

Commit 4810994

Browse files
committed
[WIP] Github action for emscripten nightly builds
1 parent d3b4c02 commit 4810994

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed
+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Emscripten nightly build + solc-bin push
2+
3+
on:
4+
schedule:
5+
# Run once a day, at midnight
6+
- cron: '0 0 * * *'
7+
8+
jobs:
9+
build-emscripten:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
nightly-version: ${{ env.NIGHTLY_VERSION }}
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
with:
17+
repository: 'ethereum/solidity'
18+
ref: 'develop'
19+
20+
- name: Build soljson.js
21+
run: |
22+
# Note that this script will spawn and build inside a docker image (which works just fine in github actions).
23+
scripts/build_emscripten.sh
24+
25+
- name: Get nightly version
26+
id: nightly-version
27+
run: |
28+
last_commit_timestamp=$(git log -1 --date=iso --format=%ad HEAD)
29+
last_commit_date=$(date --date="$last_commit_timestamp" --utc +%Y.%-m.%-d)
30+
last_commit_hash=$(git rev-parse --short=8 HEAD)
31+
solidity_version=$(scripts/get_version.sh)
32+
nightly_version="v${solidity_version}-nightly.${last_commit_date}+commit.${last_commit_hash}"
33+
34+
echo "::set-env name=NIGHTLY_VERSION::${nightly_version}"
35+
36+
- name: Upload soljson.js as an artifact
37+
uses: actions/upload-artifact@v2
38+
with:
39+
name: soljson.js
40+
path: upload/soljson.js
41+
42+
commit-soljson:
43+
runs-on: ubuntu-latest
44+
needs: build-emscripten
45+
46+
env:
47+
COMMITTER_NAME: emscripten nightly action
48+
# TODO: Set a proper e-mail address
49+
COMMITTER_EMAIL: solidity@example.com
50+
TARGET_BRANCH: master
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
NIGHTLY_VERSION: ${{ needs.build-emscripten.outputs.nightly-version }}
53+
54+
steps:
55+
- uses: actions/checkout@v2
56+
with:
57+
ref: ${{ env.TARGET_BRANCH }}
58+
59+
- name: Make sure that the working copy is clean
60+
run: |
61+
echo "::debug::$(git status)"
62+
test -z "$(git status --porcelain)" || exit 1
63+
64+
- name: Check if the nightly already exists
65+
run: |
66+
version_already_exists=$(git ls-files "bin/soljson-$NIGHTLY_VERSION.js" | sed q1 || echo true && true)
67+
echo "::set-env name=VERSION_ALREADY_EXISTS::${version_already_exists}"
68+
69+
- name: Download soljson.js artifact
70+
uses: actions/download-artifact@v2
71+
if: "!env.VERSION_ALREADY_EXISTS"
72+
with:
73+
name: soljson.js
74+
path: bin/
75+
76+
- name: Move soljson.js to the target location and stage it for commit
77+
if: "!env.VERSION_ALREADY_EXISTS"
78+
run: |
79+
mv bin/soljson.js bin/soljson-${{ env.NIGHTLY_VERSION }}.js
80+
81+
# Staging before running the update script to detect any possible damage caused by it
82+
git add "bin/soljson-$NIGHTLY_VERSION.js"
83+
84+
- name: Install dependencies of the update script using npm
85+
if: "!env.VERSION_ALREADY_EXISTS"
86+
run: |
87+
npm config set package-lock false
88+
npm install
89+
90+
- name: Run the script that updates the file lists
91+
if: "!env.VERSION_ALREADY_EXISTS"
92+
run: |
93+
npm run update
94+
95+
- name: Commit the nightly binary and updated lists
96+
if: "!env.VERSION_ALREADY_EXISTS"
97+
run: |
98+
git add bin/soljson-nightly.js
99+
git add bin/list.json
100+
git add bin/list.js
101+
git add bin/list.txt
102+
103+
git config --local user.name "$COMMITTER_NAME"
104+
git config --local user.email "$COMMITTER_EMAIL"
105+
git commit -m "Nightly build ${NIGHTLY_VERSION}"
106+
107+
- name: Remove untracked files
108+
if: "!env.VERSION_ALREADY_EXISTS"
109+
run: |
110+
rm -r node_modules/
111+
112+
- name: Make sure that no other files were modified
113+
run: |
114+
echo "::debug::$(git status)"
115+
test -z "$(git status --porcelain)" || exit 1
116+
117+
- name: Push the commit
118+
if: "!env.VERSION_ALREADY_EXISTS"
119+
run: |
120+
git push origin "$TARGET_BRANCH"

0 commit comments

Comments
 (0)