-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (81 loc) · 3.47 KB
/
Copy pathrelease.yml
File metadata and controls
99 lines (81 loc) · 3.47 KB
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
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install X11 dependencies
run: |
sudo apt-get update
sudo apt-get install -y libx11-dev xorg-dev
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23"
- name: Run tests
run: go test -v ./...
- name: Build binaries
run: |
# Extract version from tag
VERSION=${GITHUB_REF#refs/tags/}
# Linux AMD64
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.version=${VERSION}" -o gitwiz-linux-amd64
tar -czf gitwiz-linux-amd64.tar.gz gitwiz-linux-amd64
# Linux ARM64
GOOS=linux GOARCH=arm64 go build -ldflags="-s -w -X main.version=${VERSION}" -o gitwiz-linux-arm64
tar -czf gitwiz-linux-arm64.tar.gz gitwiz-linux-arm64
# macOS AMD64
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w -X main.version=${VERSION}" -o gitwiz-darwin-amd64
tar -czf gitwiz-darwin-amd64.tar.gz gitwiz-darwin-amd64
# macOS ARM64 (Apple Silicon)
GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w -X main.version=${VERSION}" -o gitwiz-darwin-arm64
tar -czf gitwiz-darwin-arm64.tar.gz gitwiz-darwin-arm64
# Windows AMD64
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w -X main.version=${VERSION}" -o gitwiz-windows-amd64.exe
zip gitwiz-windows-amd64.zip gitwiz-windows-amd64.exe
- name: Generate checksums
run: |
sha256sum gitwiz-*.tar.gz gitwiz-*.zip > checksums.txt
- name: Generate changelog
id: changelog
run: |
# Get previous tag
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
echo "First release"
git log --pretty=format:"* %s (%h)" > CHANGELOG.md
else
echo "Changes since ${PREV_TAG}"
git log ${PREV_TAG}..HEAD --pretty=format:"* %s (%h)" > CHANGELOG.md
fi
# Add checksums to changelog
echo "" >> CHANGELOG.md
echo "## Checksums" >> CHANGELOG.md
echo '```' >> CHANGELOG.md
cat checksums.txt >> CHANGELOG.md
echo '```' >> CHANGELOG.md
- name: Create Release
uses: softprops/action-gh-release@v1
with:
body_path: CHANGELOG.md
files: |
gitwiz-linux-amd64.tar.gz
gitwiz-linux-arm64.tar.gz
gitwiz-darwin-amd64.tar.gz
gitwiz-darwin-arm64.tar.gz
gitwiz-windows-amd64.zip
checksums.txt
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}