https://github.com/sillyhatxu/learning-github-actions
A simple tutorial for Actions and Budges
https://github.com/sillyhatxu/learning-github-actions
actions budge go golang
Last synced: 4 months ago
JSON representation
A simple tutorial for Actions and Budges
- Host: GitHub
- URL: https://github.com/sillyhatxu/learning-github-actions
- Owner: sillyhatxu
- License: mit
- Created: 2020-08-03T15:00:20.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-05T12:57:02.000Z (almost 5 years ago)
- Last Synced: 2025-01-19T05:51:26.700Z (6 months ago)
- Topics: actions, budge, go, golang
- Language: Go
- Homepage:
- Size: 973 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README-zh.md
- License: LICENSE
Awesome Lists containing this project
README
# learning-github-actions
[](http://golang.org)
[](https://github.com/sillyhatxu/learning-github-actions)
[](https://pkg.go.dev/github.com/sillyhatxu/learning-github-actions)
[](https://github.com/sillyhatxu/learning-github-actions/actions)
[](https://goreportcard.com/report/github.com/sillyhatxu/learning-github-actions)
[](https://codecov.io/gh/sillyhatxu/learning-github-actions)
[](https://choosealicense.com/licenses/mit/)
[](https://github.com/sillyhatxu/learning-github-actions/releases)## 1. 新增workflows
新增文件 `.github/workflows/master.yml`
> 创建后,系统会在Actions中显示build
1) 直接创建
```yaml
name: Build and Teston:
push:
branches: [ master ]jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.14
id: go- name: Check out code into the Go module directory
uses: actions/checkout@v2- name: Get dependencies
run: go mod vendor- name: Test
run: go test -v .# If it does not has the main function and doesn't need to build.
# - name: Build
# run: go build -v .
```2) 页面操作新增文件
* page 1

* page 2

* page 3

## 2. 添加 badges
### 1) 添加 Made with Go
```yaml
[](http://golang.org)
```### 2) 添加 Go Version
```yaml
[](https://github.com//)
```### 4) 添加 Go Reference
*需要创建License*
* page 1

* page 2

* page 3

* page 4

> 有时不会自动创建,官方给出两种解决方案。
* 第一种:`不知名原因,只返回了json,但没有更新Go Reference Doc`
> Making a request to proxy.golang.org for the module version, to any endpoint specified by the Module proxy protocol.
> For example: https://proxy.golang.org/example.com/my/module/@v/v1.0.0.infocurl https://proxy.golang.org/github.com/sillyhatxu/learning-github-actions/@latest
{"Version":"v1.0.0","Time":"2020-08-04T15:50:54Z"}
curl https://proxy.golang.org/github.com/sillyhatxu/learning-github-actions/@v/v1.0.0.info
{"Version":"v1.0.0","Time":"2020-08-04T15:50:54Z"}* 第二种:`需要使用另一个golang的项目,在go mod init 后,使用 go get 命令来发布`
> Downloading the package via the go command.
> For example: GOPROXY=https://proxy.golang.org GO111MODULE=on
> go get example.com/my/[email protected]
create new project xxxxxx
go mod init xxxxxx
go get github.com/sillyhatxu/learning-github-actions/@v1.0.2```yaml
[](https://pkg.go.dev/github.com//)
```### 4) 添加 build and test badge
```yaml
[](https://github.com/sillyhatxu/learning-github-actions/actions)
```
### 5) 添加 coverage badge
* 登陆 [codecov](https://codecov.io/)
* Add new repository
* Choose a new repository below

* Copy token

* 回到Github `project->Settings->Secrets->New Secret`

* Create Secret `CODECOV_TOKEN=xxxxx` paste codecov token

* Create workflows `coverage.yml`
```yaml
name: Coverageon:
push:
branches: [ master ]jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.14
id: go- name: Check out code into the Go module directory
uses: actions/checkout@v2- name: Get dependencies
run: go mod vendor- name: Create coverage file
run: |
set -e
echo "" > coverage.txtfor d in $(go list ./... | grep -v vendor); do
go test -race -coverprofile=profile.out -covermode=atomic "$d"
if [ -f profile.out ]; then
cat profile.out >> coverage.txt
rm profile.out
fi
done- name: Coverage
run: bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }}
```### 6) 添加 go report
```yaml
[](https://goreportcard.com/report/github.com//)
```### 7) 添加 release version
```yaml
[](https://github.com///releases)
```### 8) 添加 MIT License
```yaml
[](https://choosealicense.com/licenses/mit/)
```