-
Notifications
You must be signed in to change notification settings - Fork 11
124 lines (107 loc) · 3.21 KB
/
push.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
121
122
123
124
name: Golang build and release
on:
push:
tags:
- 'v*'
pull_request:
workflow_dispatch:
inputs:
tag_name:
description: 'Release Tag'
required: true
default: 'v0.0.0'
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
if: ${{ !contains(github.event.head_commit.message, 'dev') }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04]
go: ["1.21.6"]
goos: [linux, windows]
goarch: [amd64, arm64]
steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v4
# Setup Go environment
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
# Download dependencies
- name: Download Go modules
env:
CGO_ENABLED: 0
run: |
go mod download
# Build the binaries
- name: Build binaries
env:
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
GOOS: ${{ matrix.goos }}
run: |
go build -o dist/PalworldServerConfigParser-${{ matrix.goos }}-${{ matrix.goarch }}
chmod 755 dist/*
# Verify build output
- name: Verify build output
run: |
if [ ! -f "dist/PalworldServerConfigParser-${{ matrix.goos }}-${{ matrix.goarch }}" ]; then
echo "Build output is missing!"
exit 1
fi
echo "Build completed successfully."
# Append .EXE to Windows binary
- name: Append .EXE to windows binary
run: |
if [ "${{ matrix.goos }}" == "windows" ]; then
cd dist/
mv PalworldServerConfigParser-${{ matrix.goos }}-${{ matrix.goarch }} PalworldServerConfigParser-${{ matrix.goos }}-${{ matrix.goarch }}.exe
cd ..
fi
# Upload dist folder as an artifact
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/
generate-checksum:
permissions: write-all
name: Generate checksum file
runs-on: ubuntu-22.04
needs: build
steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
# Download the dist artifact from the build job
- name: Download dist artifact
uses: actions/download-artifact@v3
with:
name: dist
path: dist
# Generate checksum.txt
- name: Generate checksum.txt
run: |
cd dist
sha256sum * > checksum.txt
cd ..
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
# Upload all artifacts to GitHub release
- name: Upload release artifacts
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ steps.generate-token.outputs.token }}
file: dist/*
tag: ${{ github.ref_name || inputs.tag_name }}
overwrite: false
file_glob: true