-
Notifications
You must be signed in to change notification settings - Fork 5
177 lines (153 loc) · 5.08 KB
/
Copy pathrelease.yml
File metadata and controls
177 lines (153 loc) · 5.08 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
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
176
177
name: Build and Release
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
tests:
uses: ./.github/workflows/tests.yml
build:
name: Build binaries
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
output: audplexus-linux-amd64
- goos: linux
goarch: arm64
output: audplexus-linux-arm64
- goos: darwin
goarch: amd64
output: audplexus-darwin-amd64
- goos: darwin
goarch: arm64
output: audplexus-darwin-arm64
- goos: windows
goarch: amd64
output: audplexus-windows-amd64.exe
- goos: windows
goarch: arm64
output: audplexus-windows-arm64.exe
steps:
- name: Checkout audplexus
uses: actions/checkout@v6
with:
path: audplexus
- name: Checkout go-audible
uses: actions/checkout@v6
with:
repository: mstrhakr/go-audible
path: go-audible
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache-dependency-path: audplexus/go.sum
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
working-directory: audplexus
run: |
# Pure Go build - no CGO needed (using modernc.org/sqlite)
mkdir -p ../build
go build -ldflags="-s -w" -o ../build/${{ matrix.output }} ./cmd/server
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.output }}
path: build/${{ matrix.output }}
release:
name: Create GitHub Release
needs:
- tests
- build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Download all artifacts
uses: actions/download-artifact@v5
with:
path: release-artifacts
- name: Prepare release assets
run: |
mkdir -p release
cd release-artifacts
for dir in */; do
binary=$(basename "$dir")
if [[ "$binary" == *.exe ]]; then
# Windows binary - create zip
cd "$dir"
chmod +x "$binary" 2>/dev/null || true
zip "../../release/${binary%.exe}.zip" "$binary"
cd ..
else
# Unix binary - create tar.gz
cd "$dir"
chmod +x "$binary"
tar czf "../../release/${binary}.tar.gz" "$binary"
cd ..
fi
done
- name: Extract release notes
id: extract-notes
run: |
TAG=${GITHUB_REF#refs/tags/}
echo "tag=$TAG" >> $GITHUB_OUTPUT
# Try to extract changelog section for this version
if [ -f CHANGELOG.md ]; then
VERSION=${TAG#v}
NOTES=$(awk "/^## \[$VERSION\]|^## $VERSION/,/^## /" CHANGELOG.md | sed '$d' | tail -n +2)
if [ -z "$NOTES" ]; then
NOTES="Release $TAG"
fi
else
NOTES=$(cat <<-END
Release $TAG
## Installation
Download the appropriate binary for your platform and run it.
### Docker
\`\`\`bash
docker pull ghcr.io/mstrhakr/audplexus:$TAG
\`\`\`
See the [README](https://github.com/mstrhakr/audplexus#readme) for configuration options.
END
)
fi
{
echo "notes<<EOF"
echo "$NOTES"
echo "EOF"
} >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: release/*
body: ${{ steps.extract-notes.outputs.notes }}
draft: false
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
- name: Update floating version tags
run: |
TAG=${GITHUB_REF#refs/tags/}
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "Not a semver tag ($TAG), skipping floating tag update"
exit 0
fi
MAJOR=$(echo "$TAG" | grep -oP '^v[0-9]+')
MINOR=$(echo "$TAG" | grep -oP '^v[0-9]+\.[0-9]+')
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git tag -fa "$MAJOR" -m "Floating tag → $TAG"
git tag -fa "$MINOR" -m "Floating tag → $TAG"
git push origin "$MAJOR" --force
git push origin "$MINOR" --force
echo "Moved $MAJOR and $MINOR → $TAG"