-
Notifications
You must be signed in to change notification settings - Fork 9
61 lines (47 loc) · 1.82 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
60
61
name: Build
on:
push:
workflow_dispatch:
inputs:
go_version:
description: 'Go version without the "go" prefix'
required: false
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
concurrency:
group: gotify-build-lock
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Input sanity check
if: ${{ github.event.inputs.go_version }}
run: |
export GO_VERSION=${{ github.event.inputs.go_version }}
MATCHES=$(curl -fsSL 'https://go.dev/dl/?mode=json&include=all' | jq --arg GO_VERSION "$GO_VERSION" -r ".[] | select (.version == \"go\" + \$GO_VERSION) | .version" | wc -l)
if [ "$MATCHES" -ne 1 ]; then
echo "Invalid Go version: $GO_VERSION, found $MATCHES matches"
exit 1
fi
- name: Set up environment (tagged release)
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
GO_VERSION=${TAG_NAME#v}
echo "GO_VERSION=$GO_VERSION" >> $GITHUB_ENV
- name: Set up environment (non-tagged release)
if: ${{ !startsWith(github.ref, 'refs/tags/v') && !github.event.inputs.go_version }}
run: |
GO_VERSION=$(curl -fsSL 'https://go.dev/dl/?mode=json' | jq -r '.[] | select (.stable) | .version | sub("^go"; "")' | head -n 1)
echo "GO_VERSION=$GO_VERSION" >> $GITHUB_ENV
- name: Set up environment (to-be-tagged release)
if: ${{ !startsWith(github.ref, 'refs/tags/v') && github.event.inputs.go_version }}
run: |
GO_VERSION=${{ github.event.inputs.go_version }}
git tag -s "v${GO_VERSION}" -m "Bump to Go $GO_VERSION"
git push origin --tags
echo "GO_VERSION=$GO_VERSION" >> $GITHUB_ENV
- name: Build
run: make build