-
-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (55 loc) · 1.41 KB
/
go.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
name: Go CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.22'
- name: Run static checks
run: go vet ./...
- name: Run audit
run: go mod tidy && go mod vendor
- name: Format code
run: go fmt ./...
- name: Test
run: go test -v ./...
- name: Build
run: go build -o tgcom ./cmd/tgcom
- name: Semantic Versioning
id: semver
run: |
VERSION=$(git describe --tags --abbrev=0)
if [ -z "$VERSION" ]; then
VERSION="v0.1.0"
else
VERSION=$(echo "$VERSION" | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')
fi
echo "New version: $VERSION"
echo "::set-output name=version::$VERSION"
release:
needs: build
name: Release
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Create release
uses: actions/create-release@v1
with:
tag_name: ${{ steps.semver.outputs.version }}
release_name: ${{ steps.semver.outputs.version }}
body: |
Release ${{ steps.semver.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}