ci: create release workflow #1
Workflow file for this run
This file contains hidden or 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
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Release tag (e.g. v0.1.0-alpha.1)" | |
| required: true | |
| type: string | |
| prerelease: | |
| description: "Mark as GitHub pre-release" | |
| required: true | |
| default: true | |
| type: boolean | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-sequencer: | |
| name: Build sequencer (${{ matrix.arch }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - arch: amd64 | |
| target: x86_64-unknown-linux-gnu | |
| - arch: arm64 | |
| target: aarch64-unknown-linux-gnu | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| ca-certificates \ | |
| lua5.4 \ | |
| liblua5.4-dev \ | |
| libslirp-dev \ | |
| build-essential \ | |
| pkg-config \ | |
| libssl-dev | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Cache Rust artifacts | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Install cross | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cross | |
| - name: Build (release) | |
| run: cross build -p sequencer --release --locked --target ${{ matrix.target }} | |
| - name: Package | |
| env: | |
| TAG: ${{ inputs.tag }} | |
| ARCH: ${{ matrix.arch }} | |
| TARGET: ${{ matrix.target }} | |
| run: | | |
| set -euo pipefail | |
| mkdir -p dist | |
| mkdir -p "package/sequencer-${TAG}-linux-${ARCH}" | |
| cp "target/${TARGET}/release/sequencer" "package/sequencer-${TAG}-linux-${ARCH}/sequencer" | |
| cat > "package/sequencer-${TAG}-linux-${ARCH}/RUNNING.md" <<'EOF' | |
| ## Running | |
| Required environment variables: | |
| - `SEQ_ETH_RPC_URL` | |
| - `SEQ_DOMAIN_CHAIN_ID` | |
| - `SEQ_DOMAIN_VERIFYING_CONTRACT` | |
| Example: | |
| ```bash | |
| SEQ_ETH_RPC_URL=http://127.0.0.1:8545 \ | |
| SEQ_DOMAIN_CHAIN_ID=31337 \ | |
| SEQ_DOMAIN_VERIFYING_CONTRACT=0x1111111111111111111111111111111111111111 \ | |
| ./sequencer | |
| ``` | |
| EOF | |
| tar -C package -czf "dist/sequencer-${TAG}-linux-${ARCH}.tar.gz" "sequencer-${TAG}-linux-${ARCH}" | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: sequencer-linux-${{ matrix.arch }} | |
| path: dist/sequencer-*.tar.gz | |
| build-canonical-machine-image: | |
| name: Build canonical machine image | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| ca-certificates \ | |
| wget \ | |
| xgenext2fs | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Rust artifacts | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Install just | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: just | |
| - name: Install cartesi-machine | |
| run: | | |
| set -euo pipefail | |
| cargo install --locked \ | |
| --git https://github.com/cartesi/dave \ | |
| --rev 5d0560a04f623318af9ef5b7f193170b618b6ced \ | |
| cartesi-machine | |
| - name: Build machine image | |
| run: just canonical-build-machine-image | |
| - name: Package machine image store | |
| env: | |
| TAG: ${{ inputs.tag }} | |
| run: | | |
| set -euo pipefail | |
| test -d examples/canonical-app/out/canonical-machine-image | |
| mkdir -p dist | |
| tar -C examples/canonical-app/out -czf "dist/canonical-machine-image-${TAG}.tar.gz" canonical-machine-image | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: canonical-machine-image | |
| path: dist/canonical-machine-image-*.tar.gz | |
| publish: | |
| name: Publish GitHub Release | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build-sequencer | |
| - build-canonical-machine-image | |
| steps: | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| - name: Flatten artifacts | |
| run: | | |
| set -euo pipefail | |
| mkdir -p out | |
| find dist -type f -name '*.tar.gz' -exec cp -v '{}' out/ \; | |
| - name: Generate checksums | |
| working-directory: out | |
| run: | | |
| set -euo pipefail | |
| sha256sum *.tar.gz > SHA256SUMS | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ inputs.tag }} | |
| prerelease: ${{ inputs.prerelease }} | |
| fail_on_unmatched_files: true | |
| files: | | |
| out/*.tar.gz | |
| out/SHA256SUMS | |