-
Notifications
You must be signed in to change notification settings - Fork 237
Simplify & introduce versioning #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8578f2f
893a2b2
f2a8555
a9f1275
ddc8e09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,38 +7,47 @@ addons: | |
retries: true | ||
update: true | ||
packages: | ||
- jq | ||
- rpm2cpio | ||
- cpio | ||
env: | ||
global: | ||
- VERSION=4.0.0-5 | ||
# 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 | ||
# - DOCKER_SERVER=quay.io | ||
# Git repository | ||
- REPO=multiarch/qemu-user-static | ||
# Container repository | ||
- DOCKER_REPO=$DOCKER_SERVER/multiarch/qemu-user-static | ||
# - DOCKER_REPO=$DOCKER_SERVER/your_username/qemu-user-static | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please keep The reason why Though I understand the each feature in this PR is great. I am thinking how we can proceed this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Everything was commented out, and defaults were used. I thought that in a case like this it's simpler to start with a cleaner slate, and then gradually add features, as they become needed at the time. Also, not sure what "adhoc pipline" means, and how and what version to add 🤔 |
||
- PACKAGE_URI="https://kojipkgs.fedoraproject.org/packages/qemu/4.0.0/5.fc31/x86_64/qemu-user-static-4.0.0-5.fc31.x86_64.rpm" | ||
- PACKAGE_FILENAME=$(basename "$PACKAGE_URI") | ||
|
||
stages: | ||
- build | ||
- test | ||
- name: deploy | ||
if: tag IS present | ||
|
||
|
||
before_script: | ||
- wget --content-disposition $PACKAGE_URI | ||
- rpm2cpio $PACKAGE_FILENAME | cpio -dimv | ||
script: | ||
- wget --content-disposition ${PACKAGE_URI} | ||
- rpm2cpio ${PACKAGE_FILENAME} | cpio -dimv | ||
- ./generate_tarballs.sh | ||
- | | ||
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" | ||
- docker images | ||
- ./test.sh -d "$DOCKER_REPO" | ||
after_success: | ||
- | | ||
if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then | ||
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" "$DOCKER_SERVER" && \ | ||
docker push "$DOCKER_REPO" | ||
fi | ||
|
||
jobs: | ||
include: | ||
- stage: build | ||
name: "Build container images for x86_64" | ||
script: ./build_containers.sh | ||
|
||
- stage: test | ||
name: "Test generated images" | ||
script: ./test.sh | ||
|
||
- name: "Upload qemu binaries to Github Releases" | ||
stage: deploy | ||
deploy: | ||
skip_cleanup: true | ||
provider: releases | ||
api_key: | ||
secure: Q2ueVCN6jsXOn9iaf8ucAMWsLH+KkYrleSKRbMkJPu+qVacVcYFynm6yMwM63koVA8ADN80+yl7JUvqWx+MZLfCwR+/MRyGC2J0AlCDTBuvK55ETT4Kggtwb/2j6XrjQLlV+9Qkhb0JVpyO1475CjnoT9aOpWsHEHBymddQC13IQMn27XV1LJhunLw7+7Pqb73Yrml8PvnRLFqfqaaLZMoEUjbCjayjmgJY1HqUA2dtQBUnlASDLo3H6epJaDD8qpZTU4850I6TFwavSpRXq786+uqLWfXki0H9EJFkPMgEluul09BRXNS4RABC2darrIluQfK0EOS+acW4AHkTiM5s5YiT402WrD5VVjRCV0GoLrUjnnAFj+jm5fCXykSVJ04/tOMrTMnIgusmUYDRLJ9JUhFb6LS5pzg1ib9pfBmkUfRfEqymFfmsV32sZUyI3+C3NNjOuBiePtQ0gx3vzy1jWwqf5y4IlvMjYyQE11J0PZBjrcZWSXaFlQ34Wl7jZgr+WXJ3a717LX+TbpVjTAuJdPv4vTDJ755avOAM3IgGLFONg7x/5+yroe5dtnHsS5g2Gy8ZYF+Kb0I14x+8Hgi/jRxdF3cKvOoO8MvnK6zeDB4EDolWyTXHwfmpkJOtW+LbvJTJffg5bhoeevpJWaebJqzkusY3/nevG8FYAv2Y= | ||
file_glob: true | ||
file: releases/*.tgz | ||
on: | ||
repo: ${TRAVIS_REPO_SLUG} | ||
tags: true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#!/bin/bash -e | ||
set -xeo pipefail | ||
|
||
# | ||
## This script builds 3 types of Docker images (assuming version `VERSION`): | ||
# | ||
# 1. Image containing all qemu binaries. Built in `./containers/latest/`. Tagged with `:latest`, `:VERSION`, and `:vMAJOR.MINOR`. | ||
# 2. Register image. Built in `./containers/register/`. Tagged with `:register`, `:register-VERSION`, and `:register-vMAJOR.MINOR`. | ||
# 3. A series of images, each bundled with a single guest-architecture qemu binary. Built in `./containers/qemu-ARCH`. | ||
# Tagged with `:ARCH`, `:ARCH-VERSION`, and `:ARCH-vMAJOR.MINOR`. | ||
|
||
|
||
# Convert Travis-provided repo SLUG to lowercase - Docker's requirement for tags | ||
SLUG="$(echo "${TRAVIS_REPO_SLUG:-$DOCKER_REPO}" | tr '[:upper:]' '[:lower:]')" | ||
|
||
BUILD_DIR="containers" | ||
|
||
# list of all supported architectures for guest machines | ||
guest_architectures="aarch64 aarch64_be alpha armeb arm cris hppa i386 m68k microblazeel microblaze mips64el mips64 mipsel mipsn32el mipsn32 mips nios2 or1k ppc64abi32 ppc64le ppc64 ppc riscv32 riscv64 s390x sh4eb sh4 sparc32plus sparc64 sparc tilegx trace-stap xtensaeb xtensa" | ||
|
||
# NOTE: All qemu binaries have been downloaded, and unpacked to `./usr/bin/` in `before_script` already. | ||
|
||
## | ||
# Prepare & build image containing all qemu binaries (`:latest`) | ||
## | ||
cp -p ./usr/bin/qemu-*-static "${BUILD_DIR}/latest/" | ||
docker build -t "${SLUG}:latest" "${BUILD_DIR}/latest" | ||
|
||
|
||
## | ||
# Prepare & build register image (`:register`) | ||
## | ||
cp -p ${BUILD_DIR}/latest/{Dockerfile,register.sh} "${BUILD_DIR}/register/" | ||
|
||
# Register image does not need `qemu-*-static` binaries copied into it. This line removes the COPY directive from Dockerfile. | ||
sed -i '/^COPY qemu/ s/^/#/' "${BUILD_DIR}/register/Dockerfile" | ||
docker build -t "${SLUG}:register" "${BUILD_DIR}/register" | ||
|
||
|
||
## | ||
# Build images for individual target architectures (`:ARCH`) | ||
## | ||
for guest_arch in ${guest_architectures}; do | ||
work_dir="${BUILD_DIR}/qemu-single" | ||
|
||
mkdir -p "${work_dir}" | ||
|
||
# copy a single binary to the image | ||
cp -p "./usr/bin/qemu-${guest_arch}-static" "${work_dir}" | ||
|
||
# create a minimal `Dockerfile` that only copies that specific binary into the image | ||
cat > "${work_dir}/Dockerfile" -<<EOF | ||
FROM scratch | ||
COPY qemu-${guest_arch}-static /usr/bin/ | ||
EOF | ||
|
||
docker build -t "${SLUG}:${guest_arch}" "${work_dir}" | ||
|
||
# cleanup | ||
rm -rf "${work_dir}" | ||
done | ||
|
||
|
||
# If git tag is provided, tag all images with VERSION, and push them to Docker Hub | ||
if [[ -n "${TRAVIS_TAG}" ]]; then | ||
if [[ -z "${DOCKER_USER}" ]] || [[ -z "${DOCKER_PASS}" ]]; then | ||
echo "For deployment to Docker Hub to work both DOCKER_USER and DOCKER_PASS must be provided in Travis build settings." | ||
exit 1 | ||
fi | ||
|
||
# Login to Docker Hub | ||
echo "${DOCKER_PASSWORD}" | docker login -u="${DOCKER_USERNAME}" --password-stdin | ||
|
||
MINOR_TAG="$(echo "${TRAVIS_TAG}" | cut -d. -f1).$(echo "${TRAVIS_TAG}" | cut -d. -f2)" | ||
|
||
# Tag `:latest` with a specific qemu version, and push both | ||
docker tag "${SLUG}:latest" "${SLUG}:${TRAVIS_TAG}" | ||
docker tag "${SLUG}:latest" "${SLUG}:${MINOR_TAG}" | ||
docker push "${SLUG}:latest" | ||
docker push "${SLUG}:${TRAVIS_TAG}" | ||
docker push "${SLUG}:${MINOR_TAG}" | ||
|
||
# Tag `:register` with specific qemu version, and push both | ||
docker tag "${SLUG}:register" "${SLUG}:register-${TRAVIS_TAG}" | ||
docker tag "${SLUG}:register" "${SLUG}:register-${MINOR_TAG}" | ||
docker push "${SLUG}:register" | ||
docker push "${SLUG}:register-${TRAVIS_TAG}" | ||
docker push "${SLUG}:register-${MINOR_TAG}" | ||
|
||
# For each architecture, create a versioned tag, and push all | ||
for guest_arch in ${guest_architectures}; do | ||
docker tag "${SLUG}:${guest_arch}" "${SLUG}:${guest_arch}-${TRAVIS_TAG}" | ||
docker tag "${SLUG}:${guest_arch}" "${SLUG}:${guest_arch}-${MINOR_TAG}" | ||
|
||
docker push "${SLUG}:${guest_arch}" | ||
docker push "${SLUG}:${guest_arch}-${TRAVIS_TAG}" | ||
docker push "${SLUG}:${guest_arch}-${MINOR_TAG}" | ||
done | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
#!/bin/bash -e | ||
|
||
# | ||
## This script compresses all qemu binaries, and prepares them for upload to Github Release later in the deploy step. | ||
|
||
if [[ -z "${TRAVIS_TAG}" ]]; then | ||
echo "TRAVIS_TAG not specified. Skipping tarball generation." | ||
exit 0 | ||
fi | ||
|
||
rm -rf releases | ||
mkdir -p releases | ||
# find . -regex './qemu-.*' -not -regex './qemu-system-.*' -exec cp {} releases \; | ||
cp ./usr/bin/qemu-*-static releases/ | ||
cd releases/ | ||
for file in *; do | ||
tar -czf $file.tar.gz $file; | ||
cp $file.tar.gz x86_64_$file.tar.gz | ||
|
||
for file in ./usr/bin/qemu-*-static; do | ||
name="$(basename "${file}").tgz" | ||
tar -cvzf "releases/${TRAVIS_TAG}-${name}" "${file}" | ||
done |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove the lines? I added the lines referring
ruby/ruby
's.travis.yml
.https://github.com/ruby/ruby/blob/master/.travis.yml#L120
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My IDE says this property is not allowed there. I wasn't able to find any documentation about it. Everything worked well without it. I'm happy to add it back if it actually does something, or is useful :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please back it.
When "My IDE says this property is not allowed there", removing it is not good choice.
As you may know Travis is open source and written in Ruby language. In Ruby project, the core maintainers communicate with a core member on Travis project in Ruby project. As a result, the feature that is not documented, only existed in the source code can be used for Ruby project as a possibility. Ruby project uses
.travis.yml
with very advanced way.