Skip to content

Commit db339a7

Browse files
committed
Adjust logic
1 parent 485e640 commit db339a7

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

.github/workflows/docker.yaml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,35 +56,37 @@ jobs:
5656
nix build .#docker-${{ matrix.target }}
5757
docker load < result
5858
59-
# Determine whether we are building a tag and if yes, set a VERSION_NAME
59+
- name: Tag images
60+
run: |
61+
62+
# Determine whether we are building a tag and if yes, set a
63+
# VERSION_NAME, if not, use `unstable` as the version name.
6064
BUILDING_TAG=${{github.ref_type == 'tag'}}
65+
VERSION_NAME=unstable
6166
[[ ${BUILDING_TAG} = true ]] && \
6267
VERSION_NAME=${{github.ref_name}}
6368
64-
# Determine if we are building on master
65-
BUILDING_ON_MASTER=false
66-
[[ ${GITHUB_REF_NAME} == 'master' ]] && BUILDING_ON_MASTER=true
67-
6869
# Use 'FROM' instruction to use docker build with --label
6970
echo "FROM ${{matrix.target}}" | docker build \
7071
--label org.opencontainers.image.source=https://github.com/cardano-scaling/hydra \
7172
--label org.opencontainers.image.licenses=Apache-2.0 \
7273
--label org.opencontainers.image.created=$(date -Is) \
7374
--label org.opencontainers.image.revision=${{github.sha}} \
74-
--label org.opencontainers.image.version=${VERSION_NAME:-unstable} \
75-
--tag ${IMAGE_NAME}:unstable -
75+
--label org.opencontainers.image.version=${VERSION_NAME} \
76+
--tag ${IMAGE_NAME}:${VERSION_NAME} -
77+
78+
[[ ${GITHUB_REF_NAME} = "release" ]] && \
79+
docker tag ${IMAGE_NAME} ${IMAGE_NAME}:latest
7680
77-
# Also tag with 'latest' if we are building on master
78-
[[ ${BUILDING_ON_MASTER} = true ]] && \
79-
docker tag ${IMAGE_NAME}:unstable ${IMAGE_NAME}:latest
8081
# Also tag with version if we are building a tag
8182
[[ ${BUILDING_TAG} = true && ${{matrix.target}} != "hydraw" ]] && \
82-
docker tag ${IMAGE_NAME}:unstable ${IMAGE_NAME}:${VERSION_NAME}
83+
docker tag ${IMAGE_NAME} ${IMAGE_NAME}:${VERSION_NAME}
84+
8385
# Also tag with ref name when manually dispatched
8486
[[ ${{github.event_name == 'workflow_dispatch'}} = true ]] && \
85-
docker tag ${IMAGE_NAME}:unstable ${IMAGE_NAME}:workflow_dispatch-${{github.event.inputs.ref_name}}
87+
docker tag ${IMAGE_NAME} ${IMAGE_NAME}:workflow_dispatch-${{github.event.inputs.ref_name}}
8688
87-
docker inspect ${IMAGE_NAME}:unstable
89+
docker inspect ${IMAGE_NAME}
8890
docker images
8991
9092
- name: 📤 Push to registry

0 commit comments

Comments
 (0)