-
Notifications
You must be signed in to change notification settings - Fork 23
203 lines (176 loc) · 6.7 KB
/
github-actions-youtd.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
name: build-and-publish
# NOTE: disabled this export job because it doesn't work
# with webrtc lib. Webrtc lib files need to be included
# together with the game but this job for some reason fails
# to do it. It only adds executable and .pck file to the
# zip.
# on:
# push:
# # Sequence of patterns matched against refs/heads
# # branches:
# # - workflow*
# # Sequence of patterns matched against refs/tags
# tags:
# - v*
jobs:
setup:
runs-on: ubuntu-latest
name: cache repo with assets
steps:
- uses: actions/checkout@v3
- name: list assets in gdrive
uses: wei/rclone@v1
with:
args: lsf -R --filter-from rclone-filter "assets" | sort > .assets-list
env:
RCLONE_CONF: ${{ secrets.RCLONE_GDRIVE_CONF }}
- name: restore cache
uses: actions/cache@v3
with:
path: assets
key: assets-${{ hashFiles('.assets-list') }}
- name: sync assets from gdrive via rclone
uses: wei/rclone@v1
with:
args: sync -P --filter-from rclone-filter "gdrive:assets" "assets"
env:
RCLONE_CONF: ${{ secrets.RCLONE_GDRIVE_CONF }}
- name: upload repo with assets
id: upload_repo_with_assets
uses: actions/upload-artifact@v3
with:
path: |
./*
!.git/
name: repo-with-assets
- name: generate version for the build
id: version_generation
run: |
latest_tag=$(git ls-remote --tags --sort=-v:refname origin | grep -v 'vrefs/heads/main' | grep -o 'refs/tags/[^^{]*' | sed 's/refs\/tags\///' | head -n 1)
short_hash=$(git rev-parse --short HEAD)
version=${latest_tag:1}
echo "tag_version=${latest_tag}-${short_hash}" | tee -a $GITHUB_OUTPUT
echo "version=${version}" | tee -a $GITHUB_OUTPUT
echo "commit_ref=$GITHUB_REF_NAME" | tee -a $GITHUB_OUTPUT
outputs:
tag_version: ${{ steps.version_generation.outputs.tag_version }}
version: ${{ steps.version_generation.outputs.version }}
commit_ref: ${{ steps.version_generation.outputs.commit_ref }}
export_game:
runs-on: ubuntu-latest
needs: setup
name: export game
steps:
- name: download repo with assets
uses: actions/download-artifact@v3
with:
path: ./
name: repo-with-assets
- name: release requested check
run: |
if [[ ${{ needs.setup.outputs.commit_ref }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] ; then
echo "NEED=true" >> "$GITHUB_ENV"
echo 'true'
else
echo "NEED=false" >> "$GITHUB_ENV"
echo 'false'
fi
- name: update project.godot with new version
run: |
project_godot_file="${{ github.workspace }}/project.godot"
sed -i 's/\(config\/version="\).*\("\)/\1'"${{ needs.setup.outputs.tag_version }}"'\2/' "${project_godot_file}"
echo "New project.godot contents:"
cat "${project_godot_file}"
- name: update release version for Sentry lib
run: |
sed -i "s/youtd2@[0-9]\+\.[0-9]\+\.[0-9]\+/youtd2@${{ needs.setup.outputs.version }}/g" "${{ github.workspace }}/build/web/full-size.html"
- name: create .godot dirs
run: |
mkdir -p .godot/{editor,imported}
- name: export game
id: export
uses: firebelley/[email protected]
with:
godot_executable_download_url: https://github.com/godotengine/godot-builds/releases/download/4.1.3-stable/Godot_v4.1.3-stable_linux.x86_64.zip
godot_export_templates_download_url: https://github.com/godotengine/godot-builds/releases/download/4.1.3-stable/Godot_v4.1.3-stable_export_templates.tpz
relative_project_path: ./
export_debug: false
archive_output: true
cache: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: repack web artifact
run: |
zip -uj ${{ steps.export.outputs.archive_directory }}/web.zip ${{ github.workspace }}/build/web/*
cp ${{ github.workspace }}/build/web/* ${{ steps.export.outputs.build_directory }}/web/
- uses: actions/upload-artifact@v3
with:
name: youtd-${{ needs.setup.outputs.tag_version }}
path: ${{ steps.export.outputs.archive_directory }}/*.zip
if-no-files-found: error
outputs:
tag_version: ${{ needs.setup.outputs.tag_version }}
commit_ref: ${{ needs.setup.outputs.commit_ref }}
release_flag: ${{ env.NEED }}
upload_artifacts:
needs: export_game
strategy:
matrix:
platform: [windows, macos, web, linux]
runs-on: ubuntu-latest
steps:
- name: download exported files
uses: actions/download-artifact@v3
with:
name: youtd-${{ needs.export_game.outputs.tag_version }}
path: exported_files
- name: rename artifacts
id: rename_artifacts
run: |
VERSION_TAG="${{ needs.export_game.outputs.tag_version }}"
mv "exported_files/${{ matrix.platform }}.zip" "exported_files/${{ matrix.platform }}-$VERSION_TAG.zip"
echo "${{ matrix.platform }}=exported_files/$platform-$VERSION_TAG.zip" >> $GITHUB_OUTPUT
- name: upload artifacts
id: upload_artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.platform }}-${{ needs.export_game.outputs.tag_version }}
path: exported_files/${{ matrix.platform }}-${{ needs.export_game.outputs.tag_version }}.zip
outputs:
macos_artifact: ${{ steps.rename_artifacts.outputs.macos_artifact }}
linux_artifact: ${{ steps.rename_artifacts.outputs.linux_artifact }}
web_artifact: ${{ steps.rename_artifacts.outputs.web_artifact }}
windows_artifact: ${{ steps.rename_artifacts.outputs.windows_artifact }}
create_release:
name: create release
needs: [upload_artifacts, export_game]
if: needs.export_game.outputs.release_flag == 'true'
runs-on: ubuntu-latest
steps:
- name: show props
run: |
echo "Commit ref: $GITHUB_REF_NAME"
echo "Release tag: ${{ needs.export_game.outputs.commit_ref }}"
- name: download artifacts
uses: actions/download-artifact@v3
with:
path: .
- name: display structure of downloaded files
run: ls -R
working-directory: .
- name: release client
uses: ncipollo/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.export_game.outputs.commit_ref }}
generateReleaseNotes: true
artifacts: ./**/*.zip
clean_up_artifacts:
needs: [create_release, export_game]
runs-on: ubuntu-latest
steps:
- uses: geekyeggo/delete-artifact@v2
with:
name: |
youtd-${{ needs.export_game.outputs.tag_version }}
repo-with-assets