From 473ff0f4d50a0a4e1ac8c5709ba4e8af042280db Mon Sep 17 00:00:00 2001 From: Ben McClelland Date: Thu, 7 Sep 2023 21:30:41 -0700 Subject: [PATCH] feat: setup goreleaser to manage release artifacts when tagged --- .github/workflows/goreleaser.yml | 31 ++++++++++++++++++++ .gitignore | 2 ++ .goreleaser.yaml | 50 ++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 .github/workflows/goreleaser.yml create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml new file mode 100644 index 0000000..3afd70c --- /dev/null +++ b/.github/workflows/goreleaser.yml @@ -0,0 +1,31 @@ +name: goreleaser + +on: + push: + # run only against tags + tags: + - '*' + +permissions: + contents: write + # packages: write + # issues: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - run: git fetch --force --tags + - uses: actions/setup-go@v4 + with: + go-version: stable + - uses: goreleaser/goreleaser-action@v4 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.TOKEN }} diff --git a/.gitignore b/.gitignore index 09d1f02..a15f58d 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,5 @@ VERSION *.tar.gz **/rand.data /profile.txt + +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..9745724 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,50 @@ +before: + hooks: + - go mod tidy + +builds: + - goos: + - linux + - darwin + # windows is untested, we can start doing windows releases + # if someone is interested in taking on testing + # - windows + main: ./cmd/versitygw + binary: ./cmd/versitygw + id: versitygw + goarch: + - amd64 + - arm64 + ldflags: + - -X=main.Build={{.Commit}} -X=main.BuildTime={{.Date}} -X=main.Version={{.Version}} + +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of uname. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip + +checksum: + name_template: 'checksums.txt' + +snapshot: + name_template: "{{ incpatch .Version }}-next" + +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' + +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj