From 8a53ac6abd29d450775935af85d053a8ad60243b Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 29 Jun 2024 00:25:45 -0400 Subject: [PATCH] tests: check that binary builds correctly and respect go version from go.mod --- .github/workflows/ci.yml | 30 ++++++++++++++++++++++++++++ .github/workflows/tagged-release.yml | 3 ++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 75f5291..d81ad3f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,3 +32,33 @@ jobs: with: name: build path: build/**/* + + binary-check: + name: binary-check + runs-on: ubuntu-22.04 + needs: build + steps: + - uses: actions/checkout@v4 + - name: Get Repository Name + id: repo-name + run: | + echo "REPOSITORY_NAME=$(echo "${{ github.repository }}" | cut -d '/' -f 2)" >> $GITHUB_OUTPUT + echo "TARGET_ARCHITECTURE=$(dpkg --print-architecture)" >> $GITHUB_OUTPUT + echo "GO_VERSION=$(go mod edit -json | jq -r .Go)" >> $GITHUB_OUTPUT + - name: Build binaries + uses: crazy-max/ghaction-xgo@v3 + with: + xgo_version: latest + go_version: "${{ steps.repo-name.outputs.GO_VERSION }}" + dest: dist + prefix: ${{ steps.repo-name.outputs.REPOSITORY_NAME }} + targets: linux/${{ steps.repo-name.outputs.TARGET_ARCHITECTURE }} + v: true + x: false + race: false + ldflags: -s -w -X main.Version=${{ github.ref_name }} + buildmode: default + trimpath: true + - name: Check version + run: | + "dist/${{ steps.repo-name.outputs.REPOSITORY_NAME }}-linux-${{ steps.repo-name.outputs.TARGET_ARCHITECTURE }}" --version diff --git a/.github/workflows/tagged-release.yml b/.github/workflows/tagged-release.yml index 553a7fc..695e10e 100644 --- a/.github/workflows/tagged-release.yml +++ b/.github/workflows/tagged-release.yml @@ -34,12 +34,13 @@ jobs: id: repo-name run: | echo "REPOSITORY_NAME=$(echo "${{ github.repository }}" | cut -d '/' -f 2)" >> $GITHUB_OUTPUT + echo "GO_VERSION=$(go mod edit -json | jq -r .Go)" >> $GITHUB_OUTPUT - name: Build binaries uses: crazy-max/ghaction-xgo@v3 with: xgo_version: latest - go_version: 1.22 + go_version: "${{ steps.repo-name.outputs.GO_VERSION }}" dest: dist prefix: ${{ steps.repo-name.outputs.REPOSITORY_NAME }} targets: darwin/amd64,darwin/arm64,linux/arm64,linux/amd64,windows/amd64