From 448714a7802b3249c4af1d035ea909a5d17279bf Mon Sep 17 00:00:00 2001 From: Robert DeRose Date: Thu, 26 Dec 2024 11:39:49 -0500 Subject: [PATCH] Add more binaries and release them all This also corrects the fact that the current workflow overwrites the arm64 build --- .github/workflows/release.yml | 71 +++++++++++++++-------------------- 1 file changed, 30 insertions(+), 41 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a7a23586..b25b4373 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,57 +1,46 @@ name: Release on: - release: - types: [published] + push: + tags: + - v* jobs: build: name: Build release binaries runs-on: ubuntu-latest + steps: - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: Set up Go 1.x - uses: actions/setup-go@v2 - with: - go-version: ^1.13 - id: go - - - name: Build AMD64 - run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -installsuffix nocgo -v -o traefik-forward-auth_amd64 ./cmd - - - name: Build ARM - run: CGO_ENABLED=0 GOOS=linux GOARCH=arm GO111MODULE=on go build -a -installsuffix nocgo -v -o traefik-forward-auth_arm ./cmd + uses: actions/checkout@v4 - - name: Get tag name - run: echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - - name: Get artifact details - uses: octokit/request-action@v2.x - id: get_release_details + - name: Setup Go + uses: actions/setup-go@v5 with: - route: get /repos/${{ github.repository }}/releases/tags/${{ env.TAG }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + go-version-file: go.mod - - name: Upload AMD64 release asset - uses: actions/upload-release-asset@v1 + - name: Build Binaries env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ fromJson(steps.get_release_details.outputs.data).upload_url }} - asset_path: traefik-forward-auth_amd64 - asset_name: traefik-forward-auth_amd64 - asset_content_type: application/octet-stream - - - name: Upload ARM release asset - uses: actions/upload-release-asset@v1 + CGO_ENABLED: 0 + GO111MODULE: on + run: | + platforms=(linux windows darwin) + architectures=(amd64 arm64 arm) + + for platform in "${platforms[@]}"; do + for arch in "${architectures[@]}"; do + [[ ("${platform}" == "windows" || "${platform}" == "darwin") && "${arch}" == "arm" ]] && continue + + echo "Building Traefik-Forward-Auth for ${platform}-${arch}" + GOOS="${platform}" GOARCH="${arch}" go build -a -installsuffix nocgo -o traefik-forward-auth ./cmd + tar cJvf "traefik-forward-auth_${platform}_${arch}.tar.xz" traefik-forward-auth + rm traefik-forward-auth + done + done + + - name: Upload Assets env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ fromJson(steps.get_release_details.outputs.data).upload_url }} - asset_path: traefik-forward-auth_arm - asset_name: traefik-forward-auth_arm - asset_content_type: application/octet-stream + GH_TOKEN: ${{ github.token }} + run: | + gh release upload ${GITHUB_REF_NAME} *.tar.xz