Skip to content

Commit

Permalink
[WIP] Github action for emscripten nightly builds
Browse files Browse the repository at this point in the history
  • Loading branch information
cameel committed Jul 3, 2020
1 parent 3ecf8b6 commit 7c802cd
Showing 1 changed file with 118 additions and 0 deletions.
118 changes: 118 additions & 0 deletions .github/workflows/pull-soljson.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Emscripten nightly build + solc-bin push

on:
schedule:
# Run once a day, at midnight
- cron: '0 0 * * *'

jobs:
build-emscripten:
runs-on: ubuntu-latest
outputs:
nightly-version: ${{ env.NIGHTLY_VERSION }}

steps:
- uses: actions/checkout@v2
with:
repository: 'ethereum/solidity'
ref: 'develop'

- name: Build soljson.js
run: |
# Note that this script will spawn and build inside a docker image (which works just fine in github actions).
scripts/build_emscripten.sh
- name: Get nightly version
id: nightly-version
run: |
last_commit_timestamp=$(git log -1 --date=iso --format=%ad HEAD)
last_commit_date=$(date --date="$last_commit_timestamp" --utc +%Y.%-m.%-d)
last_commit_hash=$(git rev-parse --short=8 HEAD)
solidity_version=$(scripts/get_version.sh)
nightly_version="v${solidity_version}-nightly.${last_commit_date}+commit.${last_commit_hash}"
echo "::set-env name=NIGHTLY_VERSION::${nightly_version}"
- name: Upload soljson.js as an artifact
uses: actions/upload-artifact@v2
with:
name: soljson.js
path: upload/soljson.js

commit-soljson:
runs-on: ubuntu-latest
needs: build-emscripten

env:
COMMITTER_NAME: emscripten nightly action
# TODO: Set a proper e-mail address
COMMITTER_EMAIL: solidity@example.com
TARGET_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NIGHTLY_VERSION: ${{ needs.build-emscripten.outputs.nightly-version }}

steps:
- uses: actions/checkout@v2

- name: Make sure that the working copy is clean
run: |
echo "::debug::$(git status)"
test -z "$(git status --porcelain)" && exit 1
- name: Check if the nightly already exists
run: |
version_already_exists=$(git ls-files "bin/soljson-$NIGHTLY_VERSION.js" | sed q1 || echo true && true)
echo "::set-env name=VERSION_ALREADY_EXISTS::${version_already_exists}"
- name: Download soljson.js artifact
uses: actions/download-artifact@v2
if: "!env.VERSION_ALREADY_EXISTS"
with:
name: soljson.js
path: bin/

- name: Move soljson.js to the target location and stage it for commit
if: "!env.VERSION_ALREADY_EXISTS"
run: |
mv bin/soljson.js bin/soljson-${{ env.NIGHTLY_VERSION }}.js
# Staging before running the update script to detect any possible damage caused by it
git add "bin/soljson-$NIGHTLY_VERSION.js"
- name: Install dependencies of the update script using npm
if: "!env.VERSION_ALREADY_EXISTS"
run: |
npm config set package-lock false
npm install
- name: Run the script that updates the file lists
if: "!env.VERSION_ALREADY_EXISTS"
run: |
npm run update
- name: Commit the nightly binary and updated lists
if: "!env.VERSION_ALREADY_EXISTS"
run: |
git add bin/soljson-nightly.js
git add bin/list.json
git add bin/list.js
git add bin/list.txt
git config --local user.name "$COMMITTER_NAME"
git config --local user.email "$COMMITTER_EMAIL"
git commit -m "Nightly build ${NIGHTLY_VERSION}"
- name: Remove untracked files
if: "!env.VERSION_ALREADY_EXISTS"
run: |
rm -r node_modules/
- name: Make sure that no other files were modified
run: |
echo "::debug::$(git status)"
test -z "$(git status --porcelain)" && exit 1
- name: Push the commit
if: "!env.VERSION_ALREADY_EXISTS"
run: |
git push origin "$TARGET_BRANCH"

0 comments on commit 7c802cd

Please sign in to comment.