diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 78f97b88..716b2931 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -2,54 +2,26 @@ name: 测试版 on: push: tags: - - p* - -env: - GITHUB_TOKEN: ${{ github.token }} + - 'p*' jobs: - my-job: - name: Build ZeroBot-Plugin on Push Tag 🚀 + goreleaser: runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v2.3.4 + with: + fetch-depth: 0 - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.17 + go-version: '1.17' - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: Cache Go - id: cache - uses: actions/cache@v2 + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 with: - # A list of files, directories, and wildcard patterns to cache and restore - path: ~/go/pkg/mod - key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }} - - - name: Tidy Go modules - run: go mod tidy - - - name: Build linux-x64 - run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-linux-x64 - - name: Build linux-x86 - run: CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-linux-x86 - - name: Build windows-x64 - run: CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-windows-x64.exe - - name: Build windows-x86 - run: CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-windows-x86.exe - - name: Build arm64 - run: CGO_ENABLED=0 GOOS=linux GOARCH=arm64 GOARM=7 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-linux-arm64 - - name: Build armv6 - run: CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-linux-armv6 - - - name: Upload binaries to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: artifacts/zerobot-plugin-* - tag: ${{ github.ref }} - overwrite: true - file_glob: true + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 95b1a654..60e98dcc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,54 +2,26 @@ name: 稳定版 on: push: tags: - - v* - -env: - GITHUB_TOKEN: ${{ github.token }} + - 'v*' jobs: - my-job: - name: Build ZeroBot-Plugin on Push Tag 🚀 + goreleaser: runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v2.3.4 + with: + fetch-depth: 0 - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.17 + go-version: '1.17' - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: Cache Go - id: cache - uses: actions/cache@v2 + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 with: - # A list of files, directories, and wildcard patterns to cache and restore - path: ~/go/pkg/mod - key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }} - - - name: Tidy Go modules - run: go mod tidy - - - name: Build linux-x64 - run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-linux-x64 - - name: Build linux-x86 - run: CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-linux-x86 - - name: Build windows-x64 - run: CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-windows-x64.exe - - name: Build windows-x86 - run: CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-windows-x86.exe - - name: Build arm64 - run: CGO_ENABLED=0 GOOS=linux GOARCH=arm64 GOARM=7 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-linux-arm64 - - name: Build armv6 - run: CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-linux-armv6 - - - name: Upload binaries to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: artifacts/zerobot-plugin-* - tag: ${{ github.ref }} - overwrite: true - file_glob: true + 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 00000000..fa4ec5f1 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,89 @@ +env: + - GO111MODULE=on +before: + hooks: + - go mod tidy +builds: + - id: nowin + env: + - CGO_ENABLED=0 + - GO111MODULE=on + goos: + - linux + - darwin + goarch: + - 386 + - amd64 + - arm + - arm64 + goarm: + - 6 + - 7 + ignore: + - goos: darwin + goarch: arm + - goos: darwin + goarch: 386 + mod_timestamp: "{{ .CommitTimestamp }}" + flags: + - -trimpath + ldflags: + - -s -w + - id: win + env: + - CGO_ENABLED=0 + - GO111MODULE=on + goos: + - windows + goarch: + - 386 + - amd64 + - arm + - arm64 + goarm: + - 7 + mod_timestamp: "{{ .CommitTimestamp }}" + flags: + - -trimpath + ldflags: + - -s -w + +checksum: + name_template: "zbp_checksums.txt" +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + - fix typo + - Merge pull request + - Merge branch + - Merge remote-tracking + - go mod tidy + +archives: + - id: binary + builds: + - win + name_template: "zbp_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" + format_overrides: + - goos: windows + format: binary + - id: nowin + builds: + - nowin + - win + name_template: "zbp_{{ .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: "zbp_{{ .Version }}_{{ .Os }}_{{ .Arch }}" + formats: + - deb + - rpm + maintainer: Kanri, DawnNights, Fumiama, Suika