Skip to content

Commit 2e8adf7

Browse files
Update go.yml
1 parent 73cc7cb commit 2e8adf7

1 file changed

Lines changed: 56 additions & 23 deletions

File tree

.github/workflows/go.yml

Lines changed: 56 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,34 @@
1-
name: Build Go Engine for All Platforms
1+
name: Build Go Engine & Create Release Assets
22

33
on:
44
workflow_dispatch:
55
push:
6-
branches: [ "main" ]
7-
paths: [ 'core_engine/**' ]
6+
tags:
7+
- 'v*.*.*'
88

99
jobs:
10-
build:
11-
# ! Use a matrix strategy to run the job for each platform
10+
build-and-release:
1211
strategy:
1312
matrix:
14-
os: [ubuntu-latest, macos-latest, windows-latest]
13+
include:
14+
- os: windows-latest
15+
goos: windows
16+
goarch: amd64
17+
arch_name: "64"
18+
- os: ubuntu-latest
19+
goos: linux
20+
goarch: amd64
21+
arch_name: "64"
22+
- os: macos-latest
23+
goos: darwin
24+
goarch: amd64
25+
arch_name: "64"
26+
- os: macos-latest
27+
goos: darwin
28+
goarch: arm64
29+
arch_name: "arm64-v8a"
1530

16-
# * Run the job on the OS specified in the matrix
1731
runs-on: ${{ matrix.os }}
18-
1932
steps:
2033
- name: Checkout repository
2134
uses: actions/checkout@v4
@@ -29,28 +42,48 @@ jobs:
2942
run: go mod tidy
3043
working-directory: ./core_engine
3144

32-
# ! Define different output names for each OS
33-
- name: Set output executable name
34-
id: set_name
45+
- name: Set output names
46+
id: set_names
3547
shell: bash
3648
run: |
37-
if [ "${{ runner.os }}" == "Windows" ]; then
38-
echo "EXE_NAME=core_engine.exe" >> $GITHUB_ENV
39-
echo "ARTIFACT_NAME=go-engine-windows" >> $GITHUB_ENV
40-
elif [ "${{ runner.os }}" == "macOS" ]; then
41-
echo "EXE_NAME=core_engine_macos" >> $GITHUB_ENV
42-
echo "ARTIFACT_NAME=go-engine-macos" >> $GITHUB_ENV
43-
else
44-
echo "EXE_NAME=core_engine_linux" >> $GITHUB_ENV
45-
echo "ARTIFACT_NAME=go-engine-linux" >> $GITHUB_ENV
49+
EXE_NAME="core_engine"
50+
if [ "${{ matrix.goos }}" == "windows" ]; then
51+
EXE_NAME="core_engine.exe"
4652
fi
53+
echo "EXE_NAME=$EXE_NAME" >> $GITHUB_ENV
54+
echo "ZIP_NAME=core_engine-${{ matrix.goos }}-${{ matrix.arch_name }}.zip" >> $GITHUB_ENV
4755
4856
- name: Build Go Executable
57+
env:
58+
GOOS: ${{ matrix.goos }}
59+
GOARCH: ${{ matrix.goarch }}
4960
run: go build -v -o ${{ env.EXE_NAME }} main.go
5061
working-directory: ./core_engine
5162

52-
- name: Upload Artifact
63+
- name: Create Zip Archive
64+
shell: bash
65+
run: |
66+
cd core_engine
67+
zip ${{ env.ZIP_NAME }} ${{ env.EXE_NAME }}
68+
cd ..
69+
70+
- name: Upload Artifact for Release
5371
uses: actions/upload-artifact@v4
5472
with:
55-
name: ${{ env.ARTIFACT_NAME }}
56-
path: core_engine/${{ env.EXE_NAME }}
73+
name: ${{ env.ZIP_NAME }}
74+
path: core_engine/${{ env.ZIP_NAME }}
75+
76+
create-release:
77+
needs: build-and-release
78+
runs-on: ubuntu-latest
79+
steps:
80+
- name: Download all build artifacts
81+
uses: actions/download-artifact@v4
82+
with:
83+
path: artifacts
84+
85+
- name: Create Release and Upload Assets
86+
uses: softprops/action-gh-release@v2
87+
with:
88+
tag_name: ${{ github.ref }}
89+
files: artifacts/**/*.zip

0 commit comments

Comments
 (0)