Skip to content

Commit

Permalink
Merge pull request #48 from eryajf/main
Browse files Browse the repository at this point in the history
feat: add build go binary to release
  • Loading branch information
869413421 authored Dec 11, 2022
2 parents 0640a26 + 0e36038 commit 4a32233
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/go-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: build

on:
release:
types: [created] # 表示在创建新的 Release 时触发

jobs:
build-go-binary:
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin] # 需要打包的系统
goarch: [amd64, arm64] # 需要打包的架构
exclude: # 排除某些平台和架构
- goarch: arm64
goos: windows
steps:
- uses: actions/checkout@v3
- uses: wangyoucao577/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }} # 一个默认的变量,用来实现往 Release 中添加文件
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: 1.16 # 可以指定编译使用的 Golang 版本
binary_name: "wechatbot" # 可以指定二进制文件的名称
extra_files: README.md config.dev.json # 需要包含的额外文件
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,24 @@ $ tail -f -n 50 /app/run.log

# 快速开始

> 非技术人员请直接下载release中的[压缩包](https://github.com/869413421/wechatbot/releases/tag/v1.1.3) ,解压运行。
`第一种:直接下载二进制(适合对编程不了解的同学)`

> 非技术人员请直接下载release中的[压缩包](https://github.com/869413421/wechatbot/releases) ,请根据自己系统以及架构选择合适的压缩包,下载之后直接解压运行。
下载之后,在本地解压,即可看到可执行程序,与配置文件:

```
$ tar xf wechatbot-v0.0.2-darwin-arm64.tar.gz
$ cd wechatbot-v0.0.2-darwin-arm64
$ cp config.dev.json # 根据情况调整配置文件内容
$ ./wechatbot # 直接运行
# 如果要守护在后台运行
$ nohup ./wechatbot &> run.log &
$ tail -f run.log
```

`第二种:基于源码运行(适合了解go语言编程的同学)`

````
# 获取项目
Expand All @@ -98,7 +115,7 @@ go run main.go
# 编译
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-w' -o wechatbot ./main.go
# 守护进程运行
nohup ./wechatbot > run.log &
nohup ./wechatbot &> run.log &
# 查看二维码
# tail -f -n 50 run.log
````
Expand Down Expand Up @@ -139,4 +156,3 @@ session_clear_token: 会话清空口令,默认`下一个问题`

<img width="300px" src="https://raw.githubusercontent.com/869413421/study/master/static/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20221208153015.jpg"/>


0 comments on commit 4a32233

Please sign in to comment.