diff --git a/.github/scripts/release/build-linux-release.sh b/.github/scripts/release/build-linux-release.sh index 874c9b44788b3..a2beb6a276b98 100755 --- a/.github/scripts/release/build-linux-release.sh +++ b/.github/scripts/release/build-linux-release.sh @@ -9,6 +9,11 @@ BIN=$1 PACKAGE=${2:-$BIN} +# must be given as feature1,feature2,feature3... +FEATURES=$3 +if [ -n "$FEATURES" ]; then + FEATURES="--features ${FEATURES}" +fi PROFILE=${PROFILE:-production} ARTIFACTS=/artifacts/$BIN @@ -18,7 +23,7 @@ echo "Artifacts will be copied into $ARTIFACTS" mkdir -p "$ARTIFACTS" git log --pretty=oneline -n 1 -time cargo build --profile $PROFILE --locked --verbose --bin $BIN --package $PACKAGE +time cargo build --profile $PROFILE --locked --verbose --bin $BIN --package $PACKAGE $FEATURES echo "Artifact target: $ARTIFACTS" diff --git a/.github/workflows/release-20_build-rc.yml b/.github/workflows/release-20_build-rc.yml index 594356d4a06ba..6b4c67b832685 100644 --- a/.github/workflows/release-20_build-rc.yml +++ b/.github/workflows/release-20_build-rc.yml @@ -47,7 +47,7 @@ jobs: build-polkadot-binary: needs: [validate-inputs] if: ${{ inputs.binary == 'polkadot' || inputs.binary == 'all' }} - uses: "./.github/workflows/release-reusable-rc-buid.yml" + uses: "./.github/workflows/release-reusable-rc-build.yml" with: binary: '["polkadot", "polkadot-prepare-worker", "polkadot-execute-worker"]' package: polkadot @@ -69,7 +69,7 @@ jobs: build-polkadot-parachain-binary: needs: [validate-inputs] if: ${{ inputs.binary == 'polkadot-parachain' || inputs.binary == 'all' }} - uses: "./.github/workflows/release-reusable-rc-buid.yml" + uses: "./.github/workflows/release-reusable-rc-build.yml" with: binary: '["polkadot-parachain"]' package: "polkadot-parachain-bin" @@ -91,12 +91,13 @@ jobs: build-polkadot-omni-node-binary: needs: [validate-inputs] if: ${{ inputs.binary == 'polkadot-omni-node' || inputs.binary == 'all' }} - uses: "./.github/workflows/release-reusable-rc-buid.yml" + uses: "./.github/workflows/release-reusable-rc-build.yml" with: binary: '["polkadot-omni-node"]' package: "polkadot-omni-node" release_tag: ${{ needs.validate-inputs.outputs.release_tag }} target: x86_64-unknown-linux-gnu + features: runtime-benchmarks secrets: PGP_KMS_KEY: ${{ secrets.PGP_KMS_KEY }} PGP_KMS_HASH: ${{ secrets.PGP_KMS_HASH }} @@ -113,7 +114,7 @@ jobs: build-frame-omni-bencher-binary: needs: [validate-inputs] if: ${{ inputs.binary == 'frame-omni-bencher' || inputs.binary == 'all' }} - uses: "./.github/workflows/release-reusable-rc-buid.yml" + uses: "./.github/workflows/release-reusable-rc-build.yml" with: binary: '["frame-omni-bencher"]' package: "frame-omni-bencher" @@ -135,7 +136,7 @@ jobs: build-chain-spec-builder-binary: needs: [validate-inputs] if: ${{ inputs.binary == 'chain-spec-builder' || inputs.binary == 'all' }} - uses: "./.github/workflows/release-reusable-rc-buid.yml" + uses: "./.github/workflows/release-reusable-rc-build.yml" with: binary: '["chain-spec-builder"]' package: staging-chain-spec-builder @@ -157,7 +158,7 @@ jobs: build-polkadot-macos-binary: needs: [validate-inputs] if: ${{ inputs.binary == 'polkadot' || inputs.binary == 'all' }} - uses: "./.github/workflows/release-reusable-rc-buid.yml" + uses: "./.github/workflows/release-reusable-rc-build.yml" with: binary: '["polkadot", "polkadot-prepare-worker", "polkadot-execute-worker"]' package: polkadot @@ -179,7 +180,7 @@ jobs: build-polkadot-parachain-macos-binary: needs: [validate-inputs] if: ${{ inputs.binary == 'polkadot-parachain' || inputs.binary == 'all' }} - uses: "./.github/workflows/release-reusable-rc-buid.yml" + uses: "./.github/workflows/release-reusable-rc-build.yml" with: binary: '["polkadot-parachain"]' package: polkadot-parachain-bin @@ -201,12 +202,13 @@ jobs: build-polkadot-omni-node-macos-binary: needs: [validate-inputs] if: ${{ inputs.binary == 'polkadot-omni-node' || inputs.binary == 'all' }} - uses: "./.github/workflows/release-reusable-rc-buid.yml" + uses: "./.github/workflows/release-reusable-rc-build.yml" with: binary: '["polkadot-omni-node"]' package: polkadot-omni-node release_tag: ${{ needs.validate-inputs.outputs.release_tag }} target: aarch64-apple-darwin + features: runtime-benchmarks secrets: PGP_KMS_KEY: ${{ secrets.PGP_KMS_KEY }} PGP_KMS_HASH: ${{ secrets.PGP_KMS_HASH }} @@ -223,7 +225,7 @@ jobs: build-frame-omni-bencher-macos-binary: needs: [validate-inputs] if: ${{ inputs.binary == 'frame-omni-bencher' || inputs.binary == 'all' }} - uses: "./.github/workflows/release-reusable-rc-buid.yml" + uses: "./.github/workflows/release-reusable-rc-build.yml" with: binary: '["frame-omni-bencher"]' package: frame-omni-bencher @@ -245,7 +247,7 @@ jobs: build-chain-spec-builder-macos-binary: needs: [validate-inputs] if: ${{ inputs.binary == 'chain-spec-builder' || inputs.binary == 'all' }} - uses: "./.github/workflows/release-reusable-rc-buid.yml" + uses: "./.github/workflows/release-reusable-rc-build.yml" with: binary: '["chain-spec-builder"]' package: staging-chain-spec-builder diff --git a/.github/workflows/release-build-binary.yml b/.github/workflows/release-build-binary.yml new file mode 100644 index 0000000000000..a5adab421a8a4 --- /dev/null +++ b/.github/workflows/release-build-binary.yml @@ -0,0 +1,80 @@ +name: Binary Build +# This workflow can be used to build a binary like polkadot + workers, omninode or polkadot-parachain +# from any branch with release or profuction profile to be later used for testing. +# ⚠️ IT should not be used for release purposes! + +on: + workflow_dispatch: + inputs: + binary: + required: true + default: "polkadot" + description: "The binary to build" + package: + description: Package to be built, can be polkadot, polkadot-parachain-bin, polkadot-omni-node etc. + required: true + type: string + profile: + required: true + default: "release" + description: "The profile to use for the binary build" + features: + required: false + type: string + description: "Features to enable when building the binary (must be a list of comma-separated features)" + +jobs: + + setup: + # GitHub Actions allows using 'env' in a container context. + # However, env variables don't work for forks: https://github.com/orgs/community/discussions/44322 + # This workaround sets the container image for each job using 'set-image' job output. + runs-on: ubuntu-latest + outputs: + IMAGE: ${{ steps.set_image.outputs.IMAGE }} + RUNNER: ${{ steps.set_runner.outputs.RUNNER }} + steps: + - name: Checkout + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + + - name: Set image + id: set_image + run: cat .github/env >> $GITHUB_OUTPUT + + - name: Set runner + id: set_runner + shell: bash + run: | + if [[ "${{ inputs.binary }}" == "polkadot-parachain" ]]; then + echo "RUNNER=parity-large" >> $GITHUB_OUTPUT + else + echo "RUNNER=ubuntu-latest" >> $GITHUB_OUTPUT + fi + + build: + needs: [setup] + runs-on: ${{ needs.setup.outputs.RUNNER }} + container: + image: ${{ needs.setup.outputs.IMAGE }} + steps: + - name: Checkout + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + + - name: Build binary + run: | + git config --global --add safe.directory "${GITHUB_WORKSPACE}" #avoid "detected dubious ownership" error + PROFILE=${{ inputs.profile }} + if [ "${{ inputs.binary }}" = "polkadot" ]; then + for binary in polkadot polkadot-prepare-worker polkadot-execute-worker; do + echo "Building $binary..." + ./.github/scripts/release/build-linux-release.sh $binary ${{ inputs.package }} "${PROFILE}" ${{ inputs.features }} + done + else + ./.github/scripts/release/build-linux-release.sh ${{ inputs.binary }} ${{ inputs.package }} "${PROFILE}" ${{ inputs.features }} + fi + + - name: Upload ${{ inputs.binary }} artifacts + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + with: + name: ${{ inputs.binary }} + path: /artifacts/** diff --git a/.github/workflows/release-reusable-rc-buid.yml b/.github/workflows/release-reusable-rc-build.yml similarity index 98% rename from .github/workflows/release-reusable-rc-buid.yml rename to .github/workflows/release-reusable-rc-build.yml index e10851870b4a5..fba7b305e965a 100644 --- a/.github/workflows/release-reusable-rc-buid.yml +++ b/.github/workflows/release-reusable-rc-build.yml @@ -24,6 +24,11 @@ on: required: true type: string + features: + description: Features to be enabled when building the binary (must be a list of comma-separated features) + required: false + type: string + secrets: PGP_KMS_KEY: required: true @@ -101,7 +106,7 @@ jobs: - name: Build binary run: | git config --global --add safe.directory "${GITHUB_WORKSPACE}" #avoid "detected dubious ownership" error - ./.github/scripts/release/build-linux-release.sh ${{ matrix.binaries }} ${{ inputs.package }} + ./.github/scripts/release/build-linux-release.sh ${{ matrix.binaries }} ${{ inputs.package }} ${{ inputs.features }} - name: Generate artifact attestation uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3 @@ -216,7 +221,7 @@ jobs: - name: Build binary run: | git config --global --add safe.directory "${GITHUB_WORKSPACE}" #avoid "detected dubious ownership" error - ./.github/scripts/release/build-macos-release.sh ${{ matrix.binaries }} ${{ inputs.package }} + ./.github/scripts/release/build-macos-release.sh ${{ matrix.binaries }} ${{ inputs.package }} ${{ inputs.features }} - name: Generate artifact attestation uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3