Skip to content

Commit

Permalink
增加自动化编译
Browse files Browse the repository at this point in the history
Signed-off-by: allan716 <525223688@qq.com>
  • Loading branch information
allanpk716 committed Jun 24, 2023
1 parent d5ddd6e commit ba69f89
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/release_client_base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: release_client_base

on:
push:
tags:
- v*.*.*
- v*.*-Beta*
workflow_dispatch:

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release -f .goreleaser_client_base.yml --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/release_client_youtube.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: release_client_youtube

on:
push:
tags:
- v*.*.*
- v*.*-Beta*
workflow_dispatch:

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release -f .goreleaser_client_youtube.yml --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67 changes: 67 additions & 0 deletions .goreleaser_client_base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
project_name: client_base

env:
- GO111MODULE=on

before:
hooks:
- go mod tidy
builds:
- id: linux-amd64-build
goos:
- linux
goarch:
- amd64
main: ./cmd/client_base/main.go
ldflags:
- -s -w --extldflags "-static -fpic" -X main.AppVersion=v{{ .Version }}

- id: linux-armv7-build
goos:
- linux
goarch:
- arm
goarm:
- 7
main: ./cmd/client_base/main.go
ldflags:
- -s -w --extldflags "-static -fpic" -X main.AppVersion=v{{ .Version }}

- id: linux-arm64-build
goos:
- linux
goarch:
- arm64
main: ./cmd/client_base/main.go
ldflags:
- -s -w --extldflags "-static -fpic" -X main.AppVersion=v{{ .Version }}

- id: windows-build
goos:
- windows
goarch:
- amd64
main: ./cmd/client_base/main.go
ldflags:
- -s -w --extldflags "-static -fpic" -X main.AppVersion=v{{ .Version }}

archives:
- id: archive
name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
replacements:
darwin: Darwin
linux: Linux
windows: Windows
amd64: x86_64
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
- "^TestData:"
- "^TestCode:"
67 changes: 67 additions & 0 deletions .goreleaser_client_youtube.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
project_name: client_youtube

env:
- GO111MODULE=on

before:
hooks:
- go mod tidy
builds:
- id: linux-amd64-build
goos:
- linux
goarch:
- amd64
main: ./cmd/client_youtube/main.go
ldflags:
- -s -w --extldflags "-static -fpic" -X main.AppVersion=v{{ .Version }}

- id: linux-armv7-build
goos:
- linux
goarch:
- arm
goarm:
- 7
main: ./cmd/client_youtube/main.go
ldflags:
- -s -w --extldflags "-static -fpic" -X main.AppVersion=v{{ .Version }}

- id: linux-arm64-build
goos:
- linux
goarch:
- arm64
main: ./cmd/client_youtube/main.go
ldflags:
- -s -w --extldflags "-static -fpic" -X main.AppVersion=v{{ .Version }}

- id: windows-build
goos:
- windows
goarch:
- amd64
main: ./cmd/client_youtube/main.go
ldflags:
- -s -w --extldflags "-static -fpic" -X main.AppVersion=v{{ .Version }}

archives:
- id: archive
name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
replacements:
darwin: Darwin
linux: Linux
windows: Windows
amd64: x86_64
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
- "^TestData:"
- "^TestCode:"
6 changes: 6 additions & 0 deletions cmd/client_base/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import (

var configFile = flag.String("f", "etc/client_base.yaml", "the config file")

func init() {
logger.Infoln("Version:", AppVersion)
}

func main() {

videoFPath := flag.String("video", "", "the video file path")
Expand Down Expand Up @@ -58,3 +62,5 @@ func main() {

logger.Infoln("Done")
}

var AppVersion = "unknow"
6 changes: 6 additions & 0 deletions cmd/client_youtube/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ import (

var configFile = flag.String("f", "etc/client_youtube.yaml", "the config file")

func init() {
logger.Infoln("Version:", AppVersion)
}

func main() {

dlUrl := flag.String("yt_url", "", "the youtube video url")
Expand Down Expand Up @@ -214,3 +218,5 @@ func downloadYoutubeVideo(c settings.Configs, client *resty.Client, dlUrl string

return outVideoFPath
}

var AppVersion = "unknow"

0 comments on commit ba69f89

Please sign in to comment.