Fix Docker workflow triggers #136
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
tags: | |
- '*' | |
pull_request: | |
paths: | |
- ".github/workflows/build-wasm.yml" | |
name: Build&Publish WASM | |
concurrency: | |
group: '${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' | |
cancel-in-progress: true | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
build-runtime-wasms: | |
environment: production # It needs the production GCP credentials to upload WASM | |
# Benchmark (with cache hit) | |
# ubuntu-latest 50 min | |
# ubuntu-latest-4-cores 34 min | |
runs-on: ubuntu-latest-4-cores | |
strategy: | |
matrix: | |
target: [build-runtime] | |
package: [altair-runtime, centrifuge-runtime, development-runtime] | |
name: ${{ matrix.target }}-${{ matrix.package }} | |
steps: | |
# PREP | |
- name: Check out code | |
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab #3.5.2 | |
- name: Prep build on Ubuntu | |
uses: ./.github/actions/prep-ubuntu | |
# sccache does not work inside the srtool container | |
- uses: Swatinem/rust-cache@3cf7f8cc28d1b4e7d01e3783be10a97d55d483c8 # 2.7 | |
with: | |
prefix-key: build | |
shared-key: wasm | |
workspaces: | | |
. | |
./target/srtool | |
cache-directories: ./runtime | |
# BUILD | |
- name: Run srtool # https://docs.substrate.io/reference/command-line-tools/srtool/ | |
run: > | |
docker run --rm --user root --platform=linux/amd64 | |
-e PACKAGE=${{ matrix.package }} -v /home/runner/.cargo:/cargo-home | |
-v ${{ github.workspace }}:/build paritytech/srtool:1.73.0-0.12.0 | |
/srtool/build --app | |
# Alternative way of running SRTool that allows for "script-like" execution, | |
# extremely useful to debug: | |
# - name: Run Docker SRTool | |
# uses: addnab/docker-run-action@4f65fabd2431ebc8d299f8e5a018d79a769ae185 #v3 | |
# with: | |
# image: paritytech/srtool:${{ matrix.rust_version }} | |
# options: --user root -v /home/runner/.cargo:/cargo-home -v ${{ github.workspace }}:/build -e BUILD_OPTS=${{ env.BUILD_OPTS || ''}} -e PACKAGE=${{ matrix.package }} | |
# run: | | |
# echo "---- Env VARS ----" | |
# echo "BUILD_OPT=${BUILD_OPT}" | |
# echo "PACKAGE=${PACKAGE}" | |
# echo "---- List Cache Folder ----" | |
# ls -la /cargo-home/ | |
# du -sh /cargo-home/* | |
# echo "---- RUNNING BUILD ----" | |
# /srtool/build --save | |
- name: Upload srtool report | |
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 #v3.1.3 | |
with: | |
name: srtool-wasm-report.txt | |
path: ./${{ matrix.package }}-srtool-wasm-report.json | |
- id: 'auth' | |
if: github.event_name != 'pull_request' | |
uses: 'google-github-actions/auth@67e9c72af6e0492df856527b474995862b7b6591' # v2.0.0 | |
with: | |
workload_identity_provider: ${{ secrets.GWIP_ARTIFACTS }} | |
service_account: ${{ secrets.GSA_ARTIFACTS }} | |
- name: Setup - gcloud / gsutil | |
if: ${{ steps.auth.outcome == 'success' }} | |
uses: google-github-actions/setup-gcloud@e30db14379863a8c79331b04a9969f4c1e225e0b # v1.1.1 | |
- name: Publish artifacts to GCS | |
if: ${{ steps.auth.outcome == 'success' }} | |
shell: bash | |
run: | | |
runtime_name=$(echo "${{ matrix.package }}" | sed -e "s/-runtime$//" ) | |
filename=$(echo "${{ matrix.package }}" | sed -e 's/-/_/g' ) | |
gsutil cp \ | |
./runtime/${runtime_name}/target/srtool/release/wbuild/${{ matrix.package }}/${filename}.compact.compressed.wasm \ | |
gs://centrifuge-wasm-repo/${runtime_name}/${runtime_name}-$(git rev-parse --short HEAD).wasm |