forked from ddnet/ddnet
-
Notifications
You must be signed in to change notification settings - Fork 14
186 lines (163 loc) · 6.12 KB
/
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
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
# .github/workflows/release.yml
name: Create Release
on:
workflow_dispatch:
inputs:
tag_name:
description: 'Tag for the release (e.g., v1.0.0)'
required: true
release_name:
description: 'Name of the release'
required: true
body:
description: 'Release description'
required: false
run_id:
description: 'Run ID of the build workflow to download artifacts from'
required: true
jobs:
release:
runs-on: ubuntu-latest
env:
BUILD_PREFIX: ddnet
CLIENT_NAME: TClient
TARGET_REPOSITORY: ${{ github.repository }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download Ubuntu artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.BUILD_PREFIX }}-ubuntu-latest
path: ./artifacts/ubuntu
github-token: ${{ secrets.GH_PAT }}
repository: ${{ env.TARGET_REPOSITORY }}
run-id: ${{ github.event.inputs.run_id }}
- name: Download Windows artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.BUILD_PREFIX }}-windows-latest
path: ./artifacts/windows
github-token: ${{ secrets.GH_PAT }}
repository: ${{ env.TARGET_REPOSITORY }}
run-id: ${{ github.event.inputs.run_id }}
- name: Download macOS artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.BUILD_PREFIX }}-macOS-latest
path: ./artifacts/macOS
github-token: ${{ secrets.GH_PAT }}
repository: ${{ env.TARGET_REPOSITORY }}
run-id: ${{ github.event.inputs.run_id }}
- name: Download Android artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.BUILD_PREFIX }}-android
path: ./artifacts/android
github-token: ${{ secrets.GH_PAT }}
repository: ${{ env.TARGET_REPOSITORY }}
run-id: ${{ github.event.inputs.run_id }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.tag_name }}
release_name: ${{ github.event.inputs.release_name }}
body: ${{ github.event.inputs.body }}
draft: false
prerelease: false
- name: Rename and Move Artifacts
run: |
declare -a multi_ext=("tar.gz" "tar.bz2" "tar.xz" "tar.Z")
for dir in ./artifacts/*/ ; do
os=$(basename "$dir")
# Find the single file in the OS directory
file=$(find "$dir" -type f | head -n 1)
if [ -z "$file" ]; then
echo "No artifact found in directory $dir. Skipping."
continue
fi
filename=$(basename "$file")
extension=""
for ext in "${multi_ext[@]}"; do
if [[ "$filename" == *.$ext ]]; then
extension="$ext"
break
fi
done
if [ -z "$extension" ]; then
extension="${filename##*.}"
fi
new_name="${CLIENT_NAME}-${os}.${extension}"
echo "Renaming $file to $new_name"
mv "$file" "./artifacts/$new_name"
echo "Moved $new_name to ./artifacts/"
done
- name: Extract and Copy DDNet.exe
run: |
# Define variables
WINDOWS_ZIP="./artifacts/${CLIENT_NAME}-windows.zip"
TEMP_DIR="./artifacts/windows_temp"
mkdir -p "$TEMP_DIR"
echo "Extracting $WINDOWS_ZIP to $TEMP_DIR"
unzip -q "$WINDOWS_ZIP" -d "$TEMP_DIR"
DDNET_EXE=$(find "$TEMP_DIR" -type f -iname "DDNet.exe")
if [ -z "$DDNET_EXE" ]; then
echo "DDNet.exe not found in the extracted files."
exit 1
fi
echo "Copying DDNet.exe to ./artifacts/"
cp "$DDNET_EXE" ./artifacts/
rm -rf "$TEMP_DIR"
echo "DDNet.exe has been successfully copied to ./artifacts/"
- name: List artifacts directory
run: |
echo "Listing ./artifacts directory:"
ls -R ./artifacts
- name: Upload Ubuntu
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/${{ env.CLIENT_NAME }}-ubuntu.tar.xz
asset_name: ${{ env.CLIENT_NAME }}-ubuntu.tar.xz
asset_content_type: application/tar.xz
- name: Upload Windows
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/${{ env.CLIENT_NAME }}-windows.zip
asset_name: ${{ env.CLIENT_NAME }}-windows.zip
asset_content_type: application/zip
- name: Upload macOS
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/${{ env.CLIENT_NAME }}-macOS.dmg
asset_name: ${{ env.CLIENT_NAME }}-macOS.dmg
asset_content_type: application/dmg
- name: Upload Android
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/${{ env.CLIENT_NAME }}-android.apk
asset_name: ${{ env.CLIENT_NAME }}-android.apk
asset_content_type: application/apk
- name: Upload Raw exe
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/DDNet.exe
asset_name: DDNet.exe
asset_content_type: application/exe