-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (90 loc) · 2.92 KB
/
build.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
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
name: Go Cross-Platform Build
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go-version: ['1.23.0']
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go-version }}-
- name: Install dependencies
run: go mod download
- name: Build for ${{ matrix.os }}
run: |
echo "Starting build for $RUNNER_OS..."
if [[ "$RUNNER_OS" == "Linux" ]]; then
GOOS=linux GOARCH=amd64 go build -o builds/SkyeCraft-linux
elif [[ "$RUNNER_OS" == "macOS" ]]; then
GOOS=darwin GOARCH=amd64 go build -o builds/SkyeCraft-macOS
elif [[ "$RUNNER_OS" == "Windows" ]]; then
GOOS=windows GOARCH=amd64 go build -ldflags="-H windowsgui" -o builds/SkyeCraft.exe
fi
echo "Build completed for $RUNNER_OS."
shell: bash
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: SkyeCraft
path: builds/
- name: Print build folder contents
run: |
echo "Listing contents of builds/ folder"
ls -la builds/
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v1.0.${{ github.run_number }}
release_name: "SkyeCraft Release v1.0.${{ github.run_number }}"
draft: false
prerelease: false
- name: Upload SkyeCraft-macOS binary
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: builds/SkyeCraft-macOS
asset_name: SkyeCraft-macOS
asset_content_type: application/octet-stream
- name: Upload SkyeCraft-linux binary
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: builds/SkyeCraft-linux
asset_name: SkyeCraft-linux
asset_content_type: application/octet-stream
- name: Upload SkyeCraft.exe binary
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: builds/SkyeCraft.exe
asset_name: SkyeCraft.exe
asset_content_type: application/octet-stream