diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 87477af..672e0e8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/.github/workflows/tagged-release.yml b/.github/workflows/tagged-release.yml index 5787f53..a00d6d6 100644 --- a/.github/workflows/tagged-release.yml +++ b/.github/workflows/tagged-release.yml @@ -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 diff --git a/cmd/sigil.go b/cmd/sigil.go index 3be7404..a5d6a71 100644 --- a/cmd/sigil.go +++ b/cmd/sigil.go @@ -1,7 +1,6 @@ package main import ( - "flag" "fmt" "io" "os" @@ -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) { diff --git a/go.mod b/go.mod index 5864b95..f57edf5 100644 --- a/go.mod +++ b/go.mod @@ -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 ) diff --git a/go.sum b/go.sum index e13030f..52cf7f6 100644 --- a/go.sum +++ b/go.sum @@ -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=