|
| 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 | +env: |
| 9 | + TARGET_BRANCH: master |
| 10 | + COMMITTER_NAME: pull-soljson action |
| 11 | + COMMITTER_EMAIL: builds@ethereum.org |
| 12 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 13 | + |
| 14 | +jobs: |
| 15 | + build-emscripten-nightly: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + outputs: |
| 18 | + nightly-version: ${{ env.NIGHTLY_VERSION }} |
| 19 | + matching-nightlies-in-the-repo: ${{ env.MATCHING_NIGHTLIES_IN_THE_REPO }} |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v2 |
| 23 | + with: |
| 24 | + repository: 'ethereum/solidity' |
| 25 | + ref: 'develop' |
| 26 | + path: 'solidity/' |
| 27 | + |
| 28 | + - name: Clone solc-bin repository without checking out a working copy |
| 29 | + run: | |
| 30 | + git clone --no-checkout --branch "$TARGET_BRANCH" "https://github.com/${GITHUB_REPOSITORY}.git" solc-bin/ |
| 31 | +
|
| 32 | + # For some reason git stages all files for deletion when you use --no-checkout |
| 33 | + cd solc-bin/ |
| 34 | + git reset HEAD --quiet |
| 35 | +
|
| 36 | + - name: Check if there's already a nightly with the same date or commit ID |
| 37 | + run: | |
| 38 | + cd solidity/ |
| 39 | + solidity_version=$("scripts/get_version.sh") |
| 40 | + last_commit_timestamp=$(git log -1 --date=iso --format=%ad HEAD) |
| 41 | + last_commit_date=$(date --date="$last_commit_timestamp" --utc +%Y.%-m.%-d) |
| 42 | + last_commit_hash=$(git rev-parse --short=8 HEAD) |
| 43 | +
|
| 44 | + cd ../solc-bin/ |
| 45 | + matching_nightlies_in_the_repo="$( |
| 46 | + git ls-files "bin/soljson-v${solidity_version}-nightly.${last_commit_date}+commit.*.js"; |
| 47 | + git ls-files "bin/soljson-v${solidity_version}-nightly.*+commit.${last_commit_hash}.js" |
| 48 | + )" |
| 49 | + nightly_version="v${solidity_version}-nightly.${last_commit_date}+commit.${last_commit_hash}" |
| 50 | +
|
| 51 | + echo "::set-env name=NIGHTLY_VERSION::${nightly_version}" |
| 52 | + echo "::set-env name=MATCHING_NIGHTLIES_IN_THE_REPO::${matching_nightlies_in_the_repo}" |
| 53 | +
|
| 54 | + - name: Build soljson.js |
| 55 | + if: "!env.MATCHING_NIGHTLIES_IN_THE_REPO" |
| 56 | + run: | |
| 57 | + cd solidity/ |
| 58 | + # Note that this script will spawn and build inside a docker image (which works just fine in github actions). |
| 59 | + scripts/build_emscripten.sh |
| 60 | +
|
| 61 | + - name: Upload soljson.js as an artifact |
| 62 | + if: "!env.MATCHING_NIGHTLIES_IN_THE_REPO" |
| 63 | + uses: actions/upload-artifact@v2 |
| 64 | + with: |
| 65 | + name: soljson.js |
| 66 | + path: solidity/upload/soljson.js |
| 67 | + |
| 68 | + add-nightly-and-push: |
| 69 | + runs-on: ubuntu-latest |
| 70 | + needs: build-emscripten-nightly |
| 71 | + |
| 72 | + env: |
| 73 | + NIGHTLY_VERSION: ${{ needs.build-emscripten-nightly.outputs.nightly-version }} |
| 74 | + |
| 75 | + if: "!needs.build-emscripten-nightly.outputs.matching-nightlies-in-the-repo" |
| 76 | + steps: |
| 77 | + - uses: actions/checkout@v2 |
| 78 | + with: |
| 79 | + ref: ${{ env.TARGET_BRANCH }} |
| 80 | + path: 'solc-bin' |
| 81 | + |
| 82 | + - name: Download soljson.js artifact |
| 83 | + uses: actions/download-artifact@v2 |
| 84 | + with: |
| 85 | + name: soljson.js |
| 86 | + |
| 87 | + - name: Set committer name and e-mail |
| 88 | + run: | |
| 89 | + cd solc-bin/ |
| 90 | + git config --local user.name "$COMMITTER_NAME" |
| 91 | + git config --local user.email "$COMMITTER_EMAIL" |
| 92 | +
|
| 93 | + - name: Run add-nightly-and-push.sh |
| 94 | + run: | |
| 95 | + cd solc-bin/ |
| 96 | + ./add-nightly-and-push.sh ../soljson.js "$NIGHTLY_VERSION" |
0 commit comments