-
Notifications
You must be signed in to change notification settings - Fork 28
162 lines (162 loc) · 5.7 KB
/
test_and_release.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: Test and Release
on:
push:
jobs:
unit-test:
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
- name: Load Go version
id: go-version
run: |
echo go-version=$(sed 's/^.*://' .github/go/Dockerfile) >> $GITHUB_OUTPUT
- uses: actions/setup-go@v5
with:
go-version: ${{ steps.go-version.outputs.go-version }}
- name: Unit tests
run: |
make test race
lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v5
with:
go-version: 1.17
- name: Lint
uses: golangci/[email protected]
with:
version: v1.31
spec-test:
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
- name: Load Go version
id: go-version
run: |
echo go-version=$(sed 's/^.*://' .github/go/Dockerfile) >> $GITHUB_OUTPUT
- uses: actions/setup-go@v5
with:
go-version: ${{ steps.go-version.outputs.go-version }}
- name: Build executable
run: |
make build
- name: Build spec test suite docker image
run: |
cd spec/test
docker build . -t bbvalabsci/kapow-spec-test-suite:latest
- name: Spec test
run: |
docker run --mount type=bind,source=$(pwd)/build/kapow,target=/usr/bin/kapow bbvalabsci/kapow-spec-test-suite:latest "behave --tags=~@skip"
doc-test:
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
- name: Prepare Python env
run: |
sudo apt install python3
sudo pip install pipenv
cd docs
pipenv sync
- name: Check for warnings & broken links
run: |
cd docs
SPHINXOPTS="-qW --keep-going" pipenv run make linkcheck html
release:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-22.04
needs: [ unit-test, spec-test, doc-test, lint ]
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
- name: Load Go version
id: go-version
run: |
echo go-version=$(sed 's/^.*://' .github/go/Dockerfile) >> $GITHUB_OUTPUT
- uses: actions/setup-go@v5
with:
go-version: ${{ steps.go-version.outputs.go-version }}
- name: Select custom release notes
id: release-notes
run: |
RELNOTES="docs/release-notes/RELEASE-${GITHUB_REF#refs/tags/}.md"
[[ -f "$RELNOTES" ]] && echo ARGS=--release-notes $RELNOTES >> $GITHUB_OUTPUT || true
- name: Check credentials
id: docker-credentials
run: |
echo defined=$(test -n "${{ secrets.DOCKERHUB_USERNAME }}" && echo true || echo false) >> $GITHUB_OUTPUT
- name: Docker Login
if: steps.docker-credentials.outputs.defined == 'true'
run: |
username="${{ secrets.DOCKERHUB_USERNAME }}"
password="${{ secrets.DOCKERHUB_PASSWORD }}"
echo "$password" | docker login --username "$username" --password-stdin
- uses: goreleaser/[email protected]
with:
args: release --rm-dist ${{ steps.release-notes.outputs.ARGS }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Archive binaries as artifacts
uses: actions/upload-artifact@v4
with:
name: binaries
path: |
dist/*
- name: Upload Docker images
if: steps.docker-credentials.outputs.defined == 'true'
run: docker image push --all-tags bbvalabsci/kapow
wininstaller:
runs-on: ubuntu-22.04
needs: release
strategy:
matrix:
binary: ["kapow_windows_386", "kapow_windows_amd64_v1"]
steps:
- uses: actions/[email protected]
- name: Download a single artifact
uses: actions/download-artifact@v4
with:
name: binaries
- name: Install NSIS
run: |
sudo apt-get update -y
DEBIAN_FRONTEND=noninteractive sudo -E apt-get install --no-install-recommends -y nsis nsis-doc nsis-pluginapi
- name: Prepare NSIS files
run: |
mkdir .github/NSIS/install_dir
cp -p ${{ matrix.binary }}/kapow.exe .github/NSIS/install_dir/
wget https://github.com/awaescher/PathEd/releases/download/1.0/PathEd.zip
unzip PathEd.zip -d .github/NSIS/install_dir/
- name: Set variables for the build
id: set-vars
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
release="${GITHUB_REF_NAME}"
upload_url=$(curl -s -u "$GITHUB_TOKEN" https://api.github.com/repos/BBVA/kapow/releases \
| jq -r '.[] | if .tag_name == "'$release'" then . else empty end | .upload_url' \
| tail -n1)
echo "URL: $upload_url"
echo upload_url=$upload_url >> $GITHUB_OUTPUT
no_rc_release=${release%%-[Rr][Cc]*}
echo nsis_version=${no_rc_release#[Vv]} >> $GITHUB_OUTPUT # NSIS version only accepts \d+.\d+.\d+
unversioned_binary=${{ matrix.binary }}_setup.exe
echo nsis_installer_name=${unversioned_binary//kapow_/kapow_${release#v}_} >> $GITHUB_OUTPUT
- name: Create Windows installer
uses: joncloud/[email protected]
env:
NSIS_VERSION: ${{ steps.set-vars.outputs.nsis_version }}
NSIS_INSTALLER_NAME: ${{ steps.set-vars.outputs.nsis_installer_name }}
with:
script-file: .github/NSIS/windows.nsi
- name: Upload Release Asset
id: upload-release-asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
asset_path: .github/NSIS/${{ steps.set-vars.outputs.nsis_installer_name }}
asset_name: ${{ steps.set-vars.outputs.nsis_installer_name }}
asset_content_type: application/octet-stream
upload_url: ${{ steps.set-vars.outputs.upload_url }}