Skip to content

Commit ab10b10

Browse files
authored
Merge pull request #8 from Atlinx/feat/_add-github-actions
Add Github Actions build workflow
2 parents 987160e + b6cb5e7 commit ab10b10

File tree

6 files changed

+504
-9
lines changed

6 files changed

+504
-9
lines changed

.github/actions/build/action.yml

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: GDExtension Build
2+
description: Build GDExtension
3+
4+
inputs:
5+
platform:
6+
required: true
7+
description: Target platform.
8+
arch:
9+
required: true
10+
description: Target architecture.
11+
float-precision:
12+
default: 'single'
13+
description: Float precision (single or double).
14+
build-target-type:
15+
default: 'template_debug'
16+
description: Build type (template_debug or template_release).
17+
scons-cache:
18+
default: .scons-cache/
19+
description: Scons cache location.
20+
em_version:
21+
default: 3.1.39
22+
description: Emscripten version.
23+
em_cache_folder:
24+
default: emsdk-cache
25+
description: Emscripten cache folder.
26+
27+
runs:
28+
using: composite
29+
steps:
30+
# Android only
31+
- name: Android - Set up Java 17
32+
uses: actions/setup-java@v4
33+
if: ${{ inputs.platform == 'android' }}
34+
with:
35+
distribution: temurin
36+
java-version: 17
37+
38+
- name: Android - Remove existing Android SDK, and set up ENV vars
39+
if: ${{ inputs.platform == 'android' }}
40+
shell: sh
41+
run: |
42+
sudo rm -r /usr/local/lib/android/sdk/**
43+
export ANDROID_HOME=/usr/local/lib/android/sdk
44+
export ANDROID_SDK_ROOT=$ANDROID_HOME
45+
export ANDROID_NDK_VERSION=23.2.8568313
46+
export ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk/${ANDROID_NDK_VERSION}
47+
echo "ANDROID_HOME=$ANDROID_HOME" >> "$GITHUB_ENV"
48+
echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" >> "$GITHUB_ENV"
49+
echo "ANDROID_NDK_VERSION=$ANDROID_NDK_VERSION" >> "$GITHUB_ENV"
50+
echo "ANDROID_NDK_ROOT=$ANDROID_NDK_ROOT" >> "$GITHUB_ENV"
51+
52+
- name: Android - Set up Android SDK
53+
if: ${{ inputs.platform == 'android' }}
54+
uses: android-actions/setup-android@v3
55+
with:
56+
packages: "ndk;${{ env.ANDROID_NDK_VERSION }} cmdline-tools;latest build-tools;34.0.0 platforms;android-34 cmake;3.22.1"
57+
# Linux only
58+
- name: Linux - dependencies
59+
if: ${{ inputs.platform == 'linux' }}
60+
shell: sh
61+
run: |
62+
sudo apt-get update -qq
63+
sudo apt-get install -qqq build-essential pkg-config
64+
# Web only
65+
- name: Web - Set up Emscripten latest
66+
if: ${{ inputs.platform == 'web' }}
67+
uses: mymindstorm/setup-emsdk@v13
68+
with:
69+
version: ${{ inputs.em_version }}
70+
actions-cache-folder: ${{ inputs.em_cache_folder }}.${{ inputs.float-precision }}.${{ inputs.build-target-type }}
71+
- name: Web - Verify Emscripten setup
72+
if: ${{ inputs.platform == 'web' }}
73+
shell: sh
74+
run: |
75+
emcc -v
76+
# Windows only
77+
- name: Windows - Setup MinGW for Windows/MinGW build
78+
uses: egor-tensin/setup-mingw@v2
79+
if: ${{ inputs.platform == 'windows' }}
80+
with:
81+
version: 12.2.0
82+
# Dependencies of godot
83+
# Use python 3.x release (works cross platform)
84+
- name: Set up Python 3.x
85+
uses: actions/setup-python@v5
86+
with:
87+
# Semantic version range syntax or exact version of a Python version
88+
python-version: "3.x"
89+
# Optional - x64 or x86 architecture, defaults to x64
90+
architecture: "x64"
91+
- name: Setup scons
92+
shell: bash
93+
run: |
94+
python -c "import sys; print(sys.version)"
95+
python -m pip install scons==4.4.0
96+
scons --version
97+
# Build
98+
- name: Cache .scons_cache
99+
uses: actions/cache@v4
100+
with:
101+
path: |
102+
${{ github.workspace }}/${{ inputs.gdextension-location }}/${{ inputs.scons-cache }}/
103+
${{ github.workspace }}/${{ inputs.godot-cpp }}/${{ inputs.scons-cache }}/
104+
key: ${{ inputs.platform }}_${{ inputs.arch }}_${{ inputs.float-precision }}_${{ inputs.build-target-type }}_cache
105+
# Build godot-cpp
106+
- name: Build godot-cpp Debug Build
107+
shell: sh
108+
env:
109+
SCONS_CACHE: ${{ github.workspace }}/${{ inputs.godot-cpp }}/${{ inputs.scons-cache }}/
110+
run: |
111+
scons target=${{ inputs.build-target-type }} platform=${{ inputs.platform }} arch=${{ inputs.arch }} generate_bindings=yes precision=${{ inputs.float-precision }}
112+
working-directory: ${{ inputs.godot-cpp }}
113+
# Build gdextension
114+
- name: Build GDExtension Debug Build
115+
shell: sh
116+
env:
117+
SCONS_CACHE: ${{ github.workspace }}/${{ inputs.gdextension-location }}/${{ inputs.scons-cache }}/
118+
run: |
119+
scons target=${{ inputs.build-target-type }} platform=${{ inputs.platform }} arch=${{ inputs.arch }} precision=${{ inputs.float-precision }} production=yes
120+
working-directory: ${{ inputs.gdextension-location }}

.github/actions/sign/action.yml

+177
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
# This file incorporates work covered by the following copyright and permission notice:
2+
#
3+
# Copyright (c) Mikael Hermansson and Godot Jolt contributors.
4+
# Copyright (c) Dragos Daian.
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
# this software and associated documentation files (the "Software"), to deal in
8+
# the Software without restriction, including without limitation the rights to
9+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
# the Software, and to permit persons to whom the Software is furnished to do so,
11+
# subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in all
14+
# copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
23+
name: GDExtension Sign
24+
description: Sign Mac GDExtension
25+
26+
inputs:
27+
FRAMEWORK_PATH:
28+
description: The path of the artifact. Eg. bin/addons/my_addon/bin/libmy_addon.macos.template_release.universal.framework
29+
required: true
30+
SIGN_FLAGS:
31+
description: The extra flags to use. Eg. --deep
32+
required: false
33+
APPLE_CERT_BASE64:
34+
required: true
35+
description: Base64 file from p12 certificate.
36+
APPLE_CERT_PASSWORD:
37+
required: true
38+
description: Password set when creating p12 certificate from .cer certificate.
39+
APPLE_DEV_PASSWORD:
40+
required: true
41+
description: Apple App-Specific Password. Eg. abcd-abcd-abcd-abcd
42+
APPLE_DEV_ID:
43+
required: true
44+
description: Email used for Apple Id. Eg. email@provider.com
45+
APPLE_DEV_TEAM_ID:
46+
required: true
47+
description: Apple Team Id. Eg. 1ABCD23EFG
48+
APPLE_DEV_APP_ID:
49+
required: true
50+
description: |
51+
Certificate name from get info -> Common name . Eg. Developer ID Application: Common Name (1ABCD23EFG)
52+
outputs:
53+
zip_path:
54+
value: ${{ steps.sign.outputs.path }}
55+
56+
57+
runs:
58+
using: composite
59+
steps:
60+
- name: Sign
61+
id: sign
62+
shell: pwsh
63+
run: |
64+
#!/usr/bin/env pwsh
65+
66+
# Copyright (c) Mikael Hermansson and Godot Jolt contributors.
67+
68+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
69+
# this software and associated documentation files (the "Software"), to deal in
70+
# the Software without restriction, including without limitation the rights to
71+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
72+
# the Software, and to permit persons to whom the Software is furnished to do so,
73+
# subject to the following conditions:
74+
75+
# The above copyright notice and this permission notice shall be included in all
76+
# copies or substantial portions of the Software.
77+
78+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
79+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
80+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
81+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
82+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
83+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
84+
85+
# Taken from https://github.com/godot-jolt/godot-jolt/blob/master/scripts/ci_sign_macos.ps1
86+
87+
Set-StrictMode -Version Latest
88+
$ErrorActionPreference = "Stop"
89+
90+
$CodesignPath = Get-Command codesign | Resolve-Path
91+
92+
$CertificateBase64 = "${{inputs.APPLE_CERT_BASE64}}"
93+
$CertificatePassword = "${{inputs.APPLE_CERT_PASSWORD}}"
94+
$CertificatePath = [IO.Path]::ChangeExtension((New-TemporaryFile), "p12")
95+
96+
$Keychain = "ephemeral.keychain"
97+
$KeychainPassword = (New-Guid).ToString().Replace("-", "")
98+
99+
$DevId = "${{ inputs.APPLE_DEV_ID }}"
100+
$DevTeamId = "${{ inputs.APPLE_DEV_TEAM_ID }}"
101+
$DevPassword = "${{ inputs.APPLE_DEV_PASSWORD }}"
102+
$DeveloperIdApplication = "${{ inputs.APPLE_DEV_APP_ID }}"
103+
104+
if (!$CertificateBase64) { throw "No certificate provided" }
105+
if (!$CertificatePassword) { throw "No certificate password provided" }
106+
if (!$DevId) { throw "No Apple Developer ID provided" }
107+
if (!$DeveloperIdApplication) { throw "No Apple Developer ID Application provided" }
108+
if (!$DevTeamId) { throw "No Apple Team ID provided" }
109+
if (!$DevPassword) { throw "No Apple Developer password provided" }
110+
111+
Write-Output "Decoding certificate..."
112+
113+
$Certificate = [Convert]::FromBase64String($CertificateBase64)
114+
115+
Write-Output "Writing certificate to disk..."
116+
117+
[IO.File]::WriteAllBytes($CertificatePath, $Certificate)
118+
119+
Write-Output "Creating keychain..."
120+
121+
security create-keychain -p $KeychainPassword $Keychain
122+
123+
Write-Output "Setting keychain as default..."
124+
125+
security default-keychain -s $Keychain
126+
127+
Write-Output "Importing certificate into keychain..."
128+
security import $CertificatePath `
129+
-k ~/Library/Keychains/$Keychain `
130+
-P $CertificatePassword `
131+
-T $CodesignPath
132+
Write-Output "Check identities..."
133+
134+
security find-identity
135+
136+
Write-Output "Granting access to keychain..."
137+
138+
security set-key-partition-list -S "apple-tool:,apple:" -s -k $KeychainPassword $Keychain
139+
140+
$Framework = "${{ inputs.FRAMEWORK_PATH }}"
141+
$SignFlags = "${{ inputs.SIGN_FLAGS }}"
142+
$Archive = [IO.Path]::ChangeExtension((New-TemporaryFile), "zip")
143+
144+
Write-Output "Signing '$Framework'..."
145+
146+
& $CodesignPath --verify --timestamp --verbose "$SignFlags" --sign $DeveloperIdApplication "$Framework"
147+
148+
Write-Output "Verifying signing..."
149+
150+
& $CodesignPath --verify -dvvv "$Framework"
151+
152+
Get-ChildItem -Force -Recurse -Path "$Framework"
153+
154+
Write-Output "Archiving framework to '$Archive'..."
155+
156+
ditto -ck -rsrc --sequesterRsrc --keepParent "$Framework" "$Archive"
157+
158+
Write-Output "Submitting archive for notarization..."
159+
160+
$output = xcrun notarytool submit "$Archive" `
161+
--apple-id $DevId `
162+
--team-id $DevTeamId `
163+
--password $DevPassword `
164+
--wait
165+
echo $output
166+
$matches = $output -match '((\d|[a-z])+-(\d|[a-z])+-(\d|[a-z])+-(\d|[a-z])+-(\d|[a-z])+)'
167+
if ($output) {
168+
$id_res = $matches[0].Substring(6)
169+
}
170+
xcrun notarytool log $id_res `
171+
--apple-id $DevId `
172+
--team-id $DevTeamId `
173+
--password $DevPassword `
174+
developer_log.json
175+
get-content developer_log.json
176+
177+
echo "path=$Archive" >> $env:GITHUB_OUTPUT

0 commit comments

Comments
 (0)