Skip to content

Commit

Permalink
tests: check that binary builds correctly and respect go version from…
Browse files Browse the repository at this point in the history
… go.mod
  • Loading branch information
josegonzalez committed Jun 29, 2024
1 parent 0428ab5 commit cb754f7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,34 @@ jobs:
rm .env.docker
make .env.docker release-in-docker release-packagecloud-in-docker
fi
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
pkg: cmd
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
4 changes: 3 additions & 1 deletion .github/workflows/tagged-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ jobs:
run: |
echo "REPOSITORY_NAME=$(echo "${{ github.repository }}" | cut -d '/' -f 2)" >> $GITHUB_OUTPUT
echo "REPOSITORY_SLUG=$(echo "${{ github.repository }}" | sed 's#/#-#')" >> $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
pkg: cmd
prefix: ${{ steps.repo-name.outputs.REPOSITORY_NAME }}
targets: darwin/amd64,darwin/arm64,linux/arm64,linux/amd64
v: true
Expand Down

0 comments on commit cb754f7

Please sign in to comment.