diff --git a/.github/scripts/generate-release-body.ts b/.github/scripts/generate-release-body.ts index 6bab42c93b..2006adaff2 100644 --- a/.github/scripts/generate-release-body.ts +++ b/.github/scripts/generate-release-body.ts @@ -253,8 +253,13 @@ async function main() { describe: "Repository name (Ex: Astar)", required: true, }, + type: { + type: "string", + describe: "Type of release - runtime or client", + choices: ["runtime", "client"], + required: true, + } }) - .demandOption(["from", "to"]) .help().argv; const octokit = new Octokit({ @@ -264,10 +269,6 @@ async function main() { const previousTag = argv.from; const newTag = argv.to; - const runtimes = ["shibuya", "shiden", "astar"].map((runtimeName) => - getRuntimeInfo(argv["srtool-report-folder"], runtimeName) - ); - const moduleLinks = ["polkadot-sdk", "frontier"].map((repoName) => ({ name: repoName, link: getCompareLink(repoName, previousTag, newTag), @@ -297,65 +298,91 @@ async function main() { } }; - const template = ` -## Description -(Placeholder for release descriptions, please freely write explanations for this release here.) - -\*\*Upgrade priority: LOW/MID/HIGH/CRITICAL\*\* -> DELETE THIS -> CRITICAL - contains critical update for the client which should be rolled out ASAP -> HIGH - significant changes to client -> MEDIUM - some minor changes to the client -> LOW - no client changes - -${runtimes.length > 0 ? `## Runtimes -${runtimes - .map( - (runtime) => `### ${capitalize(runtime.name)} -\`\`\` -✨ spec_version: ${runtime.version} -🏋 Runtime Size: ${runtime.srtool.runtimes.compressed.size} -🗜 Compressed: ${runtime.srtool.runtimes.compressed.subwasm.compression.compressed ? "Yes" : "No"} -🎁 Metadata version: ${runtime.srtool.runtimes.compressed.subwasm.metadata_version} -🗳️ sha256: ${runtime.srtool.runtimes.compressed.sha256} -🗳️ blake2-256: ${runtime.srtool.runtimes.compressed.blake2_256} -🗳️ proposal (authorizeUpgrade): ${runtime.srtool.runtimes.compressed.subwasm.parachain_authorize_upgrade_hash} -📦 IPFS: ${runtime.srtool.runtimes.compressed.subwasm.ipfs_hash} -\`\`\` -`).join(`\n`)}` : ""} - -## Build Info -WASM runtime built using \`${runtimes[0]?.srtool.info.rustc}\` - -## Changes -### Client -${clientPRs.length > 0 ? ` -${clientPRs.map((pr) => `* ${printPr(pr)}`).join("\n")} -` : "None"} -### Runtime -${runtimePRs.length > 0 ? ` -${runtimePRs.map((pr) => `* ${printPr(pr)}`).join("\n")} -` : "None"} -### Others -${remainingPRs.length > 0 ? ` -${remainingPRs.map((pr) => `* ${printPr(pr)}`).join("\n")} -` : "None"} - -## Dependency Changes -Astar: https://github.com/${argv.owner}/${argv.repo}/compare/${previousTag}...${newTag} -${moduleLinks.map((modules) => `${capitalize(modules.name)}: ${modules.link}`).join("\n")} - -## Download Links -| Arch | Link | -| ----------- | ------- | -| \`MacOS x86_64\` | [Download](https://github.com/AstarNetwork/Astar/releases/download/${newTag}/astar-collator-${newTag}-macOS-x86_64.tar.gz) | -| \`Ubuntu x86_64\` | [Download](https://github.com/AstarNetwork/Astar/releases/download/${newTag}/astar-collator-${newTag}-ubuntu-x86_64.tar.gz) | -| \`Ubuntu aarch64\` | [Download](https://github.com/AstarNetwork/Astar/releases/download/${newTag}/astar-collator-${newTag}-ubuntu-aarch64.tar.gz) | - -[](https://hub.docker.com/r/staketechnologies/astar-collator/tags) -` - - console.log(template); + if (argv.type === "client") { + const template = ` + ## Description + (Placeholder for release descriptions, please freely write explanations for this release here.) + + \*\*Upgrade priority: LOW/MID/HIGH/CRITICAL\*\* + > DELETE THIS + > CRITICAL - contains critical update for the client which should be rolled out ASAP + > HIGH - significant changes to client + > MEDIUM - some minor changes to the client + > LOW - no client changes + + ## Changes + ### Client + ${clientPRs.length > 0 ? ` + ${clientPRs.map((pr) => `* ${printPr(pr)}`).join("\n")} + ` : "None"} + ### Runtime (impacts built-in runtimes) + ${runtimePRs.length > 0 ? ` + ${runtimePRs.map((pr) => `* ${printPr(pr)}`).join("\n")} + ` : "None"} + ### Others + ${remainingPRs.length > 0 ? ` + ${remainingPRs.map((pr) => `* ${printPr(pr)}`).join("\n")} + ` : "None"} + + ## Dependency Changes + Astar: https://github.com/${argv.owner}/${argv.repo}/compare/${previousTag}...${newTag} + ${moduleLinks.map((modules) => `${capitalize(modules.name)}: ${modules.link}`).join("\n")} + + ## Download Links + | Arch | Link | + | ----------- | ------- | + | \`MacOS x86_64\` | [Download](https://github.com/AstarNetwork/Astar/releases/download/${newTag}/astar-collator-${newTag}-macOS-x86_64.tar.gz) | + | \`Ubuntu x86_64\` | [Download](https://github.com/AstarNetwork/Astar/releases/download/${newTag}/astar-collator-${newTag}-ubuntu-x86_64.tar.gz) | + | \`Ubuntu aarch64\` | [Download](https://github.com/AstarNetwork/Astar/releases/download/${newTag}/astar-collator-${newTag}-ubuntu-aarch64.tar.gz) | + + [](https://hub.docker.com/r/staketechnologies/astar-collator/tags) + ` + console.log(template); + } else if (argv.type === "runtime") { + const runtimes = ["shibuya", "shiden", "astar"].map((runtimeName) => + getRuntimeInfo(argv["srtool-report-folder"], runtimeName) + ); + + const template = ` + ## Description + (Placeholder for release descriptions, please freely write explanations for this release here.) + + ${runtimes.length > 0 ? `## Runtimes + ${runtimes + .map( + (runtime) => `### ${capitalize(runtime.name)} + \`\`\` + ✨ spec_version: ${runtime.version} + 🏋 Runtime Size: ${runtime.srtool.runtimes.compressed.size} + 🗜 Compressed: ${runtime.srtool.runtimes.compressed.subwasm.compression.compressed ? "Yes" : "No"} + 🎁 Metadata version: ${runtime.srtool.runtimes.compressed.subwasm.metadata_version} + 🗳️ sha256: ${runtime.srtool.runtimes.compressed.sha256} + 🗳️ blake2-256: ${runtime.srtool.runtimes.compressed.blake2_256} + 📦 IPFS: ${runtime.srtool.runtimes.compressed.subwasm.ipfs_hash} + \`\`\` + `).join(`\n`)}` : ""} + + ## Build Info + WASM runtime built using \`${runtimes[0]?.srtool.info.rustc}\` + + ## Changes + ### Runtime + ${runtimePRs.length > 0 ? ` + ${runtimePRs.map((pr) => `* ${printPr(pr)}`).join("\n")} + ` : "None"} + ### Others + ${remainingPRs.length > 0 ? ` + ${remainingPRs.map((pr) => `* ${printPr(pr)}`).join("\n")} + ` : "None"} + + ## Dependency Changes + Astar: https://github.com/${argv.owner}/${argv.repo}/compare/${previousTag}...${newTag} + ${moduleLinks.map((modules) => `${capitalize(modules.name)}: ${modules.link}`).join("\n")} + ` + console.log(template); + } else { + console.log("Invalid type - should not happen."); + } } main(); diff --git a/.github/workflows/release-client.yml b/.github/workflows/release-client.yml new file mode 100644 index 0000000000..2bcf853ac3 --- /dev/null +++ b/.github/workflows/release-client.yml @@ -0,0 +1,327 @@ +name: Release Build +on: + push: + tags: + - v[0-9]+.[0-9]+.[0-9]+* + workflow_dispatch: +jobs: + checks-and-tests: + runs-on: [self-hosted, Linux, X64] + steps: + - name: Free disk space + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /usr/local/lib/android + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + df -h + + - name: Checkout the source code + uses: actions/checkout@v4 + with: + submodules: true + + - name: Install deps + run: sudo apt -y install protobuf-compiler + + - name: Install & display rust toolchain + run: rustup show + + - name: Check targets are installed correctly + run: rustup target list --installed + + - name: Install cargo-nextest + run: curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin + + - name: Check all features compilation + run: cargo check --features try-runtime,runtime-benchmarks --locked + + - name: Run all tests + run: make test-all + + native-linux: + needs: checks-and-tests + runs-on: [self-hosted, Linux, X64] + strategy: + matrix: + target: + - x86_64-unknown-linux-gnu + - aarch64-unknown-linux-gnu + + steps: + - name: Checkout the source code + uses: actions/checkout@v4 + with: + submodules: true + + - name: Install deps + run: sudo apt -y install protobuf-compiler + + - name: aarch64 setup + if: contains(matrix.target, 'aarch64') + shell: bash + run: | + sudo apt update + sudo apt install -y gcc-multilib g++-multilib + sudo apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu + + mkdir -p .cargo + touch .cargo/config + printf '[target.aarch64-unknown-linux-gnu]\nlinker = "aarch64-linux-gnu-gcc"' >> .cargo/config + + - name: x86_64 setup + if: contains(matrix.target, 'x86_64') + run: | + mkdir -p .cargo + touch .cargo/config + printf '[target.x86_64-unknown-linux-gnu]\nrustflags = ["-Clink-arg=-fuse-ld=lld"]' >> .cargo/config + + - name: Install & display rust toolchain + run: rustup show + + - name: Add aarch64 target + if: contains(matrix.target, 'aarch64') + run: rustup target add ${{ matrix.target }} + + - name: Check targets are installed correctly + run: rustup target list --installed + + - name: Build optimized binary + run: cargo build --profile production --target ${{ matrix.target }} --locked + + - name: Set artifact name + env: + TARGET: ${{ matrix.target }} + id: artifact-name + run: echo "::set-output name=name::astar-ubuntu-latest-${TARGET%%-*}" + + - uses: actions/upload-artifact@v3 + with: + name: ${{ steps.artifact-name.outputs.name }} + path: target/${{ matrix.target }}/production/astar-collator + + native-macos: + needs: checks-and-tests + runs-on: macos-latest + env: + RUSTC_WRAPPER: "sccache" + SCCACHE_BUCKET: ${{ secrets.SCCACHE_BUCKET }} + SCCACHE_REGION: ${{ secrets.SCCACHE_REGION }} + SCCACHE_S3_KEY_PREFIX: "astar-macos" + permissions: + id-token: write + contents: read + steps: + - name: Checkout the source code + uses: actions/checkout@v4 + with: + submodules: true + + - name: configure aws credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.SCCACHE_ROLE }} + role-session-name: github_astar_mac + aws-region: ${{ secrets.SCCACHE_REGION }} + + - name: Install deps + run: brew install protobuf sccache + + - name: Install & display rust toolchain + run: rustup show + + - name: Check targets are installed correctly + run: rustup target list --installed + + - name: Build optimized binary + run: cargo build --locked --profile production + + - name: Show sccache stats + run: sccache --show-stats + + - uses: actions/upload-artifact@v3 + with: + name: astar-macOS-latest-x86_64 + path: target/production/astar-collator + + docker: + needs: native-linux + runs-on: ubuntu-latest + steps: + - name: Checkout the source code + uses: actions/checkout@v4 + with: + submodules: true + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Docker meta + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v1 + with: + images: staketechnologies/astar-collator + tag-custom: shiden + tag-sha: true # add git short SHA as Docker tag + + - name: Download pre-built linux collator binary + uses: actions/download-artifact@v3 + with: + name: astar-ubuntu-latest-x86_64 + + - name: Make binary executable and copy it to docker folder + run: chmod +x astar-collator && cp astar-collator third-party/docker + + - name: Build & Push docker image + uses: docker/build-push-action@v2 + with: + context: third-party/docker + platforms: linux/amd64 + labels: ${{ steps.docker_meta.outputs.labels }} + tags: ${{ steps.docker_meta.outputs.tags }} + push: true + + publish-release-draft: + needs: [native-linux, native-macOS, docker] + runs-on: ubuntu-latest + outputs: + release_url: ${{ steps.create-release.outputs.html_url }} + upload_url: ${{ steps.create-release.outputs.upload_url }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Use Node.js 20.x + uses: actions/setup-node@v2 + with: + node-version: 20.x + + - name: Get the latest release + id: latest-release + uses: pozetroninc/github-action-get-latest-release@v0.5.0 + with: + repository: AstarNetwork/Astar + excludes: "prerelease, draft" + + - name: Generate Release Body + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + id: generate-release-body + run: | + cd .github/scripts + yarn + yarn -s run ts-node generate-release-body.ts generate \ + --owner "${{ github.repository_owner }}" \ + --repo "$(basename ${{ github.repository }})" \ + --from "${{ steps.latest-release.outputs.release }}" \ + --to "${{ github.ref_name }}" \ + --type client \ + > ../../body.md + + - name: Create Release Draft + id: create-release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref_name }} + release_name: ${{ github.ref_name }} + body_path: body.md + draft: true + + upload-binaries: + needs: publish-release-draft + runs-on: ubuntu-latest + strategy: + matrix: + os: ["ubuntu", "macOS"] + arch: ["x86_64", "aarch64"] + exclude: + - os: macOS + arch: aarch64 + steps: + - name: Create download folder + run: | + mkdir -p ${{ matrix.os }}-${{ matrix.arch }}-bin + + - name: Download pre-built collator binary + uses: actions/download-artifact@v3 + with: + name: astar-${{ matrix.os }}-latest-${{ matrix.arch }} + path: ${{ matrix.os }}-${{ matrix.arch }}-bin + + - name: Make binary executable and tar gzip + run: | + cd ${{ matrix.os }}-${{ matrix.arch }}-bin + chmod +x astar-collator + tar zcvf astar-collator.tar.gz astar-collator + + - name: Upload binary artifact + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.publish-release-draft.outputs.upload_url }} + asset_path: ${{ matrix.os }}-${{ matrix.arch }}-bin/astar-collator.tar.gz + asset_name: astar-collator-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.arch }}.tar.gz + asset_content_type: application/gzip + + chain-sync-smoke: + needs: native-linux + runs-on: ubuntu-latest + strategy: + matrix: + chain: ["astar", "shiden", "shibuya"] + + steps: + - name: Checkout the source code + uses: actions/checkout@v4 + + - name: Download pre-built collator binary + uses: actions/download-artifact@v3 + with: + name: astar-ubuntu-latest-x86_64 + path: target/release + + - name: Sync chain ${{ matrix.chain }} + run: | + chmod +x target/release/astar-collator + ./scripts/sync-smoke.sh ${{ matrix.chain }} + + zombienet-smoke: + needs: native-linux + runs-on: ubuntu-latest + strategy: + matrix: + chain: ["astar-dev", "shiden-dev", "shibuya-dev"] + + steps: + - name: Checkout the source code + uses: actions/checkout@v4 + + - name: Download pre-built collator binary + uses: actions/download-artifact@v3 + with: + name: astar-ubuntu-latest-x86_64 + path: third-party/zombienet + + - name: Setup + run: chmod +x third-party/zombienet/astar-collator + + - name: Setup zombienet + working-directory: third-party/zombienet + run: ./setup.sh + + - name: ${{ matrix.chain }} build blocks + working-directory: third-party/zombienet + env: + CHAIN: ${{ matrix.chain }} + run: zombienet -p native test smoke.zndsl diff --git a/.github/workflows/release.yml b/.github/workflows/release-runtime.yml similarity index 75% rename from .github/workflows/release.yml rename to .github/workflows/release-runtime.yml index 5476a68ab1..aadbd8b537 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release-runtime.yml @@ -2,7 +2,7 @@ name: Release Build on: push: tags: - - v[0-9]+.[0-9]+.[0-9]+* + - runtime-[0-9]{4,}* workflow_dispatch: env: SUBWASM_VERSION: 0.16.1 @@ -42,67 +42,6 @@ jobs: - name: Run all tests run: make test-all - native-linux: - needs: checks-and-tests - runs-on: [self-hosted, Linux, X64] - strategy: - matrix: - target: - - x86_64-unknown-linux-gnu - - aarch64-unknown-linux-gnu - - steps: - - name: Checkout the source code - uses: actions/checkout@v4 - with: - submodules: true - - - name: Install deps - run: sudo apt -y install protobuf-compiler - - - name: aarch64 setup - if: contains(matrix.target, 'aarch64') - shell: bash - run: | - sudo apt update - sudo apt install -y gcc-multilib g++-multilib - sudo apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu - - mkdir -p .cargo - touch .cargo/config - printf '[target.aarch64-unknown-linux-gnu]\nlinker = "aarch64-linux-gnu-gcc"' >> .cargo/config - - - name: x86_64 setup - if: contains(matrix.target, 'x86_64') - run: | - mkdir -p .cargo - touch .cargo/config - printf '[target.x86_64-unknown-linux-gnu]\nrustflags = ["-Clink-arg=-fuse-ld=lld"]' >> .cargo/config - - - name: Install & display rust toolchain - run: rustup show - - - name: Add aarch64 target - if: contains(matrix.target, 'aarch64') - run: rustup target add ${{ matrix.target }} - - - name: Check targets are installed correctly - run: rustup target list --installed - - - name: Build optimized binary - run: cargo build --profile production --target ${{ matrix.target }} --locked - - - name: Set artifact name - env: - TARGET: ${{ matrix.target }} - id: artifact-name - run: echo "::set-output name=name::astar-ubuntu-latest-${TARGET%%-*}" - - - uses: actions/upload-artifact@v3 - with: - name: ${{ steps.artifact-name.outputs.name }} - path: target/${{ matrix.target }}/production/astar-collator - evm-tracing-runtimes: needs: checks-and-tests runs-on: [self-hosted, Linux, X64] @@ -145,93 +84,6 @@ jobs: name: shibuya-evm-tracing-runtime path: target/production/wbuild/shibuya-runtime/shibuya_evm_tracing_runtime.compact.compressed.wasm - native-macos: - needs: checks-and-tests - runs-on: macos-latest - env: - RUSTC_WRAPPER: "sccache" - SCCACHE_BUCKET: ${{ secrets.SCCACHE_BUCKET }} - SCCACHE_REGION: ${{ secrets.SCCACHE_REGION }} - SCCACHE_S3_KEY_PREFIX: "astar-macos" - permissions: - id-token: write - contents: read - steps: - - name: Checkout the source code - uses: actions/checkout@v4 - with: - submodules: true - - - name: configure aws credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: ${{ secrets.SCCACHE_ROLE }} - role-session-name: github_astar_mac - aws-region: ${{ secrets.SCCACHE_REGION }} - - - name: Install deps - run: brew install protobuf sccache - - - name: Install & display rust toolchain - run: rustup show - - - name: Check targets are installed correctly - run: rustup target list --installed - - - name: Build optimized binary - run: cargo build --locked --profile production - - - name: Show sccache stats - run: sccache --show-stats - - - uses: actions/upload-artifact@v3 - with: - name: astar-macOS-latest-x86_64 - path: target/production/astar-collator - - docker: - needs: native-linux - runs-on: ubuntu-latest - steps: - - name: Checkout the source code - uses: actions/checkout@v4 - with: - submodules: true - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Docker meta - id: docker_meta - uses: crazy-max/ghaction-docker-meta@v1 - with: - images: staketechnologies/astar-collator - tag-custom: shiden - tag-sha: true # add git short SHA as Docker tag - - - name: Download pre-built linux collator binary - uses: actions/download-artifact@v3 - with: - name: astar-ubuntu-latest-x86_64 - - - name: Make binary executable and copy it to docker folder - run: chmod +x astar-collator && cp astar-collator third-party/docker - - - name: Build & Push docker image - uses: docker/build-push-action@v2 - with: - context: third-party/docker - platforms: linux/amd64 - labels: ${{ steps.docker_meta.outputs.labels }} - tags: ${{ steps.docker_meta.outputs.tags }} - push: true - srtool: needs: checks-and-tests runs-on: ubuntu-latest @@ -313,7 +165,7 @@ jobs: ${{ matrix.chain }}-diff.txt publish-release-draft: - needs: [native-linux, evm-tracing-runtimes, native-macOS, docker, srtool] + needs: [evm-tracing-runtimes, srtool] runs-on: ubuntu-latest outputs: release_url: ${{ steps.create-release.outputs.html_url }} @@ -360,7 +212,14 @@ jobs: run: | cd .github/scripts yarn - yarn -s run ts-node generate-release-body.ts generate --owner "${{ github.repository_owner }}" --repo "$(basename ${{ github.repository }})" --from "${{ steps.latest-release.outputs.release }}" --to "${{ github.ref_name }}" --srtool-report-folder '../../runtime-artifacts/' > ../../body.md + yarn -s run ts-node generate-release-body.ts generate \ + --owner "${{ github.repository_owner }}" \ + --repo "$(basename ${{ github.repository }})" \ + --from "${{ steps.latest-release.outputs.release }}" \ + --to "${{ github.ref_name }}" \ + --type client \ + --srtool-report-folder '../../runtime-artifacts/' \ + > ../../body.md - name: Create Release Draft id: create-release @@ -387,7 +246,6 @@ jobs: - name: Create download folder run: | mkdir -p ${{ matrix.os }}-${{ matrix.arch }}-bin - mkdir -p ubuntu-tracing-bin - name: Download pre-built collator binary uses: actions/download-artifact@v3