-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (57 loc) · 2.34 KB
/
go.yml
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
name: Go Build for Multiple Platforms
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch: # Allows manual triggering
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ ubuntu-latest, windows-latest] # Multiple OS platforms
arch: [ amd64 ] # Architecture
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.1'
- name: Build the project
run: |
# Determine GOOS based on matrix OS
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
GOOS=linux
elif [ "${{ matrix.os }}" = "windows-latest" ]; then
GOOS=windows
elif [ "${{ matrix.os }}" = "macos-latest" ]; then
GOOS=darwin
else
echo "Unsupported OS"
exit 1
fi
GOARCH=${{ matrix.arch }}
echo "Building for $GOOS $GOARCH"
# Create the build directory if it does not exist
mkdir -p build/${{ matrix.os == 'ubuntu-latest' && 'linux' || matrix.os == 'windows-latest' && 'windows' || matrix.os == 'macos-latest' && 'darwin' }}/${{ matrix.arch }}/untisDSB
# Build the project, ensuring to output a file in the correct directory
env GOOS=${{ matrix.os == 'ubuntu-latest' && 'linux' || matrix.os == 'windows-latest' && 'windows' || matrix.os == 'macos-latest' && 'darwin' }} GOARCH=${{ matrix.arch }} go build -o build/${{ matrix.os == 'ubuntu-latest' && 'linux' || matrix.os == 'windows-latest' && 'windows' || matrix.os == 'macos-latest' && 'darwin' }}/${{ matrix.arch }}/untisDSB main.go
- name: Test
run: go test -v ./...
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: untisDSB-${{ matrix.os }}-${{ matrix.arch }}
path: build/${{ matrix.os == 'ubuntu-latest' && 'linux' || matrix.os == 'windows-latest' && 'windows' || matrix.os == 'macos-latest' && 'darwin' }}/${{ matrix.arch }}/untisDSB
- name: List build artifacts
run: ls -R build
- name: Create Release
if: github.event_name == 'push'
uses: softprops/action-gh-release@v1
with:
files: |
untisDSB-ubuntu-latest-amd64
untisDSB-windows-latest-amd64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}