-
Notifications
You must be signed in to change notification settings - Fork 5
142 lines (125 loc) · 3.63 KB
/
ci.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Merge
on:
push:
branches:
- staging
- trying
tags-ignore:
- "*"
jobs:
info:
name: Gather info
runs-on: ubuntu-latest
outputs:
version: "${{ fromJSON(steps.version.outputs.version) }}"
release_notes: "${{ fromJSON(steps.notes.outputs.release_notes) }}"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Compute version
id: version
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # needed to get previous version
run: |
# Sets output VERSION
VERSION="$(./.github/scripts/get-version)"
./.github/scripts/set-output version "${VERSION}"
- uses: actions/setup-go@v3
with:
go-version: 1.19.x
cache: true
- name: Extract release notes
id: notes
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # needed to get previous version
run: |
PREVIOUS_VERSION="$(./.github/scripts/get-previous-version)"
CHANGELOG="$(./.github/scripts/get-changelog "${PREVIOUS_VERSION}" --version "${{ fromJSON(steps.version.outputs.version) }}")"
./.github/scripts/set-output release_notes "${CHANGELOG}"
version-check:
# ensure versions in the repo match the intended publish version
name: Version Check
needs: [info]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
VERSION="${{ needs.info.outputs.version }}"
./.github/scripts/update-versions "$VERSION"
ERROR=false
if [ -n "$(git status --porcelain)" ]; then
ERROR=true
echo "::error::Versions in files do not match expected version $VERSION."
echo "::group::git diff"
git diff
echo "::endgroup::"
fi
if EXISTING_RELEASE="$(gh release view "v${VERSION}")"; then
echo "::error::This version has already been released!"
echo "::group::Release $VERSION"
echo "$EXISTING_RELEASE"
echo "::endgroup::"
fi
if $ERROR; then
exit 1;
fi
lint:
name: Lint
uses: ./.github/workflows/ci-lint.yml
build:
name: Build
needs: [info]
uses: ./.github/workflows/ci-build.yml
with:
version: ${{ needs.info.outputs.version }}
secrets: inherit
build-ok:
# bors watches for this check
name: Build OK
needs: [build]
runs-on: ubuntu-latest
steps:
- run: echo OK
unit-test-go:
name: Unit Test
uses: ./.github/workflows/ci-unit-test.yml
unit-test-ok:
name: Unit Test OK
needs: [unit-test-go]
runs-on: ubuntu-latest
steps:
- run: echo OK
integration-test:
name: Integration Test
needs: [info, build]
uses: ./.github/workflows/ci-integration-test.yml
with:
version: ${{ needs.info.outputs.version }}
test-ok:
# bors watches for this check
name: Test OK
needs: [lint, unit-test-ok, integration-test]
runs-on: ubuntu-latest
steps:
- run: echo OK
publish:
name: Publish
needs: [test-ok, version-check, info]
uses: ./.github/workflows/ci-publish.yml
if: ${{ github.ref_name == 'staging' }}
with:
version: ${{ needs.info.outputs.version }}
release_notes: ${{ needs.info.outputs.release_notes }}
project: ${{ github.repository }}
commit: ${{ github.sha }}
secrets: inherit
publish-ok:
# bors watches for this check
name: Publish OK
needs: [publish]
runs-on: ubuntu-latest
steps:
- run: echo OK # test, block release