From a6d2bb055aa365df54ad168e8d8970866a7e3f10 Mon Sep 17 00:00:00 2001 From: cdryzun Date: Sat, 23 Sep 2023 18:47:57 +0800 Subject: [PATCH] feat: add goreleaser --- .gitea/workflows/release.yml | 18 ++++++++++++++++++ Taskfile.yaml | 16 +++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 .gitea/workflows/release.yml diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..d0d98bf --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,18 @@ +name: Release +on: + push: + tags: + - v* + +jobs: + release: + runs-on: [ubuntu-latest] + steps: + - uses: actions/setup-go@v3 + with: { go-version: 1.20 } + - run: go install github.com/go-task/task/v3/cmd/task@latest + - run: apt update && apt-get install zip + - uses: actions/checkout@v3 + - run: task deps + - run: git reset --hard + - run: GORELEASER_FORCE_TOKEN=gitea GITEA_TOKEN=${{ secrets.GE_TOKEN }} task release:prod \ No newline at end of file diff --git a/Taskfile.yaml b/Taskfile.yaml index 78e6082..c4b0ecf 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -16,6 +16,17 @@ tasks: desc: Install all dependencies (except dredd requirements) cmds: - task: deps:be + - task: deps:tools + + deps:tools: + desc: Installs tools needed for building + vars: + GORELEASER_VERSION: "1.19.2" + cmds: + - '{{ if ne OS "windows" }} sh -c "curl -L https://github.com/goreleaser/goreleaser/releases/download/v{{ .GORELEASER_VERSION }}/goreleaser_$(uname -s)_$(uname -m).tar.gz | tar -xz -C $(go env GOPATH)/bin goreleaser"{{ else }} {{ end }}' + - '{{ if ne OS "windows" }} chmod +x $(go env GOPATH)/bin/goreleaser{{ else }} {{ end }}' + - '{{ if eq OS "windows" }} echo "NOTICE: You must download goreleaser manually to build this application https://github.com/goreleaser/goreleaser/releases "{{ else }}:{{ end }}' + - '{{ if eq OS "windows" }} echo "NOTICE: You need to install golangci-lint manually to build this application https://github.com/golangci/golangci-lint#install"{{ else }}{{ end }}' deps:be: desc: application dependencies cmds: @@ -24,4 +35,7 @@ tasks: desc: Build a binary for the current architecture platforms: [amd64] cmds: - - env CGO_ENABLED=0 GOOS={{ .GOOS }} GOARCH={{ .GOARCH }} go build -o ./bin/{{.PROJECT_NAME}}{{ if eq OS "windows" }}.exe{{ end }} \ No newline at end of file + - env CGO_ENABLED=0 GOOS={{ .GOOS }} GOARCH={{ .GOARCH }} go build -o ./bin/{{.PROJECT_NAME}}{{ if eq OS "windows" }}.exe{{ end }} + release:prod: + cmds: + - goreleaser \ No newline at end of file