[toc]
- 当代码推送到 master和 release分支的时候触发构建
on:
push:
branches:
- master
- release/*
- 当只有 pull_request被合并到 master分支的时候:
on:
pull_request:
branches:
- master
- 比如星期一到星期五的每天2点构建任务呢:
on:
schedule:
- cron: 0 2 * * 1-5
go install github.com/goreleaser/goreleaser@latest
goreleaser init
goreleaser build --single-target
goreleaser release --snapshot
- 使用 release.yml 每次创建 tag 会触发 action 生成版本
- 用 .goreleaser.yml 控制生成文件
https://github.com/NicholeGit/ActionsDemo/workflows/Go/badge.svg
https://github.com/NicholeGit/ActionsDemo/
是项目的地址workflows/Go/badge.svg
中间的 Go 是https://github.com/NicholeGit/ActionsDemo/actions
下的名称。需要注意区分大小写
- 需要创建 release 版本才出现
- 编写.travis.yml 文件
language: go # 使用语言.
go:
- 1.15.6 # 版本号, 支持多种版本号
sudo: required # #有定制化开发环境需要,默认false,不开启容器,编译效率高
os: # 使用的操作系统
- linux
- osx
notifications: # 邮箱通知
email: [email protected]
go_import_path: # 使用Go需要导入的包.
- github.com/gin-gonic/gin
- github.com/pkg/errors
- github.com/smartystreets/goconvey
before_install: # 主要安装一些系统依赖,
- go mod tidy
install: true # 安装, true跳过
script: # 脚本执行.
- echo "run"
- go test -race -coverprofile=coverage.txt -covermode=atomic
- go test -v ./...
after_success: # 上传测试报告
- bash <(curl -s https://codecov.io/bash)
- 在 https://codecov.io/ 使用 GitHub 帐号登陆
点击Settings -> Badge