Skip to content

Commit e544bca

Browse files
authored
feat: improve pipeline to publish release builds (#170)
* feat: improve pipeline to publish release builds * fix: issues with workflows * refactor: publish process * fix: overwrite godot master to 4.1 because the api changed from 4.1->4.2 * fix: issue with wrong version name for release
1 parent 3d86e6c commit e544bca

File tree

3 files changed

+154
-5
lines changed

3 files changed

+154
-5
lines changed

.github/workflows/get_version.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ name: 🆚 Get godot version
33

44
on:
55
workflow_call:
6-
# Map the workflow outputs to job outputs
76
outputs:
87
version:
98
description: "Which version we should use based on target branch"
109
value: ${{ jobs.version.outputs.version }}
1110

11+
# We use a godot tag(rc version) as default version for master
12+
# because the api is changing often and this would lead to a lot of struggle
13+
env:
14+
MASTER_VERSION: 4.1
15+
1216
jobs:
1317
version:
1418
name: Get godot version
@@ -18,13 +22,15 @@ jobs:
1822
steps:
1923
- name: 🏷 Get and set godot version
2024
id: version
21-
# TODO: GH-Action should extract target branch; branches should be named according to godot engine branches
2225
run: |
23-
VERSION="4.1"
26+
VERSION="${{ github.event.pull_request.base.ref || github.base_ref || github.event.release.target_commitish }}"
27+
if [[ $VERSION == "master" ]]; then
28+
VERSION="$MASTER_VERSION"
29+
echo "We are overwrite master to latest rc version: $VERSION"
30+
fi
2431
echo "version=$VERSION" >> $GITHUB_OUTPUT
2532
2633
- name: 🌳 Log Valid Version
2734
env:
2835
VERSION: ${{ steps.version.outputs.version }}
2936
run: echo "$VERSION"
30-

.github/workflows/release_builds.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: 🦅 Release Builds
2+
on:
3+
workflow_call:
4+
inputs:
5+
version:
6+
required: true
7+
type: string
8+
9+
concurrency:
10+
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-android
11+
cancel-in-progress: true
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
rename:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: ⏬ Checkout repo
21+
uses: actions/checkout@v4
22+
23+
- name: 📛 Add version to release name
24+
uses: actions/github-script@v6
25+
with:
26+
result-encoding: json
27+
script: |
28+
const { repo, owner } = context.repo;
29+
const date = new Date();
30+
const year = date.getFullYear().toString();
31+
const month = (date.getMonth() + 1).toString().padStart(2,"0");
32+
const day = (date.getDay() + 1).toString().padStart(2,"0");
33+
await github.rest.repos.updateRelease({
34+
owner,
35+
repo,
36+
release_id: context.payload.release.id,
37+
name: '${{ inputs.version }}-' + context.payload.release.name + '-' + year + month + day,
38+
});
39+
40+
release:
41+
runs-on: ubuntu-latest
42+
name: ${{ matrix.name }}
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
name:
47+
- android-template
48+
- ios-template
49+
- linux-editor-mono
50+
- linux-template-minimal
51+
- linux-template-mono
52+
- macos-editor
53+
- macos-template
54+
- web-template
55+
- windows-editor
56+
- windows-template
57+
steps:
58+
- name: ⏬ Checkout repo
59+
uses: actions/checkout@v4
60+
61+
- name: ⏬ Download build
62+
uses: actions/download-artifact@v3
63+
with:
64+
name: ${{ matrix.name }}
65+
path: ${{ matrix.name }}
66+
67+
- name: 📦 Pack build as zip
68+
run: zip -r ${{ matrix.name }}.zip ${{ matrix.name }}
69+
shell: bash
70+
71+
- name: ⏫ Upload Release Asset
72+
id: upload-release-asset
73+
uses: actions/github-script@v6
74+
with:
75+
result-encoding: json
76+
script: |
77+
const FS = require('node:fs')
78+
const { repo, owner } = context.repo;
79+
return await github.rest.repos.uploadReleaseAsset({
80+
owner,
81+
repo,
82+
release_id: context.payload.release.id,
83+
name: '${{ matrix.name }}.zip',
84+
data: FS.readFileSync('${{ github.workspace }}/${{ matrix.name }}.zip')
85+
});

.github/workflows/runner.yml

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
name: 🔗 GHA
2-
on: [push, pull_request]
2+
3+
# Only run pipeline on open pull_requests and master + versions + releases
4+
# we don't need it on every push and some parameters are not available for push only
5+
on:
6+
pull_request:
7+
push:
8+
branches:
9+
- "master"
10+
- "3.4"
11+
- "4.1"
12+
release:
13+
types: [published]
314

415
concurrency:
516
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-runner
@@ -58,3 +69,50 @@ jobs:
5869
uses: ./.github/workflows/web_builds.yml
5970
with:
6071
version: ${{ needs.get-version.outputs.version }}
72+
73+
checks-done:
74+
if: ${{ always() }}
75+
name: ✅ Check builds
76+
runs-on: ubuntu-latest
77+
steps:
78+
- name: 🎉 Checks done
79+
run: |
80+
resultWebBuild="${{ needs.web-build.result }}"
81+
resultWindowsBuild="${{ needs.windows-build.result }}"
82+
resultMacosBuild="${{ needs.macos-build.result }}"
83+
resultLinuxBuild="${{ needs.linux-build.result }}"
84+
resultIosBuild="${{ needs.ios-build.result }}"
85+
resultAndroidBuild="${{ needs.android-build.result }}"
86+
if [[
87+
$resultWebBuild == "success" &&
88+
$resultWindowsBuild == "success" &&
89+
$resultMacosBuild == "success" &&
90+
$resultLinuxBuild == "success" &&
91+
$resultIosBuild == "success" &&
92+
$resultAndroidBuild == "success"
93+
]];
94+
then
95+
echo "🎉 All builds were successful."
96+
exit 0
97+
else
98+
echo "😥 Some builds were failing."
99+
exit 1
100+
fi
101+
needs:
102+
[
103+
web-build,
104+
windows-build,
105+
macos-build,
106+
linux-build,
107+
ios-build,
108+
android-build
109+
]
110+
111+
release:
112+
name: 🦅 Release
113+
if: github.event_name == 'release' && github.event.action == 'published'
114+
needs: [checks-done]
115+
uses: ./.github/workflows/release_builds.yml
116+
secrets: inherit
117+
with:
118+
version: ${{ needs.get-version.outputs.version }}

0 commit comments

Comments
 (0)