forked from ikemen-engine/Ikemen-GO
-
Notifications
You must be signed in to change notification settings - Fork 0
228 lines (217 loc) · 8.62 KB
/
releases.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
on:
push:
branches: [ develop ]
workflow_dispatch:
inputs:
tag:
description: 'Tag for the new release. Use semantic versioning e.g. v1.0.0. Leave empty to only update the nightly build.'
type: string
required: false
default: ''
prerelease:
description: 'Set as a pre-release.'
type: boolean
required: false
default: false
makeLatest:
description: 'Set as the latest release.'
type: boolean
required: false
default: true
draft:
description: 'Set as a draft release.'
type: boolean
required: false
default: false
discussionCategory:
description: 'When provided this will generate a discussion of the specified category, e.g. Announcements.'
type: string
required: false
default: ''
permissions:
checks: write
contents: write
name: releases
jobs:
tag:
name: prepare tag
if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
outputs:
version: ${{ env.version }}
buildTime: ${{ env.buildTime }}
#previousTag: ${{ steps.previousTag.outputs.tag }}
steps:
- uses: actions/checkout@v4
#- name: Get previous tag
# id: previousTag
# uses: actions-ecosystem/action-get-latest-tag@v1
# with:
# semver_only: true
- name: Set version
run: |
if [ "${{ github.event.inputs.tag }}" != "" ]; then
echo "version=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
else
echo "version=nightly" >> $GITHUB_ENV
fi
echo "buildTime=$(date '+%Y-%m-%d')" >> $GITHUB_ENV
shell: bash
build:
name: prepare release
if: ${{ github.actor != 'dependabot[bot]' }}
needs: tag
strategy:
matrix:
cfg:
- runner_os: windows
os: windows-2022
goos: windows
goarch: amd64
bin: Ikemen_GO.exe
glibc: ''
target: ''
- runner_os: linux
os: ubuntu-20.04 # ubuntu-22.04 / ubuntu-18.04 (deprecated)
goos: linux
goarch: amd64
bin: Ikemen_GO_Linux
glibc: '2.13'
target: ''
- runner_os: macos
os: macos-11 # macos-10.15 (deprecated)
goos: darwin
goarch: amd64
bin: Ikemen_GO_MacOS
glibc: ''
target: '10.7'
runs-on: ${{ matrix.cfg.os }}
steps:
- uses: actions/checkout@v4
- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v4
with:
go-version: ~1.20
#go-version-file: go.mod
#cache-key-suffix: -ikemen
- name: Install dependencies
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get update && sudo apt-get install -y libasound2-dev libgl1-mesa-dev xorg-dev libgtk-3-dev
fi
shell: bash
- name: Build
run: |
ldflags="-X 'main.Version=${{ needs.tag.outputs.version }}' -X 'main.BuildTime=${{ needs.tag.outputs.buildTime }}'"
export GOOS="${{ matrix.cfg.goos }}"
export GOARCH="${{ matrix.cfg.goarch }}"
export CGO_ENABLED=1
if [ "${{ matrix.cfg.glibc }}" != "" ]; then
wget https://raw.githubusercontent.com/wheybags/glibc_version_header/master/version_headers/x64/force_link_glibc_${{ matrix.cfg.glibc }}.h -O $PWD/force_link_glibc.h
export CGO_CFLAGS="$CGO_CFLAGS -include $PWD/force_link_glibc.h"
export CGO_CXXFLAGS="$CGO_CXXFLAGS -include $PWD/force_link_glibc.h"
fi
if [ "$RUNNER_OS" == "macOS" ]; then
export CGO_LDFLAGS="$CGO_LDFLAGS -mmacosx-version-min=${{ matrix.cfg.target }}"
export CGO_CFLAGS="$CGO_CFLAGS -mmacosx-version-min=${{ matrix.cfg.target }}"
export CGO_CXXFLAGS="$CGO_CXXFLAGS -mmacosx-version-min=${{ matrix.cfg.target }}"
elif [ "$RUNNER_OS" == "Windows" ]; then
ldflags="$ldflags -H windowsgui"
cd windres
windres -o ../src/ikemen_go.syso Ikemen_GO.rc
cd ..
fi
echo "ldflags: $ldflags"
echo "CGO_LDFLAGS: $CGO_LDFLAGS"
echo "CGO_CFLAGS: $CGO_CFLAGS"
echo "CGO_CXXFLAGS: $CGO_CXXFLAGS"
go env -w GO111MODULE=on
go mod download
go build -v -ldflags "$ldflags" -o ./${{ matrix.cfg.bin }} ./src
if [ "$RUNNER_OS" != "Windows" ]; then
chmod +x ${{ matrix.cfg.bin }}
fi
shell: bash
- name: Prepare artifacts
id: artifacts
run: |
echo "Preparing files for deployment"
mkdir deploy
cp ${{ matrix.cfg.bin }} deploy/
git clone https://github.com/ikemen-engine/Ikemen_GO-Elecbyte-Screenpack.git
cp -r data external font Ikemen_GO-Elecbyte-Screenpack/chars Ikemen_GO-Elecbyte-Screenpack/data Ikemen_GO-Elecbyte-Screenpack/font Ikemen_GO-Elecbyte-Screenpack/sound Ikemen_GO-Elecbyte-Screenpack/stages deploy/
cp License.txt deploy/
cp Ikemen_GO-Elecbyte-Screenpack/LICENCE.txt deploy/ScreenpackLicense.txt
echo "Zipping deploy directory"
cd deploy
if [ "${{ github.event.inputs.tag }}" == "" ]; then
ARTIFACT_NAME=Ikemen_GO-dev-${{ matrix.cfg.runner_os }}.zip
echo "artifact=$ARTIFACT_NAME" >> "$GITHUB_OUTPUT"
echo "${{ needs.tag.outputs.buildTime }}" > external/script/version
else
ARTIFACT_NAME=Ikemen_GO-${{ needs.tag.outputs.version }}-${{ matrix.cfg.runner_os }}.zip
echo "artifact=$ARTIFACT_NAME" >> "$GITHUB_OUTPUT"
echo "${{ needs.tag.outputs.version }}" > external/script/version
fi
if [ "$RUNNER_OS" == "Windows" ]; then
"/c/Program Files/7-Zip/7z.exe" a ../$ARTIFACT_NAME *
else
cp ../build/Ikemen_GO.command .
zip -r ../$ARTIFACT_NAME *
fi
echo "Successfully prepared assets for deployment"
shell: bash
- name: Update dev release
if: "${{ github.event.inputs.tag == '' }}"
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.IKEMEN_TOKEN }}
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: "${{ steps.artifacts.outputs.artifact }}"
body: |
The nightly release, or more precisely, the latest development version, is generated after each commit and always represents the most up-to-date iteration of the source code. It features the newest development version of the engine and screenpack files, making it ready for testing straightaway. Using it can eliminate the need to compile the source code for the latest, cutting-edge updates. However, as a consequence, it may sometimes contain regressions that were not yet discovered and/or outpace the documentation that corresponds to stable releases with version numbers like v x.x.x.
discussionCategory: ""
draft: false
generateReleaseNotes: false
makeLatest: false
name: nightly
omitBody: false
omitBodyDuringUpdate: false
omitDraftDuringUpdate: true
omitName: false
omitNameDuringUpdate: true
omitPrereleaseDuringUpdate: true
prerelease: true
removeArtifacts: false
replacesArtifacts: true
skipIfReleaseExists: false
tag: nightly
updateOnlyUnreleased: false
- name: Create Release
if: "${{ github.event.inputs.tag != '' }}"
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.IKEMEN_TOKEN }}
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: "${{ steps.artifacts.outputs.artifact }}"
# body: |
# ${{ needs.tag.outputs.changelog }}
discussionCategory: ${{ github.event.inputs.discussionCategory }}
draft: ${{ github.event.inputs.draft }}
generateReleaseNotes: true
makeLatest: ${{ github.event.inputs.makeLatest }}
name: ${{ needs.tag.outputs.version }}
omitBody: false
omitBodyDuringUpdate: true
omitDraftDuringUpdate: true
omitName: false
omitNameDuringUpdate: true
omitPrereleaseDuringUpdate: true
prerelease: ${{ github.event.inputs.prerelease }}
removeArtifacts: false
replacesArtifacts: true
skipIfReleaseExists: false
tag: ${{ needs.tag.outputs.version }}
updateOnlyUnreleased: false