@@ -102,7 +102,6 @@ jobs:
102102 QEMU_VERSION : v4.2.0
103103 run : docker run --rm --privileged "meedamian/simple-qemu:${QEMU_VERSION}" -p yes
104104
105- # TODO: add labels, see: https://github.com/lncm/docker-lnd/blob/3a26bc667c441e94958b876170f87d538cb5a07a/.github/workflows/on-tag.yml#L102-L107
106105 - name : Build IPFS
107106 run : >
108107 docker build --no-cache .
@@ -111,6 +110,12 @@ jobs:
111110 --build-arg "GOARCH=${GOARCH}"
112111 --build-arg "GOARM=${GOARM}"
113112 --build-arg "FLAVOR=${{matrix.flavor}}"
113+ --label "arch=${{matrix.arch}}"
114+ --label "commit=${{github.sha}}"
115+ --label "git-tag=${TAG}"
116+ --label "guilty=${{github.actor}}"
117+ --label "repo-url=${{github.repositoryUrl}}"
118+ --label "flavor=${FLAVOR}"
114119 --tag "${APP}:${FLAV_ARCH}"
115120
116121 - name : Show built image details
@@ -148,34 +153,48 @@ jobs:
148153 path : binary/
149154
150155
151- docker-hub-push :
152- name : Tag & deploy to Docker Hub. Only after successful build, and test of a pushed git tag
156+ docker-hub :
157+ name : Tag & deploy to Docker Hub. Only after all builds & tests succeed
158+
153159 runs-on : ubuntu-18.04
154160 needs : build
155161
156- env :
157- APP : ipfs
158-
159162 steps :
160163161164
162- - name : Enable Docker manifest features
163- run : |
164- mkdir -p ~/.docker
165- echo '{ "experimental": "enabled" }' > ~/.docker/config.json
166- sudo systemctl restart docker
167-
168165 - name : Setup environment
169166 run : |
170- VERSION="$(echo "${GITHUB_REF}" | grep 'refs/tags/' | awk -F/ '{print $NF}')"
171- echo ::set-env name=VERSION::"${VERSION}"
167+ echo ::set-env name=DOCKER_USER::"${GITHUB_ACTOR,,}"
168+
169+ SLUG="$(echo ${GITHUB_REPOSITORY,,} | sed 's/docker-//')"
170+ echo ::set-env name=SLUG::"${SLUG}"
172171
173- echo ::set-env name=SLUG ::"$(echo ${GITHUB_REPOSITORY,,} | sed 's/docker-// ')"
172+ echo ::set-env name=APP ::"$(echo "${SLUG}" | awk -F/ '{print $NF} ')"
174173
175- - name : Print Docker version
176- run : docker version
174+ TAG="$(echo "${GITHUB_REF}" | grep 'refs/tags/' | awk -F/ '{print $NF}')"
175+ echo ::set-env name=TAG::"${TAG}"
177176
178- - name : Download build artifact
177+ echo ::set-env name=VERSION::"$(echo "${TAG}" | cut -d+ -f1)"
178+ echo ::set-env name=BUILD::"$(echo "+${TAG}" | cut -d+ -f3)"
179+
180+ - name : Print just set ENV VARs
181+ run : |
182+ printf "Just set env vars:\n"
183+ printf " USER: %s\n" "${DOCKER_USER}"
184+ printf " TAG: %s\n" "${TAG}"
185+ printf " SLUG: %s\n" "${SLUG}"
186+ printf " APP: %s\n" "${APP}"
187+ printf "VERSION: %s\n" "${VERSION}"
188+ printf " BUILD: %s\n" "${BUILD}"
189+
190+ - name : Enable manifests & print Docker version
191+ run : |
192+ mkdir -p ~/.docker
193+ echo '{ "experimental": "enabled" }' > ~/.docker/config.json
194+ sudo systemctl restart docker
195+ docker version
196+
197+ - name : Download images built in build job
179198180199 with :
181200 name : docker-images
@@ -184,47 +203,62 @@ jobs:
184203 run : sha256sum docker-images/*
185204
186205 - name : Load images locally
187- run : ls docker-images/ | xargs -I % docker load -i "docker-images/%"
188-
189- - name : List all tagged images
190- run : docker images "${APP}"
206+ run : ls -d docker-images/* | xargs -I % docker load -i "%"
191207
208+ # `ipfs:fuse-arm64` -> `lncm/ipfs:v0.4.22-fuse-arm64-build1`
209+ # `ipfs:fuse-arm64` -> `lncm/ipfs:v0.4.22-fuse-arm64`
210+ # `ipfs:nofuse-arm64` -> `lncm/ipfs:v0.4.22-nofuse-arm64-build1`
211+ # `ipfs:nofuse-arm64 -> `lncm/ipfs:v0.4.22-nofuse-arm64`
192212 - name : Version-tag all images
193213 run : |
194- for arch in $(docker images "${APP}" --format "{{.Tag}}"); do
195- docker tag "${APP}:${arch}" "${SLUG}:${VERSION}-${arch}"
214+ for tag in $(docker images ${APP} --format "{{.Tag}}"); do
215+ docker tag "${APP}:${tag}" "${SLUG}:${VERSION}-${tag}-${BUILD}"
216+ docker tag "${APP}:${tag}" "${SLUG}:${VERSION}-${tag}"
196217 done
197218
198219 - name : List all tagged images
199220 run : docker images "${SLUG}"
200221
201222 - name : Login to Docker Hub
202- run : echo "${{secrets.DOCKER_TOKEN}}" | docker login -u="meedamian" --password-stdin
223+ run : |
224+ echo "Logging in as ${DOCKER_USER}…"
225+ echo "${{secrets.DOCKER_TOKEN}}" | docker login -u="${DOCKER_USER}" --password-stdin
203226
204227 - name : Push all images
205- run : |
206- for image in $(docker images "${SLUG}" --format "{{.Repository}}:{{.Tag}}"); do
207- docker push "${image}"
208- done
228+ run : docker images "${SLUG}" --format "{{.Repository}}:{{.Tag}}" | xargs -I % docker push %
209229
210230 - name : Get convenience Docker tag suggestions
211231 id : tags
212232213233
214- - name : Create version-exact manifest
215- run : ./scripts/ci-create-manifest.sh "${SLUG}" "${VERSION}"
234+ - name : Create :X.Y.Z manifests
235+ run : |
236+ ./scripts/ci-create-manifest.sh "${SLUG}" "${VERSION}" "fuse" "${VERSION}-fuse"
237+ ./scripts/ci-create-manifest.sh "${SLUG}" "${VERSION}" "nofuse" "${VERSION}-nofuse"
238+ ./scripts/ci-create-manifest.sh "${SLUG}" "${VERSION}" "nofuse"
216239
217- - name : Create minor-version manifest
240+ - name : Create :X.Y manifests
218241 if : steps.tags.outputs.minor != ''
219- run : ./scripts/ci-create-manifest.sh "${SLUG}" "${VERSION}" "${{steps.tags.outputs.minor}}"
242+ run : |
243+ SHORT="${{steps.tags.outputs.minor}}"
244+ ./scripts/ci-create-manifest.sh "${SLUG}" "${VERSION}" "fuse" "${SHORT}-fuse"
245+ ./scripts/ci-create-manifest.sh "${SLUG}" "${VERSION}" "nofuse" "${SHORT}-nofuse"
246+ ./scripts/ci-create-manifest.sh "${SLUG}" "${VERSION}" "nofuse"
220247
221- - name : Create major-version manifest
248+ - name : Create :X manifests
222249 if : steps.tags.outputs.major != ''
223- run : ./scripts/ci-create-manifest.sh "${SLUG}" "${VERSION}" "${{steps.tags.outputs.major}}"
250+ run : |
251+ SHORT="${{steps.tags.outputs.major}}"
252+ ./scripts/ci-create-manifest.sh "${SLUG}" "${VERSION}" "fuse" "${SHORT}-fuse"
253+ ./scripts/ci-create-manifest.sh "${SLUG}" "${VERSION}" "nofuse" "${SHORT}-nofuse"
254+ ./scripts/ci-create-manifest.sh "${SLUG}" "${VERSION}" "nofuse"
224255
225- - name : Create latest-version manifest
256+ - name : Create : latest manifests
226257 if : steps.tags.outputs.latest != ''
227- run : ./scripts/ci-create-manifest.sh "${SLUG}" "${VERSION}" "${{steps.tags.outputs.latest}}"
258+ run : |
259+ ./scripts/ci-create-manifest.sh "${SLUG}" "${VERSION}" "fuse" "fuse"
260+ ./scripts/ci-create-manifest.sh "${SLUG}" "${VERSION}" "nofuse" "nofuse"
261+ ./scripts/ci-create-manifest.sh "${SLUG}" "${VERSION}" "nofuse" "${{steps.tags.outputs.latest}}"
228262
229263 - name : List all tagged images
230264 run : docker images "${SLUG}"
0 commit comments