Skip to content

Commit

Permalink
use new workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
magicxor committed Mar 23, 2024
1 parent 7921e63 commit f139c99
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 23 deletions.
59 changes: 38 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
FROM ubuntu:latest

ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG BUILD_PLATFORM
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
Expand Down
9 changes: 9 additions & 0 deletions VersionInfo.Dockerfile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f139c99

Please sign in to comment.