添加自动化编译

This commit is contained in:
M09Ic 2023-05-04 12:23:24 +08:00
parent 1a656b26a1
commit 2421c4178d
6 changed files with 121 additions and 0 deletions

51
.github/workflows/gorelease.yml vendored Normal file
View File

@ -0,0 +1,51 @@
name: goreleaser
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
jobs:
goreleaser:
runs-on: ubuntu-20.04
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{secrets.TOKEN}}
submodules: recursive
-
name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.17
-
name: Install upx
run: sudo apt install upx -y
continue-on-error: true
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --rm-dist --skip-validate
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
GOPATH: "/home/runner/go"
- name: upx
run: upx dist/gogo*
continue-on-error: true
- name: Upload assets
uses: actions/upload-artifact@v3
with:
name: gogo_archive
path: |
dist/gogo*
tools/*
README.md

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "templates"]
path = templates
url = https://github.com/chainreactors/gogo-templates

58
.goreleaser.yml Normal file
View File

@ -0,0 +1,58 @@
project_name: spray
before:
hooks:
- go mod tidy
- go get sigs.k8s.io/yaml
- go generate
builds:
-
main: .
binary: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
goos:
- windows
- linux
- darwin
goarch:
- amd64
- "386"
- arm64
ignore:
- goos: windows
goarch: arm64
- goos: darwin
goarch: "386"
ldflags: "-s -w -X 'github.com/chainreactors/spray/cmd.ver=={{ .Tag }}'"
flags:
- -trimpath
- -tags=forceposix
asmflags:
- all=-trimpath={{.Env.GOPATH}}
gcflags:
- all=-trimpath={{.Env.GOPATH}}
no_unique_dist_dir: true
archives:
-
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
format: binary
replacements:
amd64_v1: amd64
checksum:
name_template: "{{ .ProjectName }}_checksums.txt"
changelog:
sort: desc
filters:
exclude:
- '^MERGE'
- "{{ .Tag }}"
- "^docs"
release:
github:
owner: chainreactors
name: spray
draft: true

View File

@ -17,6 +17,8 @@ import (
"time"
)
var ver = ""
func Spray() {
var option internal.Option
parser := flags.NewParser(&option, flags.Default)
@ -49,6 +51,11 @@ func Spray() {
return
}
if option.Version {
fmt.Println(ver)
return
}
if option.Format != "" {
internal.Format(option.Format, !option.NoColor)
os.Exit(0)

View File

@ -124,6 +124,7 @@ type MiscOptions struct {
PoolSize int `short:"P" long:"pool" default:"5" description:"Int, Pool size"`
Threads int `short:"t" long:"thread" default:"20" description:"Int, number of threads per pool"`
Debug bool `long:"debug" description:"Bool, output debug info"`
Version bool `short:"v" long:"version" description:"Bool, show version"`
Quiet bool `short:"q" long:"quiet" description:"Bool, Quiet"`
NoColor bool `long:"no-color" description:"Bool, no color"`
NoBar bool `long:"no-bar" description:"Bool, No progress bar"`

1
templates Submodule

@ -0,0 +1 @@
Subproject commit 241a707ce2a8d32b8bc96ebb5a06bcfdecb54b24