Skip to content

Commit 2993b00

Browse files
Add stable release tag as an input parameter (#5282)
This PR adds the possibility to set the docker stable release tag as an input parameter to the produced docker images, so that it matches with the release version
1 parent 12539e7 commit 2993b00

File tree

2 files changed

+46
-9
lines changed

2 files changed

+46
-9
lines changed

.github/scripts/common/lib.sh

+13
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ function import_gpg_keys() {
315315
) &
316316
done
317317
wait
318+
gpg -k $SEC
318319
}
319320

320321
# Check the GPG signature for a given binary
@@ -457,3 +458,15 @@ function get_polkadot_node_version_from_code() {
457458
# Remove the semicolon
458459
sed 's/;//g'
459460
}
461+
462+
validate_stable_tag() {
463+
tag="$1"
464+
pattern='^stable[0-9]+(-[0-9]+)?$'
465+
466+
if [[ $tag =~ $pattern ]]; then
467+
echo $tag
468+
else
469+
echo "The input '$tag' does not match the pattern."
470+
exit 1
471+
fi
472+
}

.github/workflows/release-50_publish-docker.yml

+33-9
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ on:
4545
type: string
4646
default: docker.io
4747

48-
# The owner is often the same than the Docker Hub username but does ont have to be.
48+
# The owner is often the same as the Docker Hub username but does ont have to be.
4949
# In our case, it is not.
5050
owner:
5151
description: Owner of the container image repo
@@ -58,6 +58,10 @@ on:
5858
default: v0.9.18
5959
required: true
6060

61+
stable_tag:
62+
description: Tag matching the actual stable release version in the format stableYYMM or stableYYMM-X for patch releases
63+
required: true
64+
6165
permissions:
6266
contents: write
6367

@@ -74,6 +78,29 @@ env:
7478
VERSION: ${{ inputs.version }}
7579

7680
jobs:
81+
validate-inputs:
82+
runs-on: ubuntu-latest
83+
outputs:
84+
stable_tag: ${{ steps.validate_inputs.outputs.stable_tag }}
85+
86+
steps:
87+
- name: Checkout sources
88+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
89+
90+
- name: Validate inputs
91+
id: validate_inputs
92+
run: |
93+
. ./.github/scripts/common/lib.sh
94+
95+
VERSION=$(filter_version_from_input "${{ inputs.version }}")
96+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
97+
98+
RELEASE_ID=$(check_release_id "${{ inputs.release_id }}")
99+
echo "RELEASE_ID=${RELEASE_ID}" >> $GITHUB_ENV
100+
101+
STABLE_TAG=$(validate_stable_tag ${{ inputs.stable_tag }})
102+
echo "stable_tag=${STABLE_TAG}" >> $GITHUB_OUTPUT
103+
77104
fetch-artifacts: # this job will be triggered for the polkadot-parachain rc and release or polkadot rc image build
78105
if: ${{ inputs.binary == 'polkadot-parachain' || inputs.binary == 'chain-spec-builder' || inputs.image_type == 'rc' }}
79106
runs-on: ubuntu-latest
@@ -102,17 +129,14 @@ jobs:
102129
run: |
103130
. ./.github/scripts/common/lib.sh
104131
105-
VERSION=$(filter_version_from_input "${{ inputs.version }}")
106-
echo "VERSION=${VERSION}" >> $GITHUB_ENV
107-
108132
fetch_release_artifacts_from_s3
109133
110134
- name: Fetch chain-spec-builder rc artifacts or release artifacts based on release id
111135
#this step runs only if the workflow is triggered manually and only for chain-spec-builder
112136
if: ${{ env.EVENT_NAME == 'workflow_dispatch' && inputs.binary == 'chain-spec-builder' }}
113137
run: |
114138
. ./.github/scripts/common/lib.sh
115-
RELEASE_ID=$(check_release_id "${{ inputs.release_id }}")
139+
116140
fetch_release_artifacts
117141
118142
- name: Upload artifacts
@@ -124,7 +148,7 @@ jobs:
124148
build-container: # this job will be triggered for the polkadot-parachain rc and release or polkadot rc image build
125149
if: ${{ inputs.binary == 'polkadot-parachain' || inputs.binary == 'chain-spec-builder' || inputs.image_type == 'rc' }}
126150
runs-on: ubuntu-latest
127-
needs: fetch-artifacts
151+
needs: [fetch-artifacts, validate-inputs]
128152
environment: release
129153

130154
steps:
@@ -179,7 +203,7 @@ jobs:
179203
release=$( echo $VERSION | cut -f1 -d- )
180204
echo "tag=latest" >> $GITHUB_OUTPUT
181205
echo "release=${release}" >> $GITHUB_OUTPUT
182-
echo "stable=stable" >> $GITHUB_OUTPUT
206+
echo "stable=${{ needs.validate-inputs.outputs.stable_tag }}" >> $GITHUB_OUTPUT
183207
184208
- name: Build Injected Container image for polkadot rc or chain-spec-builder
185209
if: ${{ env.BINARY == 'polkadot' || env.BINARY == 'chain-spec-builder' }}
@@ -257,7 +281,7 @@ jobs:
257281
build-polkadot-release-container: # this job will be triggered for polkadot release build
258282
if: ${{ inputs.binary == 'polkadot' && inputs.image_type == 'release' }}
259283
runs-on: ubuntu-latest
260-
needs: fetch-latest-debian-package-version
284+
needs: [fetch-latest-debian-package-version, validate-inputs]
261285
environment: release
262286
steps:
263287
- name: Checkout sources
@@ -295,7 +319,7 @@ jobs:
295319
# TODO: The owner should be used below but buildx does not resolve the VARs
296320
# TODO: It would be good to get rid of this GHA that we don't really need.
297321
tags: |
298-
parity/polkadot:stable
322+
parity/polkadot:${{ needs.validate-inputs.outputs.stable_tag }}
299323
parity/polkadot:latest
300324
parity/polkadot:${{ needs.fetch-latest-debian-package-version.outputs.polkadot_container_tag }}
301325
build-args: |

0 commit comments

Comments
 (0)