forked from CodenameCrew/CodenameEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
199 lines (174 loc) · 7.13 KB
/
release.yml
File metadata and controls
199 lines (174 loc) · 7.13 KB
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
name: Create Release Builds
on:
workflow_dispatch:
inputs:
tag_name:
description: "Release name (e.g. v1.0.5 or v1.2-rc1)"
required: true
prerelease:
description: "Is this a prerelease?"
required: true
type: boolean
custom_message:
description: "Optional pre-changelog message"
required: false
jobs:
collect-release:
name: Release ${{ github.event.inputs.tag_name }} Builds
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download Windows Full Build
uses: dawidd6/action-download-artifact@v6
with:
workflow: windows.yml
name: Codename Engine
path: artifacts/windows/full_build
allow_forks: false
- name: Download Windows Executable
uses: dawidd6/action-download-artifact@v6
with:
workflow: windows.yml
name: Codename Engine (Executable Only)
path: artifacts/windows/executable
allow_forks: false
- name: Download Mac OS Full Build
uses: dawidd6/action-download-artifact@v6
with:
workflow: macos.yml
name: Codename Engine
path: artifacts/macos/full_build
allow_forks: false
- name: Download Mac OS Executable
uses: dawidd6/action-download-artifact@v6
with:
workflow: macos.yml
name: Codename Engine (Executable Only)
path: artifacts/macos/executable
allow_forks: false
- name: Download Linux Full Build
uses: dawidd6/action-download-artifact@v6
with:
workflow: linux.yml
name: Codename Engine
path: artifacts/linux/full_build
allow_forks: false
- name: Download Linux Executable
uses: dawidd6/action-download-artifact@v6
with:
workflow: linux.yml
name: Codename Engine (Executable Only)
path: artifacts/linux/executable
allow_forks: false
- name: Prepare artifacts
run: |
mkdir -p renamed
# Windows
mv artifacts/windows/executable/CodenameEngine.exe renamed/update-windows.exe
cd artifacts/windows/full_build
zip -r ../../../renamed/"Codename Engine-Windows.zip" *
cd -
# Mac OS
mv artifacts/macos/executable/CodenameEngine renamed/update-mac
cd artifacts/macos/full_build
if [ -f CodenameEngine.tar.gz ]; then
# Keep tar.gz as-is
cp CodenameEngine.tar.gz ../../../renamed/"Codename Engine-Mac.tar.gz"
else
# Zip contents at root
zip -r ../../../renamed/"Codename Engine-Mac.zip" *
fi
cd -
# Linux
mv artifacts/linux/executable/CodenameEngine renamed/update-linux
cd artifacts/linux/full_build
zip -r ../../../renamed/"Codename Engine-Linux.zip" *
cd -
- name: Find Base Release
id: get_base_release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Looking for base release..."
PRERELEASE="${{ github.event.inputs.prerelease }}"
if [[ "$PRERELEASE" == "true" ]]; then
BASE=$(gh release list --repo ${{ github.repository }} --json tagName,isPrerelease,isDraft \
-L 50 -q '.[] | select(.isPrerelease==false and .isDraft==false) | .tagName' | head -n 1)
if [ -z "$BASE" ]; then
echo "No stable release found, resorting to prereleases."
BASE=$(gh release list --repo ${{ github.repository }} --json tagName,isDraft \
-L 1 -q '.[] | select(.isDraft==false) | .tagName')
fi
else
BASE=$(gh release list --repo ${{ github.repository }} --json tagName,isPrerelease,isDraft \
-L 50 -q '.[] | select(.isPrerelease==false and .isDraft==false) | .tagName' | head -n 1)
fi
if [ -z "$BASE" ]; then
echo "No older release found; please make sure to have at least one older release containing the 'update-assets.zip' file in order to generate the differences."
exit 1
else
echo "Base release: $BASE"
echo "base_release=$BASE" >> $GITHUB_OUTPUT
fi
- name: Prepare update-assets.zip
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Looking for 'update-assets.zip' from release '${{ steps.get_base_release.outputs.base_release }}'"
ASSETS=$(gh release view "${{ steps.get_base_release.outputs.base_release }}" \
--repo "${{ github.repository }}" \
--json assets \
| jq -r '.assets[].name')
if echo "$ASSETS" | grep -xq "update-assets.zip"; then
mkdir -p update_assets_temp renamed
echo "Downloading assets from release '${{ steps.get_base_release.outputs.base_release }}'"
gh release download "${{ steps.get_base_release.outputs.base_release }}" \
--repo ${{ github.repository }} \
--pattern "update-assets.zip" \
-D update_assets_temp
unzip -q update_assets_temp/update-assets.zip -d update_assets_temp
cd update_assets_temp
zip -r ../renamed/update-assets.zip . -i assets
else
echo "No 'update-assets.zip' file found in release '${{ steps.get_base_release.outputs.base_release }}'; please make sure to have this file in that older release in order to generate the differences."
exit 1
fi
- name: Prepare pre-changelog message
id: pre_changelog_message
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Preparing a pre-changelog message..."
BODY="If you would like to download the full builds of the engine from this release, please ignore the files starting with 'update-' as they're needed for the engine's internal autoupdater.\n\n"
if [ -n "${{ github.event.inputs.custom_message }}" ]; then
BODY="${{ github.event.inputs.custom_message }}\n${BODY}"
fi
{
echo "body<<EOF"
echo -e "$BODY"
echo "EOF"
} >> $GITHUB_OUTPUT
echo -e "Final pre-changelog message:\n\n$BODY"
- name: Create GitHub Release with Assets
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.tag_name }}
name: Release ${{ github.event.inputs.tag_name }}
draft: true
prerelease: ${{ github.event.inputs.prerelease }}
body: ${{ steps.build_body.outputs.body }}
generate_release_notes: true
files: |
renamed/Codename Engine-Windows.zip
renamed/Codename Engine-Mac.zip
renamed/Codename Engine-Mac.tar.gz
renamed/Codename Engine-Linux.zip
renamed/update-assets.zip
renamed/update-windows.exe
renamed/update-mac
renamed/update-linux