From 5f62352ceec3ba6a9bd1415a9a7cd22d8c10c9b8 Mon Sep 17 00:00:00 2001 From: Akram Ben Aissi Date: Tue, 28 Sep 2021 15:36:56 +0000 Subject: [PATCH] Release workflow for shp CLI - Use gorelease to create binaries for windows, linux, and macOS on amd64 and arm64. - Run workflow whenever a semantic version tag is created. - Binary is named `shp` and optimized for space efficiency. Co-authored-by: Akram Ben Aissi Co-authored-by: Matthias Diester Co-authored-by: Sascha Schwarze --- .github/workflows/release.yml | 26 ++++++++++++++++++++++++++ .gitignore | 1 + .goreleaser.yml | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..ac7f10974 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,26 @@ +--- +name: Release +on: + push: + tags: + - 'v*' +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.17.x + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index fa2738b9f..1140f652b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ _output/ /shp /shp-* /bin/* +dist/ diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 000000000..c36502df2 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,33 @@ +before: + hooks: + - go generate ./... +builds: +- env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + - windows + goarch: + - amd64 + - arm64 + flags: + - -trimpath + ldflags: + - -s -w -extldflags "-static" + main: ./cmd/shp/main.go + binary: shp +archives: +- replacements: + darwin: macOS + amd64: x86_64 +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ incpatch .Version }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:'