diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cf9ae0e..53f2e2b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,35 +1,30 @@ +name: release + on: - release: - types: [created] + push: + tags: + - 'v*' jobs: - releases-matrix: - name: Release Go Binary + goreleaser: runs-on: ubuntu-latest - strategy: - matrix: - # build and publish in parallel: linux/386, linux/amd64, windows/386, windows/amd64, darwin/386, darwin/amd64, darwin/arm64 - goos: [linux, windows, darwin] - goarch: ["386", amd64, arm, arm64] - exclude: - - goos: darwin - goarch: arm - - goos: darwin - goarch: "386" - - goos: windows - goarch: arm64 - steps: - - uses: actions/checkout@v2 - - name: Set RELEASE_VERSION env - run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV - - uses: pcrbot/go-release-action@master - env: - CGO_ENABLED: 0 + - + name: Checkout + uses: actions/checkout@v2.3.4 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - goos: ${{ matrix.goos }} - goarch: ${{ matrix.goarch }} - goversion: "https://golang.org/dl/go1.16.linux-amd64.tar.gz" - build_flags: -trimpath - ldflags: -w -s + fetch-depth: 0 + + - + name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: '1.16.2' + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..e9a9a5a --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,58 @@ +env: + - GO111MODULE=on +before: + hooks: + - go mod tidy +builds: + - env: + - CGO_ENABLED=0 + - GO111MODULE=on + goos: + - linux + - darwin + - windows + goarch: + - 386 + - amd64 + - arm + - arm64 + ignore: + - goos: darwin + goarch: arm + - goos: darwin + goarch: 386 + - goos: windows + goarch: arm64 + mod_timestamp: '{{ .CommitTimestamp }}' + flags: + - -trimpath + ldflags: + - -s -w -X github.com/Mrs4s/go-cqhttp/coolq.Version=v{{.Version}} + +checksum: + name_template: '{{ .ProjectName }}_checksums.txt' +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' + - fix typo + - Merge pull request + - Merge branch + - Merge remote-tracking + - go mod tidy + +archives: + - name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' + format_overrides: + - goos: windows + format: zip + +nfpms: + - license: AGPL 3.0 + homepage: https://go-cqhttp.org + file_name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}" + formats: + - deb + - rpm \ No newline at end of file diff --git a/coolq/api.go b/coolq/api.go index 8567ce8..ddf2dbe 100644 --- a/coolq/api.go +++ b/coolq/api.go @@ -28,6 +28,9 @@ import ( var Version = "unknown" func init() { + if Version != "unknown" { + return + } info, ok := debug.ReadBuildInfo() if ok { Version = info.Main.Version diff --git a/global/config.go b/global/config.go index 8495355..e6108ff 100644 --- a/global/config.go +++ b/global/config.go @@ -173,7 +173,7 @@ type JSONConfig struct { UseSSOAddress bool `json:"use_sso_address"` Debug bool `json:"debug"` LogLevel string `json:"log_level"` - //WebUI *GoCQWebUI `json:"web_ui"` + // WebUI *GoCQWebUI `json:"web_ui"` } // CQHTTPAPIConfig HTTPAPI对应的Config结构体 diff --git a/main.go b/main.go index 4da7d22..009f92b 100644 --- a/main.go +++ b/main.go @@ -444,7 +444,7 @@ func OldPasswordDecrypt(encryptedPassword string, key []byte) string { func checkUpdate() { log.Infof("正在检查更新.") - if coolq.Version == "unknown" { + if coolq.Version == "(devel)" { log.Warnf("检查更新失败: 使用的 Actions 测试版或自编译版本.") return }