-
Notifications
You must be signed in to change notification settings - Fork 8
59 lines (46 loc) · 1.64 KB
/
build.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
name: Build
on:
push:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
concurrency:
group: gotify-build-lock
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Sanity check
run: |
GO_VERSION=$(cat GO_VERSION)
MATCHES=$(curl -fsSL 'https://go.dev/dl/?mode=json&include=all' | jq --arg GO_VERSION "$GO_VERSION" -r 'map(select(.version == "go\($GO_VERSION)")) | length')
if [ "$MATCHES" -ne 1 ]; then
echo "Invalid Go version: $GO_VERSION, found $MATCHES matches"
exit 1
fi
- name: Build
run: make build
- name: Login to Docker
if: ${{ !startsWith(github.ref, 'refs/tags/v') && github.ref == 'refs/heads/master' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Push and tag
# push if we are not already tagged, the workflow is triggered by a manual go_version input or we are on master
if: ${{ !startsWith(github.ref, 'refs/tags/v') && github.ref == 'refs/heads/master' }}
run: |
GO_VERSION=$(cat GO_VERSION)
if git tag --list "v${GO_VERSION}" | grep -q "v${GO_VERSION}"; then
echo "Tag v${GO_VERSION} already exists"
exit 1
fi
if ! make push; then
echo "Failed to push tags"
exit 1
fi
git config user.name "gotifyci"
git config user.email "[email protected]"
git tag "v${GO_VERSION}" -m "Bump to Go $GO_VERSION"
git push origin --tags