From ebe2885513b36b6b57d866128a8ba5c54a2a9c7f Mon Sep 17 00:00:00 2001 From: ch4r10t33r Date: Thu, 13 Nov 2025 11:57:52 +0000 Subject: [PATCH] fix: removed multi-arch docker build and quickened the process --- .github/workflows/docker-publish.yml | 54 ++++++++++++++++++---------- .github/workflows/release.yml | 49 ------------------------- 2 files changed, 36 insertions(+), 67 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 6f11b69..e75e96b 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,29 +1,47 @@ -name: Build Relayx Docker image +name: Build and Publish Relayx Docker Image on: push: branches: - - "master" + - master + - main tags: - "v*" + release: + types: [published] + +permissions: + contents: write + +env: + DOCKER_BUILDKIT: 1 + IMAGE_NAME: etherspot/relayx jobs: build-and-push-relayx: runs-on: ubuntu-latest steps: - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + - name: Checkout code + uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Checkout code - uses: actions/checkout@v4 - - - name: Get version from Cargo.toml - id: get_version + - name: Determine version + id: version run: | - VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/') + if [[ "${{ github.ref }}" == refs/tags/* ]]; then + # Extract version from git tag (remove 'v' prefix if present) + VERSION=${GITHUB_REF#refs/tags/} + VERSION=${VERSION#v} + elif [[ "${{ github.event_name }}" == "release" ]]; then + # Use release tag name + VERSION=${GITHUB_REF#refs/tags/} + VERSION=${VERSION#v} + else + # Fallback to Cargo.toml version + VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/') + fi echo "version=${VERSION}" >> $GITHUB_OUTPUT echo "Version: ${VERSION}" @@ -33,24 +51,24 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push Relayx Docker image + - name: Build and push Docker image uses: docker/build-push-action@v6 with: context: . file: ./Dockerfile push: true tags: | - etherspot/relayx:${{ steps.get_version.outputs.version }} - etherspot/relayx:latest - platforms: linux/amd64,linux/arm64 + ${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }} + ${{ env.IMAGE_NAME }}:latest + platforms: linux/amd64 cache-from: type=gha cache-to: type=gha,mode=max - name: Create GitHub release - if: startsWith(github.ref, 'refs/tags/') - uses: "marvinpinto/action-automatic-releases@6273874b61ebc8c71f1a61b2d98e234cf389b303" + if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'push' + uses: "marvinpinto/action-automatic-releases@latest" with: repo_token: "${{ secrets.GITHUB_TOKEN }}" - automatic_release_tag: ${{ steps.get_version.outputs.version }} + automatic_release_tag: ${{ steps.version.outputs.version }} prerelease: false - title: Relayx ${{ steps.get_version.outputs.version }} + title: Relayx ${{ steps.version.outputs.version }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 1cc1683..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Release - -on: - release: - types: [published] - -permissions: - contents: read - -jobs: - docker-release: - runs-on: ubuntu-latest - env: - IMAGE_NAME: relayx - DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - DOCKER_BUILDKIT: 1 - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ env.DOCKERHUB_USERNAME }} - password: ${{ env.DOCKERHUB_TOKEN }} - - - name: Determine tags - id: meta - run: | - VERSION_TAG=${GITHUB_REF#refs/tags/} - echo "version=$VERSION_TAG" >> $GITHUB_OUTPUT - - - name: Build and push Docker image - uses: docker/build-push-action@v6 - with: - context: . - file: ./Dockerfile - push: true - tags: | - ${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }} - ${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest - cache-from: type=gha - cache-to: type=gha,mode=max - platforms: linux/amd64