From f139c99e7068e25ca585a2c95748b9aeec4e57ae Mon Sep 17 00:00:00 2001 From: Ilia Burakov Date: Fri, 22 Mar 2024 23:07:19 -0400 Subject: [PATCH] use new workflow --- .github/workflows/build.yml | 59 ++++++++++++++++++++++++------------- Dockerfile | 3 +- VersionInfo.Dockerfile | 9 ++++++ 3 files changed, 48 insertions(+), 23 deletions(-) create mode 100644 VersionInfo.Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 33f4739..d50910e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,34 +5,51 @@ on: branches: - master +env: + DOCKER_REGISTRY: magicxor + DOCKER_IMAGE: tor-simple + jobs: buildx: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: docker/login-action@v1 + - uses: actions/checkout@v4 + + - uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - id: build_args + + - id: get_build_info run: | - echo '::set-output name=BUILD_DATE::$(date +'%Y-%m-%dT%H:%M:%S')' - echo '::set-output name=VERSION::0.0.1' + docker build . --file=VersionInfo.Dockerfile --progress=plain --no-cache -t tor-version-info + package_versions=$(docker run --rm tor-version-info) + echo "PACKAGE_VERSIONS=$package_versions" >> $GITHUB_OUTPUT + echo "BUILD_DATE=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_OUTPUT + + # https://github.com/docker/setup-qemu-action + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + # https://github.com/docker/setup-buildx-action - name: Set up Docker Buildx - uses: crazy-max/ghaction-docker-buildx@v1 + uses: docker/setup-buildx-action@v3 + + # https://github.com/docker/build-push-action + - name: Build and push + uses: docker/build-push-action@v5 with: - buildx-version: latest - qemu-version: latest - - name: Run Buildx - run: | - DOCKER_IMAGE=magicxor/tor-simple - docker buildx create --use --name build --node build --driver-opt network=host - docker buildx build \ - --platform linux/amd64,linux/arm/v7,linux/arm64 \ - --output "type=image,push=true" \ - --tag ${DOCKER_IMAGE}:latest \ - --tag ${DOCKER_IMAGE}:${{ steps.build_args.outputs.VERSION }} \ - --build-arg VERSION=${{ steps.build_args.outputs.VERSION }} \ - --build-arg BUILD_DATE=${{ steps.build_args.outputs.BUILD_DATE }} \ - --build-arg VCS_REF=${GITHUB_SHA::8} \ - . + push: true + context: . + tags: | + ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }}:latest + ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }}:${{ steps.get_build_info.outputs.PACKAGE_VERSIONS }} + platforms: | + linux/amd64 + linux/arm/v7 + linux/arm64/v8 + build-args: | + VERSION=${{ steps.get_build_info.outputs.PACKAGE_VERSIONS }} + VCS_REF=${{ github.sha }} + BUILD_DATE=${{ steps.get_build_info.outputs.BUILD_DATE }} + BUILD_PLATFORM=${{ runner.os }}/${{ runner.arch }} diff --git a/Dockerfile b/Dockerfile index 4e5c39c..f861969 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,6 @@ FROM ubuntu:latest -ARG TARGETPLATFORM -ARG BUILDPLATFORM +ARG BUILD_PLATFORM ARG BUILD_DATE ARG VCS_REF ARG VERSION diff --git a/VersionInfo.Dockerfile b/VersionInfo.Dockerfile new file mode 100644 index 0000000..a787f0c --- /dev/null +++ b/VersionInfo.Dockerfile @@ -0,0 +1,9 @@ +FROM ubuntu:latest + +RUN apt-get update && \ + tor_version=$(apt-cache madison tor | awk '{print $3; exit}') && \ + obfs4proxy_version=$(apt-cache madison obfs4proxy | awk '{print $3; exit}') && \ + ubuntu_version=$(cat /etc/os-release | grep VERSION_ID | awk -F '"' '{print $2}') && \ + echo "${ubuntu_version}_${tor_version}_${obfs4proxy_version}" > /version.txt + +CMD cat /version.txt