Skip to content

Commit b7b8d0d

Browse files
committed
test
1 parent 4da453b commit b7b8d0d

1 file changed

Lines changed: 167 additions & 0 deletions

File tree

.github/workflows/build-core.yml

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
tags:
7+
- "v*"
8+
- "*.*.*"
9+
pull_request:
10+
branches: [ main ]
11+
12+
env:
13+
CGO_CXXFLAGS: "-D__RTMIDI_DEBUG__=0 -D__RTMIDI_QUIET__"
14+
15+
defaults:
16+
run:
17+
working-directory: core
18+
19+
jobs:
20+
macos:
21+
runs-on: macos-latest
22+
steps:
23+
- uses: actions/checkout@v5
24+
25+
- name: Install rtmidi dependencies
26+
run: |
27+
brew update
28+
brew install pkg-config
29+
brew install rtmidi
30+
brew install sox
31+
32+
- uses: actions/setup-go@v6
33+
with:
34+
go-version: "stable"
35+
36+
- name: Set up environment variables
37+
run: echo "CGO_ENABLED=1" >> $GITHUB_ENV
38+
39+
- name: Test
40+
run: go test -v ./...
41+
42+
- name: Build Go project
43+
run: go build -v -ldflags "-X main.Version=${{ github.ref_name }}" -o core
44+
45+
- name: Verify binary
46+
run: ./core --help
47+
48+
- name: Zip binary (macOS)
49+
run: zip -9 core_macos.zip core
50+
51+
- name: Upload artifact (macOS)
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: core_macos.zip
55+
path: core/core_macos.zip
56+
if-no-files-found: error
57+
58+
linux:
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v5
62+
63+
- name: Install dependencies
64+
run: |
65+
sudo apt-get update
66+
sudo apt-get install -y libasound2-dev sox zip
67+
68+
- uses: actions/setup-go@v6
69+
with:
70+
go-version: "stable"
71+
72+
- name: Test
73+
run: go test -v ./...
74+
75+
- name: Build Go project
76+
run: go build -v -ldflags "-X main.Version=${{ github.ref_name }}" -o core
77+
78+
- name: Verify binary
79+
run: ./core --help
80+
81+
- name: Zip binary (Linux)
82+
run: zip -9 core_linux.zip core
83+
84+
- name: Upload artifact (Linux)
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: core_linux.zip
88+
path: core/core_linux.zip
89+
if-no-files-found: error
90+
91+
92+
windows:
93+
runs-on: windows-latest
94+
steps:
95+
- name: Checkout code
96+
uses: actions/checkout@v5
97+
98+
- name: Set up MSYS2
99+
uses: msys2/setup-msys2@v2
100+
with:
101+
msystem: MINGW64
102+
update: true
103+
104+
- name: Install required packages
105+
shell: msys2 {0}
106+
run: |
107+
pacman -S --noconfirm mingw-w64-x86_64-rtmidi mingw-w64-x86_64-toolchain
108+
109+
- name: Set up environment variables for Go
110+
shell: pwsh
111+
run: |
112+
$env:Path += ";C:\msys64\mingw64\bin"
113+
echo "CGO_ENABLED=1" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
114+
echo "CC=x86_64-w64-mingw32-gcc" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
115+
echo "CGO_LDFLAGS=-static" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
116+
echo "CGO_CXXFLAGS=-D__RTMIDI_DEBUG__=0 -D__RTMIDI_QUIET__" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
117+
118+
- uses: actions/setup-go@v6
119+
with:
120+
go-version: "stable"
121+
122+
- name: Test
123+
run: go test -v ./...
124+
125+
- name: Build Go project
126+
run: go build -v -ldflags "-X main.Version=${{ github.ref_name }}" -o core.exe
127+
128+
- name: Verify binary
129+
run: .\core.exe --help
130+
131+
- name: Zip binary (Windows)
132+
shell: pwsh
133+
run: Compress-Archive -Path core.exe -DestinationPath core_windows.zip -Force
134+
135+
- name: Upload artifact (Windows)
136+
uses: actions/upload-artifact@v4
137+
with:
138+
name: core_windows.zip
139+
path: core/core_windows.zip
140+
if-no-files-found: error
141+
142+
release:
143+
name: Create GitHub Release (on tags)
144+
runs-on: ubuntu-latest
145+
needs: [macos, linux, alpine, windows]
146+
if: startsWith(github.ref, 'refs/tags/')
147+
permissions:
148+
contents: write
149+
steps:
150+
- name: Download artifacts
151+
uses: actions/download-artifact@v4
152+
with:
153+
path: ./dist
154+
merge-multiple: true
155+
156+
- name: List artifacts
157+
run: ls -l ./dist
158+
159+
- name: Create Release and upload assets
160+
uses: softprops/action-gh-release@v2
161+
with:
162+
files: |
163+
dist/core_macos.zip
164+
dist/core_linux.zip
165+
dist/core_windows.zip
166+
env:
167+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)