-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (102 loc) · 2.79 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
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
name: Go CI/CD
on:
push:
branches: [ "main" ]
tags: [ "v*" ]
pull_request:
branches: [ "main" ]
env:
GO_VERSION: '1.21'
JAVA_VERSION: '17'
BINARY_NAME: 'minecrap_hoster'
VERSION: '1.0.0'
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Install golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
- name: Run golangci-lint
run: golangci-lint run ./...
test:
name: Test
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ env.JAVA_VERSION }}
- name: Download test dependencies
run: |
mkdir -p static
curl -o fabric-server-mc.1.20.1-loader.0.16.5-launcher.1.0.1.jar https://meta.fabricmc.net/v2/versions/loader/1.20.1/0.14.21/0.11.2/server/jar
- name: Run tests
run: |
go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
- name: Upload coverage reports
uses: codecov/codecov-action@v3
with:
file: ./coverage.txt
fail_ci_if_error: false
build:
name: Build
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Build using Makefile
run: |
# Set version from git tag if available
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
make build-all VERSION=$VERSION
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: releases
path: |
build/*.zip
build/*.tar.gz
retention-days: 7
release:
name: Release
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download built artifacts
uses: actions/download-artifact@v3
with:
name: releases
path: releases
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
releases/*.zip
releases/*.tar.gz
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}