-
Notifications
You must be signed in to change notification settings - Fork 0
175 lines (145 loc) · 4.11 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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Lint, build and upload Igitt
on:
push:
# branches: ["main"]
tags:
- "*"
pull_request:
branches: ["main"]
jobs:
lint:
# run on self-hosted runner to reduce usage quota
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23"
- name: Lint
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint run
test:
needs: lint
# run on github hosted runner to avoid waste of resources
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23"
- name: Test
run: go test -v ./...
buildStatusCheck:
if: github.event_name == 'pull_request'
runs-on: self-hosted
needs: [lint, test]
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23"
- name: Build
run: |
go build -o /dev/null ./cmd/igitt;
build:
env:
LATEST_TAG: ${{ github.ref_name }}
needs: [lint, test]
if: startsWith(github.ref, 'refs/tags/')
# run on self-hosted runner to reduce usage quota
runs-on: self-hosted
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: [amd64, arm64]
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23"
- name: Set GOOS and GOARCH
run: |
echo "GOOS=${{ matrix.goos }}" >> $GITHUB_ENV
echo "GOARCH=${{ matrix.goarch }}" >> $GITHUB_ENV
- name: Build
run: |
if [[ "${{ matrix.goos }}" == "windows" ]]; then \
go build -v -o out/igitt.exe ./cmd/igitt; \
else \
go build -v -o out/igitt ./cmd/igitt; \
fi
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: igitt-${{ matrix.goos }}-${{ matrix.goarch }}-${{ env.LATEST_TAG }}
path: |
out/igitt*
build-windows-setup:
needs: build
runs-on: windows-latest
env:
LATEST_TAG: ${{ github.ref_name }}
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
pattern: igitt-windows-amd64-*
- name: Copy Build Artifacts
run: |
cp igitt-windows-amd64-*/* .
- name: Compile .ISS to .EXE Installer
uses: Minionguyjpro/[email protected]
with:
path: ./igitt-setup.iss
options: /Oout
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: igitt-setup-windows-amd64-${{ env.LATEST_TAG }}
path: |
out/igitt*
pre-release:
permissions:
contents: write
if: startsWith(github.ref, 'refs/tags/')
needs: build-windows-setup
runs-on: ubuntu-latest
steps:
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
pattern: igitt-*
- name: Create ZIP Archives
run: |
for dir in igitt-*; do
zip -r "${dir}.zip" "$dir"
done
- name: debug-tree
run: |
tree
- name: Release on GitHub
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
igitt-*
token: ${{ secrets.GITHUB_TOKEN }}
name: "Automatic Pre-Release: ${{ github.ref_name }}"
body: |
This is an automatic pre-release build. See the generated release notes below
generate_release_notes: true
# if tag contains debug, it should be a draft release
draft: ${{ contains(github.ref, 'debug') }}
prerelease: true