From 04c255ff6e1365e5ad2d9589068421f5047fe9a5 Mon Sep 17 00:00:00 2001 From: alex-voigt Date: Thu, 27 Jun 2024 08:51:26 +0200 Subject: [PATCH] chore: add build steps for ARM architecture (#42) --- .github/Dockerfile | 2 +- .github/workflows/build.yml | 51 +++++++++++++++++++------------------ 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/.github/Dockerfile b/.github/Dockerfile index 01d45f4..213da4b 100644 --- a/.github/Dockerfile +++ b/.github/Dockerfile @@ -4,4 +4,4 @@ RUN apk add --no-cache \ ttf-freefont \ inotify-tools \ tini -COPY build-artifacts/vistecture-linux /usr/local/bin/vistecture +COPY build-artifacts/vistecture-linux-$TARGETARCH /usr/local/bin/vistecture diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a0b95e4..7c21a3a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,9 +59,10 @@ jobs: - uses: actions/setup-go@v2 with: go-version: '^1.17.x' - - run: GOOS=linux GOARCH=amd64 go build -o build-artifacts/vistecture-linux vistecture.go + - run: GOOS=linux GOARCH=amd64 go build -o build-artifacts/vistecture-linux-amd64 vistecture.go + - run: GOOS=linux GOARCH=arm64 go build -o build-artifacts/vistecture-linux-arm64 vistecture.go - run: GOOS=windows go build -o build-artifacts/vistecture.exe vistecture.go - - uses: actions/upload-artifact@master + - uses: actions/upload-artifact@v4 with: name: binaries path: build-artifacts/vistecture* @@ -81,7 +82,7 @@ jobs: draft: false prerelease: false - name: Download go-binary artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: binaries path: ./ @@ -96,47 +97,47 @@ jobs: asset_name: vistecture.exe asset_content_type: application/octet-stream - name: Upload vistecture linux asset - id: upload-linux-asset + id: upload-linux-asset-amd64 uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./vistecture-linux + asset_path: ./vistecture-linux-amd64 asset_name: vistecture-amd64 asset_content_type: application/octet-stream + - name: Upload vistecture linux asset + id: upload-linux-asset-arm64 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./vistecture-linux-arm64 + asset_name: vistecture-arm64 + asset_content_type: application/octet-stream docker: - if: startsWith(github.ref, 'refs/tags/ggadfgv') + if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest needs: [ go-binaries ] steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - name: Download go-binary artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: binaries path: build-artifacts - - - name: Cache Docker layers - uses: actions/cache@v2 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - - name: Login to DockerHub + - name: Login to DockerHub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build - uses: docker/build-push-action@v2 + - name: Build + uses: docker/build-push-action@v6 with: push: true - tags: | - aoepeople/vistecture:${{ github.ref }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + tags: aoepeople/vistecture:${{ github.ref }} + platforms: linux/amd64,linux/arm64