From e71df48e81d3c979b6f000f6e85dd789ac5b8274 Mon Sep 17 00:00:00 2001 From: Xinzhao Xu Date: Mon, 9 Oct 2023 15:15:46 +0800 Subject: [PATCH] Add goreleaser action --- .github/workflows/goreleaser.yml | 27 +++++++++++++++++++++++++++ .goreleaser.yml | 21 +++------------------ app/app.go | 10 +++++----- 3 files changed, 35 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/goreleaser.yml diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml new file mode 100644 index 000000000..4165aa6b9 --- /dev/null +++ b/.github/workflows/goreleaser.yml @@ -0,0 +1,27 @@ +name: goreleaser +on: + push: + tags: + - '*' +permissions: + contents: write +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.21 + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v4 + with: + distribution: goreleaser + version: ${{ env.GITHUB_REF_NAME }} + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GORELEASER_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml index 2ca048451..4ad2fd231 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,13 +1,13 @@ project_name: lux env: - GO111MODULE=on + - CGO_ENABLED=0 before: hooks: - go mod download builds: -- env: - - CGO_ENABLED=0 - binary: lux +- binary: lux + ldflags: -s -w -X github.com/iawia002/lux/app.version={{ .RawVersion }} goos: - windows - darwin @@ -29,17 +29,6 @@ builds: - goos: openbsd goarch: arm goarm: 6 -env_files: - github_token: ./github_token -changelog: - sort: asc - use: github - filters: - exclude: - - '^docs' - - '^tests' - - Merge pull request - - Merge branch archives: - name_template: >- {{ .ProjectName }}_ @@ -56,7 +45,3 @@ archives: files: - none* wrap_in_directory: false -release: - draft: true - footer: | - **Full Changelog**: https://github.com/iawia002/lux/compare/{{ .PreviousTag }}...{{ .Tag }} diff --git a/app/app.go b/app/app.go index c01dfb10f..05167995f 100644 --- a/app/app.go +++ b/app/app.go @@ -17,11 +17,11 @@ import ( "github.com/iawia002/lux/utils" ) -const ( - // Name is the name of this app. - Name = "lux" - version = "v0.20.0" -) +// Name is the name of this app. +const Name = "lux" + +// This value will be injected into the corresponding git tag value at build time using `-ldflags`. +var version = "v0.0.0" func init() { cli.VersionPrinter = func(c *cli.Context) {