@@ -7,9 +7,10 @@ name: Release - Publish Docker Image
77# image and publishes it.
88
99on :
10- release :
11- types :
12- - published
10+ # TODO: activate automated run later
11+ # release:
12+ # types:
13+ # - published
1314 workflow_dispatch :
1415 inputs :
1516 release_id :
3940 required : true
4041 type : string
4142 default : parity
43+ binary :
44+ description : Binary to be published
45+ required : true
46+ default : polkadot
47+ type : choice
48+ options :
49+ - polkadot
50+ - staking-miner
51+ - polkadot-parachain
52+
53+ permissions :
54+ contents : write
4255
4356env :
4457 RELEASE_ID : ${{ inputs.release_id }}
4760 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4861 DOCKER_OWNER : ${{ inputs.owner || github.repository_owner }}
4962 REPO : ${{ github.repository }}
50- BINARY : polkadot-parachain
51- EVENT_ACTION : ${{ github.event.action }}
63+ BINARY : ${{ inputs.binary }}
64+ # EVENT_ACTION: ${{ github.event.action }}
5265 EVENT_NAME : ${{ github.event_name }}
5366 IMAGE_TYPE : ${{ inputs.image_type }}
5467
@@ -58,100 +71,68 @@ jobs:
5871
5972 steps :
6073 - name : Checkout sources
61- uses : actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
62-
63- - name : Prepare temp folder
64- run : |
65- TMP=$(mktemp -d)
66- echo "TMP=$TMP" >> "$GITHUB_ENV"
67- pwd
68- ls -al "$TMP"
74+ uses : actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
6975
70- - name : Fetch lib.sh from polkadot repo
71- working-directory : ${{ env.TMP }}
72- run : |
73- curl -O -L \
74- -H "Accept: application/vnd.github.v3.raw" \
75- https://raw.githubusercontent.com/paritytech/polkadot/master/scripts/ci/common/lib.sh
76-
77- chmod a+x lib.sh
78- ls -al
79-
80- - name : Fetch release artifacts based on final release tag
76+ # TODO: this step will be needed when automated triggering will work
8177 # this step runs only if the workflow is triggered automatically when new release is published
82- if : ${{ env.EVENT_NAME == 'release' && env.EVENT_ACTION != '' && env.EVENT_ACTION == 'published' }}
83- run : |
84- mkdir -p release-artifacts && cd release-artifacts
85-
86- for f in $BINARY $BINARY.asc $BINARY.sha256; do
87- URL="https://github.com/${{ github.event.repository.full_name }}/releases/download/${{ github.event.release.tag_name }}/$f"
88- echo " - Fetching $f from $URL"
89- wget "$URL" -O "$f"
90- done
91- chmod a+x $BINARY
92- cp -f ${TMP}/lib.sh .
93- ls -al
78+ # if: ${{ env.EVENT_NAME == 'release' && env.EVENT_ACTION != '' && env.EVENT_ACTION == 'published' }}
79+ # run: |
80+ # mkdir -p release-artifacts && cd release-artifacts
81+
82+ # for f in $BINARY $BINARY.asc $BINARY.sha256; do
83+ # URL="https://github.com/${{ github.event.repository.full_name }}/releases/download/${{ github.event.release.tag_name }}/$f"
84+ # echo " - Fetching $f from $URL"
85+ # wget "$URL" -O "$f"
86+ # done
87+ # chmod a+x $BINARY
88+ # ls -al
9489
9590 - name : Fetch rc artifacts or release artifacts based on release id
9691 # this step runs only if the workflow is triggered manually
9792 if : ${{ env.EVENT_NAME == 'workflow_dispatch' }}
9893 run : |
99- . ${TMP} /lib.sh
94+ . ./.github/scripts/common /lib.sh
10095
10196 fetch_release_artifacts
10297
103- chmod a+x release-artifacts/$BINARY
104- ls -al
105-
106- cp -f ${TMP}/lib.sh release-artifacts/
107-
10898 - name : Cache the artifacts
10999 uses : actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
110100 with :
111- key : artifacts-${{ github.sha }}
101+ key : artifacts-${{ env.BINARY }}-${{ github.sha }}
112102 path : |
113- ./release-artifacts/**/*
103+ ./release-artifacts/${{ env.BINARY }}/ **/*
114104
115105 build-container :
116106 runs-on : ubuntu-latest
117107 needs : fetch-artifacts
118108
119109 steps :
120110 - name : Checkout sources
121- uses : actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
111+ uses : actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
122112
123113 - name : Get artifacts from cache
124114 uses : actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
125115 with :
126- key : artifacts-${{ github.sha }}
116+ key : artifacts-${{ env.BINARY }}-${{ github.sha }}
127117 fail-on-cache-miss : true
128118 path : |
129- ./release-artifacts/**/*
119+ ./release-artifacts/${{ env.BINARY }}/ **/*
130120
131121 - name : Check sha256 ${{ env.BINARY }}
132- working-directory : ./release-artifacts
122+ working-directory : ./release-artifacts/${{ env.BINARY }}
133123 run : |
134- . ./lib.sh
124+ . ../../.github/scripts/common /lib.sh
135125
136126 echo "Checking binary $BINARY"
137127 check_sha256 $BINARY && echo "OK" || echo "ERR"
138128
139129 - name : Check GPG ${{ env.BINARY }}
140- working-directory : ./release-artifacts
130+ working-directory : ./release-artifacts/${{ env.BINARY }}
141131 run : |
142- . ./lib.sh
132+ . ../../.github/scripts/common /lib.sh
143133 import_gpg_keys
144134 check_gpg $BINARY
145135
146- - name : Build Injected Container image for ${{ env.BINARY }}
147- env :
148- IMAGE_NAME : ${{ env.BINARY }}
149- OWNER : ${{ env.DOCKER_OWNER }}
150- run : |
151- ls -al
152- echo "Building container for $BINARY"
153- ./docker/scripts/build-injected-image.sh
154-
155136 - name : Fetch rc commit and tag
156137 if : ${{ env.IMAGE_TYPE == 'rc' }}
157138 id : fetch_rc_refs
@@ -167,36 +148,55 @@ jobs:
167148 echo "No tag, doing without"
168149
169150 - name : Fetch release tags
170- if : ${{ env.IMAGE_TYPE == 'release' || env.EVENT_NAME == 'release' && env.EVENT_ACTION != '' && env.EVENT_ACTION == 'published' }}
151+ working-directory : ./release-artifacts/${{ env.BINARY }}
152+ if : ${{ env.IMAGE_TYPE == 'release'}}
171153 id : fetch_release_refs
172154 run : |
173- VERSION=$(docker run --pull never --rm $DOCKER_OWNER/$BINARY --version | awk '{ print $2 }' )
155+ chmod a+rx $BINARY
156+ VERSION=$(./$BINARY --version | awk '{ print $2 }' )
174157 release=$( echo $VERSION | cut -f1 -d- )
175158 echo "tag=latest" >> $GITHUB_OUTPUT
176159 echo "release=${release}" >> $GITHUB_OUTPUT
177160
161+ - name : Build Injected Container image for polkadot/staking-miner
162+ if : ${{ env.BINARY == 'polkadot' || env.BINARY == 'staking-miner' }}
163+ env :
164+ ARTIFACTS_FOLDER : ./release-artifacts
165+ IMAGE_NAME : ${{ env.BINARY }}
166+ OWNER : ${{ env.DOCKER_OWNER }}
167+ TAGS : ${{ join(steps.fetch_rc_refs.outputs.*, ',') || join(steps.fetch_release_refs.outputs.*, ',') }}
168+ run : |
169+ ls -al
170+ echo "Building container for $BINARY"
171+ ./docker/scripts/build-injected.sh
172+
173+ - name : Build Injected Container image for polkadot-parachain
174+ if : ${{ env.BINARY == 'polkadot-parachain' }}
175+ env :
176+ ARTIFACTS_FOLDER : ./release-artifacts
177+ IMAGE_NAME : ${{ env.BINARY }}
178+ OWNER : ${{ env.DOCKER_OWNER }}
179+ DOCKERFILE : docker/dockerfiles/polkadot-parachain/polkadot-parachain_injected.Dockerfile
180+ TAGS : ${{ join(steps.fetch_rc_refs.outputs.*, ',') || join(steps.fetch_release_refs.outputs.*, ',') }}
181+ run : |
182+ ls -al
183+ mkdir -p $ARTIFACTS_FOLDER/specs
184+ cp cumulus/parachains/chain-specs/*.json $ARTIFACTS_FOLDER/specs
185+
186+ echo "Building container for $BINARY"
187+ ./docker/scripts/build-injected.sh
178188
179189 - name : Login to Dockerhub
180190 uses : docker/login-action@v2
181191 with :
182192 username : ${{ secrets.DOCKERHUB_USERNAME }}
183193 password : ${{ secrets.DOCKERHUB_TOKEN }}
184194
185- - name : Tag and Push Container image for ${{ env.BINARY }}
195+ - name : Push Container image for ${{ env.BINARY }}
186196 id : docker_push
187- env :
188- TAGS : ${{ join(steps.fetch_rc_refs.outputs.*, ',') || join(steps.fetch_release_refs.outputs.*, ',') }}
189197 run : |
190- TAGS=${TAGS[@]:-latest}
191- IFS=',' read -r -a TAG_ARRAY <<< "$TAGS"
192-
193- echo "The image ${BINARY} will be tagged with ${TAG_ARRAY[*]}"
194- for TAG in "${TAG_ARRAY[@]}"; do
195- $ENGINE tag ${DOCKER_OWNER}/${BINARY} ${DOCKER_OWNER}/${BINARY}:${TAG}
196- $ENGINE push ${DOCKER_OWNER}/${BINARY}:${TAG}
197- done
198-
199198 $ENGINE images | grep ${BINARY}
199+ $ENGINE push --all-tags ${REGISTRY}/${DOCKER_OWNER}/${BINARY}
200200
201201 - name : Check version for the published image for ${{ env.BINARY }}
202202 env :
0 commit comments