-
Notifications
You must be signed in to change notification settings - Fork 3
111 lines (94 loc) · 3.88 KB
/
release.yml
File metadata and controls
111 lines (94 loc) · 3.88 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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
name: Release (${{ matrix.goos }}/${{ matrix.goarch }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- goos: linux
goarch: amd64
runner: ubuntu-latest
- goos: linux
goarch: arm64
runner: ubuntu-24.04-arm
- goos: windows
goarch: amd64
runner: ubuntu-latest
- goos: windows
goarch: arm64
runner: ubuntu-latest
- goos: darwin
goarch: amd64
runner: ubuntu-latest
- goos: darwin
goarch: arm64
runner: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
- name: Install CGO deps (Linux only)
if: matrix.goos == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y build-essential libasound2-dev
- name: Set binary extension
id: bin
run: |
if [ "${{ matrix.goos }}" = "windows" ]; then
echo "ext=.exe" >> $GITHUB_OUTPUT
else
echo "ext=" >> $GITHUB_OUTPUT
fi
- name: Set CGO flag
id: cgo
run: |
if [ "${{ matrix.goos }}" = "linux" ]; then
echo "enabled=1" >> $GITHUB_OUTPUT
else
echo "enabled=0" >> $GITHUB_OUTPUT
fi
- name: Build Discord bot
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: ${{ steps.cgo.outputs.enabled }}
run: |
mkdir -p dist
BUILD_DATE=$(date -u +"%Y-%m-%dT%H-%M-%SZ")
GIT_COMMIT=$(git rev-parse --short HEAD)
go build -trimpath -ldflags="-s -w -X github.com/keshon/buildinfo.Version=${GITHUB_REF_NAME} -X github.com/keshon/buildinfo.Commit=${GIT_COMMIT} -X github.com/keshon/buildinfo.BuildTime=${BUILD_DATE}" -o dist/melodix-discord${{ steps.bin.outputs.ext }} ./cmd/discord/
- name: Build CLI player
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: ${{ steps.cgo.outputs.enabled }}
run: |
go build -trimpath -ldflags="-s -w -X github.com/keshon/buildinfo.Version=${GITHUB_REF_NAME} -X github.com/keshon/buildinfo.Commit=${GIT_COMMIT} -X github.com/keshon/buildinfo.BuildTime=${BUILD_DATE}" -o dist/melodix-cli${{ steps.bin.outputs.ext }} ./cmd/cli/
- name: Prepare release bundle
run: |
PKG_ROOT="melodix-${{ matrix.goos }}-${{ matrix.goarch }}"
mkdir -p "${PKG_ROOT}"
cp dist/* "${PKG_ROOT}/"
cp README.md LICENSE "${PKG_ROOT}/"
[ -f .env.example ] && cp .env.example "${PKG_ROOT}/.env"
mkdir -p "${PKG_ROOT}/data"
[ -d assets ] && cp -R assets "${PKG_ROOT}/"
zip -r "dist/${PKG_ROOT}.zip" "${PKG_ROOT}"
- name: Publish release
uses: softprops/action-gh-release@v2
with:
files: dist/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}