Skip to content

Commit 9c40e9a

Browse files
EgorPopelyaevlexnv
authored andcommitted
[CI/CD] Add a pipeline to build binaries in different profiles (#7496)
Recently there were some requests to build and deploy a binary, for example `polkadot`, in the `release` or `production` profile to do some testing. So far we had only a [release](https://github.com/paritytech/polkadot-sdk/blob/master/.github/workflows/release-20_build-rc.yml) pipeline that could do it in the GitHub but to use it, there was a lot of extra overhead needed. This pipeline should simplify this case and give a possibility to build a binary in desired profile from any branch for the testing purposes. Something similar to what we have for runtimes in the [srtool repo](https://github.com/paritytech/srtool/actions/workflows/manual.yml) It won't be used in any release activities though. CC: @BulatSaif
1 parent e599b29 commit 9c40e9a

2 files changed

Lines changed: 80 additions & 5 deletions

File tree

.github/scripts/release/build-linux-release.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# This is used to build our binaries:
44
# - polkadot
55
# - polkadot-parachain
6-
# - polkadot-omni-node
6+
# - polkadot-omni-node
77
#
88
# set -e
99

@@ -12,7 +12,6 @@ PACKAGE=${2:-$BIN}
1212

1313
PROFILE=${PROFILE:-production}
1414
ARTIFACTS=/artifacts/$BIN
15-
VERSION=$(git tag -l --contains HEAD | grep -E "^v.*")
1615

1716
echo "Artifacts will be copied into $ARTIFACTS"
1817
mkdir -p "$ARTIFACTS"
@@ -25,10 +24,10 @@ echo "Artifact target: $ARTIFACTS"
2524
cp ./target/$PROFILE/$BIN "$ARTIFACTS"
2625
pushd "$ARTIFACTS" > /dev/null
2726
sha256sum "$BIN" | tee "$BIN.sha256"
28-
29-
EXTRATAG="$($ARTIFACTS/$BIN --version |
27+
chmod a+x "$BIN"
28+
VERSION="$($ARTIFACTS/$BIN --version)"
29+
EXTRATAG="$(echo "${VERSION}" |
3030
sed -n -r 's/^'$BIN' ([0-9.]+.*-[0-9a-f]{7,13})-.*$/\1/p')"
31-
3231
EXTRATAG="${VERSION}-${EXTRATAG}-$(cut -c 1-8 $ARTIFACTS/$BIN.sha256)"
3332

3433
echo "$BIN version = ${VERSION} (EXTRATAG = ${EXTRATAG})"
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Binary Build
2+
# This workflow can be used to build a binary like polkadot + workers, omninode or polkadot-parachain
3+
# from any branch with release or profuction profile to be later used for testing.
4+
# ⚠️ IT should not be used for release purposes!
5+
6+
on:
7+
workflow_dispatch:
8+
inputs:
9+
binary:
10+
required: true
11+
default: "polkadot"
12+
description: "The binary to build"
13+
package:
14+
description: Package to be built, can be polkadot, polkadot-parachain-bin, polkadot-omni-node etc.
15+
required: true
16+
type: string
17+
profile:
18+
required: true
19+
default: "release"
20+
description: "The profile to use for the binary build"
21+
22+
jobs:
23+
24+
setup:
25+
# GitHub Actions allows using 'env' in a container context.
26+
# However, env variables don't work for forks: https://github.com/orgs/community/discussions/44322
27+
# This workaround sets the container image for each job using 'set-image' job output.
28+
runs-on: ubuntu-latest
29+
outputs:
30+
IMAGE: ${{ steps.set_image.outputs.IMAGE }}
31+
RUNNER: ${{ steps.set_runner.outputs.RUNNER }}
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
35+
36+
- name: Set image
37+
id: set_image
38+
run: cat .github/env >> $GITHUB_OUTPUT
39+
40+
- name: Set runner
41+
id: set_runner
42+
shell: bash
43+
run: |
44+
if [[ "${{ inputs.binary }}" == "polkadot-parachain" ]]; then
45+
echo "RUNNER=parity-large" >> $GITHUB_OUTPUT
46+
else
47+
echo "RUNNER=ubuntu-latest" >> $GITHUB_OUTPUT
48+
fi
49+
50+
build:
51+
needs: [setup]
52+
runs-on: ${{ needs.setup.outputs.RUNNER }}
53+
container:
54+
image: ${{ needs.setup.outputs.IMAGE }}
55+
steps:
56+
- name: Checkout
57+
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
58+
59+
- name: Build binary
60+
run: |
61+
git config --global --add safe.directory "${GITHUB_WORKSPACE}" #avoid "detected dubious ownership" error
62+
PROFILE=${{ inputs.profile }}
63+
if [ "${{ inputs.binary }}" = "polkadot" ]; then
64+
for binary in polkadot polkadot-prepare-worker polkadot-execute-worker; do
65+
echo "Building $binary..."
66+
./.github/scripts/release/build-linux-release.sh $binary ${{ inputs.package }} "${PROFILE}"
67+
done
68+
else
69+
./.github/scripts/release/build-linux-release.sh ${{ inputs.binary }} ${{ inputs.package }} "${PROFILE}"
70+
fi
71+
72+
- name: Upload ${{ inputs.binary }} artifacts
73+
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
74+
with:
75+
name: ${{ inputs.binary }}
76+
path: /artifacts/**

0 commit comments

Comments
 (0)