From 62ff6b5446e04b5fc43c1abc45b7eaa62f4f92c8 Mon Sep 17 00:00:00 2001 From: Choko Date: Fri, 5 Aug 2022 15:08:41 +0900 Subject: [PATCH 1/3] Add binary release workflow --- .github/workflows/build.yml | 1 + .github/workflows/release.yml | 22 ++++++++++++++++++++++ .goreleaser.yaml | 27 +++++++++++++++++++++++++++ magefiles/magefile.go | 8 ++++++++ magefiles/versions.go | 1 + 5 files changed, 59 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cdaf4b6..4f8458f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,3 +36,4 @@ jobs: skip-pkg-cache: true skip-build-cache: true - run: go run mage.go test + - run: go run mage.go snapshot diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c139617 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,22 @@ +name: "Release" + +on: + push: + tags: + - v* + +jobs: + build: + name: Release + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-go@v3 + with: + go-version: '^1.18.4' + cache: true + - run: go run mage.go release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..25f2dc0 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,27 @@ +builds: + - main: ./cmd + env: + - CGO_ENABLED=0 + targets: + - linux_amd64 + - linux_arm64 + - darwin_amd64 + - darwin_arm64 + - windows_amd64 + - windows_arm64 +archives: + - format_overrides: + - goos: windows + format: zip +release: + mode: append +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ incpatch .Version }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' diff --git a/magefiles/magefile.go b/magefiles/magefile.go index f54134a..585547c 100644 --- a/magefiles/magefile.go +++ b/magefiles/magefile.go @@ -6,6 +6,14 @@ import ( "github.com/magefile/mage/sh" ) +func Snapshot() error { + return sh.RunV("go", "run", fmt.Sprintf("github.com/goreleaser/goreleaser@%s", goReleaserVer), "release", "--snapshot", "--rm-dist") +} + +func Release() error { + return sh.RunV("go", "run", fmt.Sprintf("github.com/goreleaser/goreleaser@%s", goReleaserVer), "release", "--rm-dist") +} + func Build() error { return sh.Run("go", "build", "-o", "build/reassign", "./cmd") } diff --git a/magefiles/versions.go b/magefiles/versions.go index 414120c..d348b78 100644 --- a/magefiles/versions.go +++ b/magefiles/versions.go @@ -1,4 +1,5 @@ package main var golangCILintVer = "v1.48.0" +var goReleaserVer = "v1.10.3" var gosImportsVer = "v0.1.5" From e5a1f9979e1b9a6c0ce3a2608195dde6dab1633a Mon Sep 17 00:00:00 2001 From: Choko Date: Fri, 5 Aug 2022 15:09:55 +0900 Subject: [PATCH 2/3] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5ad2688..59fa336 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ .envrc build +dist From 390ac3b18e1fa874c8eef610b10d5527816dd42c Mon Sep 17 00:00:00 2001 From: Choko Date: Fri, 5 Aug 2022 15:11:46 +0900 Subject: [PATCH 3/3] Only snapshot on ubuntu --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4f8458f..58ff86d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,3 +37,4 @@ jobs: skip-build-cache: true - run: go run mage.go test - run: go run mage.go snapshot + if: ${{ matrix.os }} == 'ubuntu-22.04'