-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (113 loc) · 3.26 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
name: Lint, build and upload Igitt
on:
push:
# branches: ["main"]
tags:
- "v[0-9]+.[0-9]+.[0-9]+.*"
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:
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: Get latest tag and short commit SHA
run: |
echo "LATEST_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
echo "SHORT_COMMIT=$(git rev-parse --short HEAD)" >> $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 }}-${{ env.SHORT_COMMIT }}
path: |
out/igitt*
pre-release:
permissions:
contents: write
if: startsWith(github.ref, 'refs/tags/')
needs: build
runs-on: ubuntu-latest
steps:
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
pattern: igitt-*
- name: debug-tree
run: |
tree
- name: Release on GitHub
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
igitt-*
tag_name: ${{ env.LATEST_TAG }}
token: ${{ secrets.GITHUB_TOKEN }}
name: "Automatic Pre-Release: ${{ env.LATEST_TAG }}-${{ env.SHORT_COMMIT }}"
body: |
This is an automatic pre-release build.
draft: false
prerelease: true