From 8ac28ecc4aa50e546ea78e1c55ac59120b52c1a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ximo=20Cuadros?= Date: Thu, 19 Mar 2020 22:39:53 +0100 Subject: [PATCH] cd: release binaries --- .github/workflows/build.yml | 54 +++++++++++++------------------------ .github/workflows/test.yml | 1 + main.go | 25 +++++++++-------- 3 files changed, 34 insertions(+), 46 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2802213..071103e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,39 +1,23 @@ - -on: release -name: Build +on: + release: + types: [created] + +name: Release jobs: - release-linux-amd64: - name: Release linux/amd64 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - name: compile and release - uses: ngs/go-release.action@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GOARCH: amd64 - GOOS: linux - - release-darwin-amd64: - name: Release darwin/amd64 + release: + strategy: + fail-fast: false + matrix: + goos: [linux, windows, darwin] runs-on: ubuntu-latest steps: - - uses: actions/checkout@master - - name: compile and release - uses: ngs/go-release.action@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GOARCH: amd64 - GOOS: darwin + - name: Checkout code + uses: actions/checkout@v2 - release-windows-amd64: - name: Release windows/amd64 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - name: compile and release - uses: ngs/go-release.action@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GOARCH: amd64 - GOOS: windows \ No newline at end of file + - name: Release binaries + uses: mcuadros/go-release-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + goos: ${{ matrix.goos }} + goarch: amd64 + ldflags: -X main.commit=${{ github.sha }} -X main.version=${{ github.ref }} \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fb3e371..1395daf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,5 +16,6 @@ jobs: - name: Checkout code uses: actions/checkout@v2 + - name: Test run: go test ./... \ No newline at end of file diff --git a/main.go b/main.go index adc31d6..86792ce 100644 --- a/main.go +++ b/main.go @@ -19,9 +19,8 @@ import ( ) var ( - version = "undefined" - build = "undefined" - commit = "undefined" + version = "not-set" + commit = "not-set" ) func main() { @@ -146,17 +145,21 @@ func main() { fmt.Print(buf.String()) } +const usageFormat = `enry, a simple (and faster) implementation of github/linguist + +usage: %[1]s [-mode=(file|line|byte)] [-prog] + %[1]s [-mode=(file|line|byte)] [-prog] [-json] [-breakdown] + %[1]s [-mode=(file|line|byte)] [-prog] [-json] [-breakdown] + %[1]s [-version] + +build info: %[2]s, commit: %[3]s, based on linguist commit: %[4]s +` + func usage() { fmt.Fprintf( os.Stderr, - ` %[1]s %[2]s build: %[3]s commit: %[4]s, based on linguist commit: %[5]s - %[1]s, A simple (and faster) implementation of github/linguist - usage: %[1]s [-mode=(file|line|byte)] [-prog] - %[1]s [-mode=(file|line|byte)] [-prog] [-json] [-breakdown] - %[1]s [-mode=(file|line|byte)] [-prog] [-json] [-breakdown] - %[1]s [-version] -`, - os.Args[0], version, build, commit, data.LinguistCommit[:7], + usageFormat, + os.Args[0], version, commit[:7], data.LinguistCommit[:7], ) }