From 0c2ccd8259de7f56374b78d3586e3a829be6e32f Mon Sep 17 00:00:00 2001 From: Joe Chen Date: Tue, 7 Mar 2023 22:31:54 +0800 Subject: [PATCH] ci: set up Goreleaser --- .github/workflows/release.yml | 28 ++++++++++++++++++++++++++++ .gitignore | 2 ++ .goreleaser.yaml | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7f6cde3 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,28 @@ +# Docs: https://goreleaser.com/ci/actions/ +name: Release +on: + release: + types: [ published ] + +permissions: + contents: 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@v3 + with: + go-version: '>=1.20.1' + cache: true + - uses: goreleaser/goreleaser-action@v4 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index a128c4d..6963d9c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ # production backend/embed/build bilibili-lottery + +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..c0e30bf --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,33 @@ +# Docs: https://goreleaser.com +builds: + - main: ./cmd + dir: ./backend + env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm64 +archives: + - format: tar.gz + wrap_in_directory: false + # this name template makes the OS and Arch compatible with the results of uname. + name_template: >- + {{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }} + # 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:'