Skip to content

Commit

Permalink
Merge pull request #129 from gliderlabs/binary-check
Browse files Browse the repository at this point in the history
tests: check that binary builds correctly and respect go version from go.mod
  • Loading branch information
josegonzalez authored Jun 29, 2024
2 parents 4b58e8f + bc62cc9 commit 60dc048
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 6 deletions.
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
10 changes: 5 additions & 5 deletions cmd/sigil.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"flag"
"fmt"
"io"
"os"
Expand All @@ -10,15 +9,16 @@ import (

"github.com/gliderlabs/sigil"
_ "github.com/gliderlabs/sigil/builtin"
flag "github.com/spf13/pflag"
)

var Version string

var (
filename = flag.String("f", "", "use template file instead of STDIN")
inline = flag.String("i", "", "use inline template string instead of STDIN")
posix = flag.Bool("p", false, "preprocess with POSIX variable expansion")
version = flag.Bool("v", false, "prints version")
filename = flag.StringP("filename", "f", "", "use template file instead of STDIN")
inline = flag.StringP("inline", "i", "", "use inline template string instead of STDIN")
posix = flag.BoolP("posix", "p", false, "preprocess with POSIX variable expansion")
version = flag.BoolP("version", "v", false, "prints version")
)

func template() ([]byte, string, error) {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568
github.com/jmespath/go-jmespath v0.4.0
github.com/mgood/go-posix v0.0.0-20150821180505-948c005421f5
github.com/spf13/pflag v1.0.5
gopkg.in/yaml.v2 v2.4.0
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ github.com/mgood/go-posix v0.0.0-20150821180505-948c005421f5 h1:AutzcJSqc7ROMqcj
github.com/mgood/go-posix v0.0.0-20150821180505-948c005421f5/go.mod h1:irVTeKOI2GrudEK6/mqR4dDlGH91lCZIZM34YKSKH7M=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down

0 comments on commit 60dc048

Please sign in to comment.