mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 03:23:49 +08:00
use goreleaser
(cherry picked from commit 2b3842e61cef5dabc7b1ad9a93d51c87f1ef5cf2)
This commit is contained in:
parent
8974adb009
commit
f6280baa0c
50
.github/workflows/release.yml
vendored
50
.github/workflows/release.yml
vendored
@ -1,36 +1,28 @@
|
|||||||
|
name: release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
push:
|
||||||
types: [created]
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
releases-matrix:
|
goreleaser:
|
||||||
name: Release Go Binary
|
|
||||||
runs-on: ubuntu-latest
|
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:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- name: Checkout
|
||||||
- name: Set RELEASE_VERSION env
|
uses: actions/checkout@v2.3.4
|
||||||
run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV
|
|
||||||
- uses: pcrbot/go-release-action@master
|
|
||||||
env:
|
|
||||||
CGO_ENABLED: 0
|
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
fetch-depth: 0
|
||||||
goos: ${{ matrix.goos }}
|
|
||||||
goarch: ${{ matrix.goarch }}
|
|
||||||
goversion: "https://golang.org/dl/go1.16.linux-amd64.tar.gz"
|
|
||||||
build_flags: -trimpath
|
|
||||||
ldflags: -w -s -X "github.com/Mrs4s/go-cqhttp/coolq.Version=${{ env.RELEASE_VERSION }}"
|
|
||||||
|
|
||||||
|
- 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 }}
|
||||||
|
58
.goreleaser.yml
Normal file
58
.goreleaser.yml
Normal file
@ -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
|
11
coolq/api.go
11
coolq/api.go
@ -10,6 +10,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"runtime/debug"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -28,6 +29,16 @@ import (
|
|||||||
// Version go-cqhttp的版本信息,在编译时使用ldflags进行覆盖
|
// Version go-cqhttp的版本信息,在编译时使用ldflags进行覆盖
|
||||||
var Version = "unknown"
|
var Version = "unknown"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
if Version != "unknown" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
info, ok := debug.ReadBuildInfo()
|
||||||
|
if ok {
|
||||||
|
Version = info.Main.Version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// CQGetLoginInfo 获取登录号信息
|
// CQGetLoginInfo 获取登录号信息
|
||||||
//
|
//
|
||||||
// https://git.io/Jtz1I
|
// https://git.io/Jtz1I
|
||||||
|
2
main.go
2
main.go
@ -351,7 +351,7 @@ func OldPasswordDecrypt(encryptedPassword string, key []byte) string {
|
|||||||
|
|
||||||
func checkUpdate() {
|
func checkUpdate() {
|
||||||
log.Infof("正在检查更新.")
|
log.Infof("正在检查更新.")
|
||||||
if coolq.Version == "unknown" {
|
if coolq.Version == "(devel)" {
|
||||||
log.Warnf("检查更新失败: 使用的 Actions 测试版或自编译版本.")
|
log.Warnf("检查更新失败: 使用的 Actions 测试版或自编译版本.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user