Skip to content

Commit

Permalink
Implement tag versioning. (#84)
Browse files Browse the repository at this point in the history
Special thanks @meeDamian.
  • Loading branch information
junaruga authored Aug 16, 2019
1 parent b89ece1 commit a80f6b0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
11 changes: 9 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ addons:
- cpio
env:
global:
- VERSION=4.0.0-5
- MAJOR_VERSION=4
- MINOR_VERSION=0
- PATCH_VERSION=0
- RELEASE_VERSION=5
- VERSION=$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION-$RELEASE_VERSION
# Container tag version string.
# Set it here to give a flexibility of the value such as "vX.Y".
- TAG_VER=v$VERSION
# See qemu-user-static's RPM spec file on Fedora to check the new version.
# https://src.fedoraproject.org/rpms/qemu/blob/master/f/qemu.spec
- DOCKER_SERVER=docker.io
Expand All @@ -33,7 +40,7 @@ script:
if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then
./publish.sh -v "$VERSION" -t "$GITHUB_TOKEN" -r "$REPO"
fi
- ./update.sh -v "$VERSION" -r "$REPO" -d "$DOCKER_REPO"
- ./update.sh -v "$VERSION" -t "$TAG_VER" -r "$REPO" -d "$DOCKER_REPO"
- docker images
- ./test.sh -d "$DOCKER_REPO"
after_success:
Expand Down
15 changes: 11 additions & 4 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ set -xe
# A POSIX variable
OPTIND=1 # Reset in case getopts has been used previously in the shell.

while getopts "r:v:d:" opt; do
while getopts "r:v:t:d:" opt; do
case "$opt" in
r) REPO=$OPTARG
;;
v) VERSION=$OPTARG
;;
t) TAG_VER=$OPTARG
;;
d) DOCKER_REPO=$OPTARG
;;
esac
Expand Down Expand Up @@ -58,11 +60,16 @@ for to_arch in $to_archs; do
FROM scratch
COPY qemu-${to_arch}-static /usr/bin/
EOF
docker build -t ${DOCKER_REPO}:$from_arch-$to_arch ${work_dir}
docker tag ${DOCKER_REPO}:$from_arch-$to_arch ${DOCKER_REPO}:$to_arch
docker build -t ${DOCKER_REPO}:$from_arch-$to_arch-${TAG_VER} ${work_dir}
for target in "${DOCKER_REPO}:$from_arch-$to_arch" \
"${DOCKER_REPO}:$to_arch-${TAG_VER}" \
"${DOCKER_REPO}:$to_arch" ; do
docker tag ${DOCKER_REPO}:$from_arch-$to_arch-${TAG_VER} "${target}"
done
rm -rf "${work_dir}"
fi
done

docker build -t ${DOCKER_REPO}:latest "${out_dir}/latest"
docker build -t ${DOCKER_REPO}:${TAG_VER} "${out_dir}/latest"
docker tag ${DOCKER_REPO}:${TAG_VER} ${DOCKER_REPO}:latest
docker build -t ${DOCKER_REPO}:register "${out_dir}/register"

0 comments on commit a80f6b0

Please sign in to comment.