diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 720afb4..e6e6ce7 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -1,39 +1,51 @@ name: actions -on: push +on: + push: + branches: + - master + paths: + - containers/** + - .github/workflows/actions.yml + - "*.sh" + pull_request: + branches: + - master + paths: + - containers/** + - .github/workflows/actions.yml + - "*.sh" jobs: qemu-user-static: runs-on: ubuntu-latest + env: + VERSION: 5.2.0-11 + ORIGIN_VERSION: 5.2+dfsg-11 steps: - uses: actions/checkout@v2 - name: Set variables run: | - echo "VERSION=${VERSION}" >> $GITHUB_ENV - echo "ORIGIN_VERSION=${ORIGIN_VERSION}" >> $GITHUB_ENV - echo "DOCKER_REPO=${DOCKER_REPO}/$GITHUB_REPOSITORY" >> $GITHUB_ENV - env: - VERSION: 5.2.0-2 - ORIGIN_VERSION: 5.2+dfsg-3 - DOCKER_REPO: docker.io - - name: Build releases + echo "DOCKER_REPO=docker.io/$GITHUB_REPOSITORY" >> $GITHUB_ENV + - name: Build run: | - wget --content-disposition http://ftp.de.debian.org/debian/pool/main/q/qemu/qemu-user-static_${ORIGIN_VERSION}_amd64.deb - dpkg-deb -R qemu-user-static_*.deb . - ./generate_tarballs.sh - - name: Publish releases - if: github.ref == 'refs/heads/master' - run: | - sudo apt install jq - ./publish.sh -v "$VERSION" -t ${{ secrets.GITHUB_TOKEN }} -r "$GITHUB_REPOSITORY" - - name: Build images - if: github.ref == 'refs/heads/master' - run: | - ./update.sh -v "$VERSION" -t "$VERSION" -r "$GITHUB_REPOSITORY" -d "$DOCKER_REPO" - - name: Test images - run: | - docker images - ./test.sh -d "$DOCKER_REPO" - - name: Publish images + wget --content-disposition http://ftp.de.debian.org/debian/pool/main/q/qemu/qemu-user-static_${{ env.ORIGIN_VERSION }}_amd64.deb + dpkg-deb -R qemu-user-static_*.deb releases + ./run.sh -t "${{ env.VERSION }}" -r "${{ env.GITHUB_REPOSITORY }}" -d "${{ env.DOCKER_REPO }}" + - name: Test + run: ./test.sh -d "${{ env.DOCKER_REPO }}" + - name: Publish if: github.ref == 'refs/heads/master' run: | docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_TOKEN }} - docker push $DOCKER_REPO + docker push ${{ env.DOCKER_REPO }} + - name: Create Release + if: github.ref == 'refs/heads/master' + uses: ncipollo/release-action@v1 + with: + name: "v${{ env.VERSION }}" + tag: "v${{ env.VERSION }}" + body: | + # `qemu-*-static` @ ${{ env.VERSION }} + artifacts: "releases/usr/bin/*.tar.gz" + draft: false + prerelease: false + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/containers/latest/Dockerfile b/containers/latest/Dockerfile index ae39263..6fa177a 100644 --- a/containers/latest/Dockerfile +++ b/containers/latest/Dockerfile @@ -1,7 +1,7 @@ FROM busybox ENV QEMU_BIN_DIR=/usr/bin ADD ./register.sh /register -ADD https://raw.githubusercontent.com/qemu/qemu/master/scripts/qemu-binfmt-conf.sh /qemu-binfmt-conf.sh +ADD https://raw.githubusercontent.com/qemu/qemu/7c81570d932268a9626457a662f1c5046ebc455e/scripts/qemu-binfmt-conf.sh /qemu-binfmt-conf.sh RUN chmod +x /qemu-binfmt-conf.sh COPY qemu-*-static /usr/bin/ ENTRYPOINT ["/register"] diff --git a/generate_tarballs.sh b/generate_tarballs.sh deleted file mode 100755 index eee894b..0000000 --- a/generate_tarballs.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -e - -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 -done diff --git a/publish.sh b/publish.sh deleted file mode 100755 index 3dd34ae..0000000 --- a/publish.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -e - -# A POSIX variable -OPTIND=1 # Reset in case getopts has been used previously in the shell. - -while getopts "v:t:r:" opt; do - case "$opt" in - v) VERSION=$OPTARG - ;; - t) GITHUB_TOKEN=$OPTARG - ;; - r) REPO=$OPTARG - ;; - esac -done - -shift $((OPTIND-1)) - -[ "$1" = "--" ] && shift - -# create a release -release_id=$(curl -sL -X POST \ - -H "Content-Type: application/json" \ - -H "Accept: application/vnd.github.v3+json" \ - -H "Authorization: token ${GITHUB_TOKEN}" \ - -H "Cache-Control: no-cache" -d "{ - \"tag_name\": \"v${VERSION}\", - \"target_commitish\": \"master\", - \"name\": \"v${VERSION}\", - \"body\": \"# \`qemu-*-static\` @ ${VERSION}\", - \"draft\": false, - \"prerelease\": false -}" "https://api.github.com/repos/${REPO}/releases" | jq -r ".id") -if [ "$release_id" = "null" ]; then - # get the existing release id - release_id=$(set -x; curl -sL \ - -H "Content-Type: application/json" \ - -H "Accept: application/vnd.github.v3+json" \ - -H "Authorization: token ${GITHUB_TOKEN}" \ - -H "Cache-Control: no-cache" \ - "https://api.github.com/repos/${REPO}/releases" | jq -r --arg version "${VERSION}" '.[] | select(.name == "v"+$version).id') -fi - -cd releases/ -for file in *; do - content_type=$(file --mime-type -b ${file}) - curl -sL \ - -H "Authorization: token ${GITHUB_TOKEN}" \ - -H "Content-Type: ${content_type}" \ - --upload-file ${file} \ - "https://uploads.github.com/repos/${REPO}/releases/${release_id}/assets?name=${file}" -done diff --git a/update.sh b/run.sh similarity index 65% rename from update.sh rename to run.sh index d72f7ca..aecc387 100755 --- a/update.sh +++ b/run.sh @@ -4,12 +4,10 @@ set -xe # A POSIX variable OPTIND=1 # Reset in case getopts has been used previously in the shell. -while getopts "r:v:t:d:" opt; do +while getopts "r:t:d:" opt; do case "$opt" in r) REPO=$OPTARG ;; - v) VERSION=$OPTARG - ;; t) TAG_VER=$OPTARG ;; d) DOCKER_REPO=$OPTARG @@ -17,20 +15,20 @@ while getopts "r:v:t:d:" opt; do esac done -if [ -z "$VERSION" ]; then - echo "usage: $0 -v VERSION" 2>&1 - echo "check https://github.com/${REPO}/releases for available versions" 2>&1 - exit 1 -fi - shift $((OPTIND-1)) [ "$1" = "--" ] && shift +base_path=$(pwd) +cd releases/usr/bin/ +for file in *; do + tar -czf $file.tar.gz $file; + mv $file.tar.gz x86_64_$file.tar.gz +done +cd ${base_path} + from_arch="x86_64" to_archs="aarch64 aarch64_be alpha arm armeb cris hppa i386 m68k microblaze microblazeel mips mips64 mips64el mipsel mipsn32 mipsn32el nios2 or1k ppc ppc64 ppc64le riscv32 riscv64 s390x sh4 sh4eb sparc sparc32plus sparc64 x86_64 xtensa xtensaeb" -# For casual test -# to_archs="aarch64" # Build container images creating the directory. # containers/ @@ -49,18 +47,8 @@ for to_arch in $to_archs; do if [ "$from_arch" != "$to_arch" ]; then work_dir="${out_dir}/${from_arch}_qemu-${to_arch}" mkdir -p "${work_dir}" - tar_gz_url="https://github.com/${REPO}/releases/download/v${VERSION}/${from_arch}_qemu-${to_arch}-static.tar.gz" - http_status="$(curl -s -o /dev/null -w "%{http_code}" "${tar_gz_url}")" - if [ "${http_status}" = 404 ]; then - echo "URL not found: ${tar_gz_url}" 1>&2 - exit 1 - fi - curl -sSL -o "${work_dir}/${from_arch}_qemu-${to_arch}-static.tar.gz" "${tar_gz_url}" - tar xzvf "${work_dir}/${from_arch}_qemu-${to_arch}-static.tar.gz" -C "${work_dir}" - rm -f "${work_dir}/${from_arch}_qemu-${to_arch}-static.tar.gz" - + cp -p "releases/usr/bin/qemu-${to_arch}-static" ${work_dir} cp -p "${work_dir}/qemu-${to_arch}-static" "${out_dir}/latest/" - cat > ${work_dir}/Dockerfile -<