-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (85 loc) · 2.95 KB
/
build-test.yaml
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
94
95
96
97
98
99
100
name: Build, Test and Publish
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
on:
push:
branches: ["master"]
paths-ignore:
- "CHANGELOG.md"
pull_request:
branches: ["master"]
jobs:
test-and-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Go environment
uses: actions/setup-go@v3.3.1
with:
go-version-file: go.mod
# Used to specify whether caching is needed. Set to true, if you'd like to enable caching.
cache: true
# Used to specify the path to a dependency file - go.sum
cache-dependency-path: go.sum
- name: Setup dependencies
run: make setup
- name: Run tests w/ Coverage
run: make test-cov
- name: Build cli binary
run: make build
publish:
needs:
- test-and-build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GH_TOKEN }}
fetch-depth: 0
- name: Setup Go environment
uses: actions/setup-go@v3.3.1
with:
go-version-file: go.mod
# Used to specify whether caching is needed. Set to true, if you'd like to enable caching.
cache: true
# Used to specify the path to a dependency file - go.sum
cache-dependency-path: go.sum
- name: Generate changelog and tag release
id: changelog
uses: TriPSs/conventional-changelog-action@v4
with:
input-file: CHANGELOG.md
output-file: CHANGELOG.md
fallback-version: 0.0.0
skip-commit: true
skip-version-file: true
skip-tag: true
git-push: false
- name: Write changelog to temp file for goreleaser
if: ${{ steps.changelog.outputs.skipped == 'false' }}
run: echo "${{ steps.changelog.outputs.clean_changelog }}" > ${{ runner.temp }}/CHANGELOG.md
- name: Commit release
if: ${{ steps.changelog.outputs.skipped == 'false' }}
run: |
git config user.name "GitHub Actions"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "chore(release): ${{ steps.changelog.outputs.tag }}"
- name: Tag commit
if: ${{ steps.changelog.outputs.skipped == 'false' }}
run: git tag ${{ steps.changelog.outputs.tag }}
- name: Push changelog
if: ${{ steps.changelog.outputs.skipped == 'false' }}
run: |
git push origin master
- name: Release new CLI version
if: ${{ steps.changelog.outputs.skipped == 'false' }}
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --clean --release-notes "${{ runner.temp }}/CHANGELOG.md"
env:
GITHUB_TOKEN: ${{ secrets.GH_HOMEBREW_PUBLISHER }}