Skip to content

Commit 422cd4e

Browse files
author
molty3000
committed
ci: add test and release workflows
test.yml: - Runs on push/PR to main - go test -race -coverprofile - go vet release.yml: - Triggers on v* tags - Cross-compile linux/darwin amd64/arm64 - CGO_ENABLED=0, ldflags for version - Attach binaries + checksums to GitHub release
1 parent 25d5dab commit 422cd4e

2 files changed

Lines changed: 85 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags: ["v*"]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
goos: [linux, darwin]
13+
goarch: [amd64, arm64]
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: actions/setup-go@v5
18+
with:
19+
go-version: "1.24"
20+
21+
- name: build
22+
env:
23+
GOOS: ${{ matrix.goos }}
24+
GOARCH: ${{ matrix.goarch }}
25+
CGO_ENABLED: "0"
26+
run: |
27+
TAG=${GITHUB_REF#refs/tags/}
28+
go build -ldflags "-s -w -X main.version=${TAG}" -o kode-${{ matrix.goos }}-${{ matrix.goarch }} ./cmd/kode
29+
30+
- name: upload artifact
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: kode-${{ matrix.goos }}-${{ matrix.goarch }}
34+
path: kode-${{ matrix.goos }}-${{ matrix.goarch }}
35+
36+
release:
37+
needs: build
38+
runs-on: ubuntu-latest
39+
permissions:
40+
contents: write
41+
steps:
42+
- uses: actions/download-artifact@v4
43+
with:
44+
pattern: kode-*
45+
merge-multiple: true
46+
47+
- name: checksums
48+
run: sha256sum kode-* > checksums.txt
49+
50+
- name: release
51+
uses: softprops/action-gh-release@v2
52+
with:
53+
files: |
54+
kode-linux-amd64
55+
kode-linux-arm64
56+
kode-darwin-amd64
57+
kode-darwin-arm64
58+
checksums.txt
59+
generate_release_notes: true

.github/workflows/test.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: actions/setup-go@v5
16+
with:
17+
go-version: "1.24"
18+
19+
- name: test
20+
run: go test ./... -race -coverprofile=coverage.out -covermode=atomic -count=1
21+
22+
- name: coverage
23+
run: go tool cover -func=coverage.out
24+
25+
- name: vet
26+
run: go vet ./...

0 commit comments

Comments
 (0)