-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (92 loc) · 2.91 KB
/
go_lib_push_main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Create Github Release
on:
workflow_call:
inputs:
GH_CI_USER:
description: "User for GitHub auth"
required: true
type: string
GOPRIVATE:
description: "GOPRIVATE env for go commands"
required: false
type: string
secrets:
GH_CI_PAT:
description: 'Token password for GitHub auth'
required: true
CODECOV_TOKEN:
description: 'Token for Codecov'
required: true
env:
GOPRIVATE: ${{ inputs.GOPRIVATE }}
jobs:
test:
#
# ensure go standards and tests pass
#
runs-on: ubuntu-latest
strategy:
matrix:
# List of go versions to test on.
go: ["^1"]
steps:
# Checkout go code to test.
- name: Checkout repo
uses: actions/checkout@v4
# Setup Go for each version in the matrix.
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
# Use auth to get access to private Git repos for Go code dependencies.
- name: Configure git for private modules
env:
TOKEN: ${{ secrets.GH_CI_PAT }}
GITHUB_USERNAME: ${{ inputs.GH_CI_USER }}
run:
git config --global url."https://${GITHUB_USERNAME}:${TOKEN}@github.com".insteadOf
"https://github.com"
# Go vet every Go module.
- name: go vet
run:
find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname
| xargs -n1 -I{} bash -c "pushd {}; go vet ./..."
# Run unit test for evet Go module.
- name: go test
run:
find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname
| xargs -n1 -I{} bash -c "pushd {}; go test -coverprofile=coverage.txt --race -v ./..."
- name: Upload test coverage results to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
release:
#
# Create a GitHub Release based on conventional commits.
#
name: 'Release to GitHub'
# needs: test
runs-on: ubuntu-latest
steps:
# Checkout code to release.
- name: Checkout repo
uses: actions/checkout@v4
# Setup Node needed to create release.
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 18
# Add plugin to make the changelog for the release.
- name: Add plugin for conventional commits
run: npm install conventional-changelog-conventionalcommits@6
working-directory: ./.github/workflows
# Create the release.
- name: Release to GitHub
working-directory: ./.github/workflows
env:
GITHUB_TOKEN: ${{ secrets.GH_CI_PAT }}
GIT_AUTHOR_NAME: release-bot
GIT_AUTHOR_EMAIL: [email protected]
GIT_COMMITTER_NAME: asyncapi-bot
GIT_COMMITTER_EMAIL: [email protected]
run: npx [email protected]