-
-
Notifications
You must be signed in to change notification settings - Fork 11
120 lines (102 loc) · 3.9 KB
/
build-release.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
108
109
110
111
112
113
114
115
116
117
118
119
120
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Build and Release
# This workflow runs linter, builds, runs unit tests, then publishes a new release for the main branch.
on:
workflow_dispatch:
push:
branches:
- 'main'
paths-ignore:
- 'docs/**'
pull_request:
branches:
- 'main'
jobs:
build:
name: Build project
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.22]
platform:
- name: windows-386
target: windows-386
- name: windows-amd64
target: windows-amd64
- name: windows-arm64
target: windows-arm64
- name: linux-386
target: linux-386
- name: linux-amd64
target: linux-amd64
- name: linux-arm64
target: linux-arm64
- name: darwin-amd64
target: apple-darwin-amd64
- name: darwin-arm64
target: apple-darwin-arm64
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Linting
run: |
go fmt ./...
go vet ./...
- name: Test
run: go test -v ./...
# For non-Windows platforms
- name: Build for ${{ matrix.platform.name }}
if: ${{ !startsWith(matrix.platform.name, 'windows-') }}
run: |
export GOOS=$(echo ${{ matrix.platform.name }} | cut -d'-' -f1)
export GOARCH=$(echo ${{ matrix.platform.name }} | cut -d'-' -f2)
go build -o llama-nb-${{ matrix.platform.target }} ./cmd/main.go
# For Windows platforms, to add .exe extension
- name: Build for ${{ matrix.platform.name }}
if: ${{ startsWith(matrix.platform.name, 'windows-') }}
run: |
export GOOS=$(echo ${{ matrix.platform.name }} | cut -d'-' -f1)
export GOARCH=$(echo ${{ matrix.platform.name }} | cut -d'-' -f2)
go build -o llama-nb-${{ matrix.platform.target }}.exe ./cmd/main.go
# For non-Windows platforms
- name: Zip build artifacts
if: ${{ !startsWith(matrix.platform.name, 'windows-') }}
run: zip -r llama-nb-${{ matrix.platform.target }}.zip llama-nb-${{ matrix.platform.target }}
# For Windows platforms
- name: Zip build artifacts
if: ${{ startsWith(matrix.platform.name, 'windows-') }}
run: zip -r llama-nb-${{ matrix.platform.target }}.zip llama-nb-${{ matrix.platform.target }}.exe
- uses: actions/upload-artifact@v4
with:
name: project-artifact-${{ matrix.platform.target }}
path: llama-nb-${{ matrix.platform.target }}.zip
release:
name: Release project
runs-on: ubuntu-latest
needs: build
steps:
- name: set env
run: echo "NOW=$(date +'%Y.%m.%d')" >> $GITHUB_ENV
- uses: actions/download-artifact@v4
with:
path: artifacts/
pattern: project-artifact-*
merge-multiple: true
- name: Publish Release
id: publish_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: artifacts/*.zip
tag_name: release-${{ github.run_number }}-${{ env.NOW }}
name: Release ${{ github.run_number }}-${{ env.NOW }}
body: |
Release ${{ github.run_number }}-${{ env.NOW }}. You can download the executable file that is suitable for your system, or complete source code.
However, your operating system (e.g. MacOS) may not allow you to run the executable files downloaded from Github directly, because it may require notarization/signing of executables.
This is not an issue to fix for this project, if you tried and failed, then you can clone this repository and compile/run it by yourself on your machine.