Skip to content

Commit

Permalink
Add export configs and the CI setup
Browse files Browse the repository at this point in the history
Also update readme with all the necessary
details.
  • Loading branch information
YuriSizov committed Oct 29, 2024
1 parent 4cf2e45 commit ac7d6ef
Show file tree
Hide file tree
Showing 18 changed files with 1,301 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
patreon: YuriSizov
54 changes: 54 additions & 0 deletions .github/actions/export-godot-project/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Export Godot project
description: Export a project for the target platform.

inputs:
platform:
required: true
arch:
required: true
preset:
required: true
output:
required: true

project-path:
default: "."

outputs:
export-path:
value: ${{ steps.export-project-step.outputs.export-path }}

runs:
using: "composite"
steps:
- name: Import assets, scripts, extensions
shell: bash
continue-on-error: true
run: |
godot --headless --path ${{ inputs.project-path }} --import
- name: Export the project (${{ inputs.preset }})
id: export-project-step
shell: bash
env:
EXPORT_OUTPUT_PATH: export/${{ inputs.platform }}/${{ inputs.arch }}
run: |
echo "Creating the export output folder..."
mkdir -p ${{ inputs.project-path }}/${{ env.EXPORT_OUTPUT_PATH }}
echo "Exporting the project..."
godot --headless --path ${{ inputs.project-path }} --export-release "${{ inputs.preset }}" ${{ env.EXPORT_OUTPUT_PATH }}/${{ inputs.output }}
echo "export-path=${{ inputs.project-path }}/${{ env.EXPORT_OUTPUT_PATH }}" >> "$GITHUB_OUTPUT"
# Perform post-export steps.

# We need the .app folder on macOS, not the zip that Godot produces.
- name: Unzip the project (macos)
if: ${{ inputs.platform == 'macos' }}
shell: bash
env:
EXPORT_OUTPUT_PATH: export/${{ inputs.platform }}/${{ inputs.arch }}
run: |
cd ${{ inputs.project-path }}/${{ env.EXPORT_OUTPUT_PATH }}
unzip ${{ inputs.output }}
rm -f ${{ inputs.output }}
22 changes: 22 additions & 0 deletions .github/actions/make-release/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Make GitHub Release
description: Create a GitHub release as a draft, and generate its description.

inputs:
release-version:
required: true

runs:
using: "composite"
steps:
- name: Prepare release notes for this release
shell: bash
run: |
sed -i 's/\${COMMIT_HASH}/${{ github.sha }}/g' $GITHUB_ACTION_PATH/release-notes.md
sed -i 's/\${VERSION_TAG}/${{ inputs.release-version }}/g' $GITHUB_ACTION_PATH/release-notes.md
- name: Create a draft release with custom release notes
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create --verify-tag ${{ inputs.release-version }} --draft --title 'Glasan FX - ${{ inputs.release-version }}' --notes-file $GITHUB_ACTION_PATH/release-notes.md
10 changes: 10 additions & 0 deletions .github/actions/make-release/release-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
If you experience issues, [please report them](https://github.com/YuriSizov/glasan-fx/issues) as soon as you can.

## Downloads

* **[Download for Linux (x86_64)](https://github.com/YuriSizov/glasan-fx/releases/download/${VERSION_TAG}/glasan-fx-linux-x86_64.zip)**
* **[Download for macOS (Universal)](https://github.com/YuriSizov/glasan-fx/releases/download/${VERSION_TAG}/glasan-fx-macos-universal.zip)**
* **[Download for Windows (x86_64)](https://github.com/YuriSizov/glasan-fx/releases/download/${VERSION_TAG}/glasan-fx-windows-x86_64.zip)**
* **[Download for Windows (x86_32)](https://github.com/YuriSizov/glasan-fx/releases/download/${VERSION_TAG}/glasan-fx-windows-x86_32.zip)**

_Built from commit [${COMMIT_HASH}](https://github.com/YuriSizov/glasan-fx/commits/${COMMIT_HASH}/)._
27 changes: 27 additions & 0 deletions .github/actions/setup-deps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Set up Project Dependencies
description: Download and install dependencies and libraries used by the project.

inputs:
platform:
required: true
gdsion-version:
required: true

runs:
using: "composite"
steps:
- name: Install rcedit (Windows)
if: ${{ inputs.platform == 'windows' }}
shell: bash
run: |
curl -JLO https://github.com/electron/rcedit/releases/download/v2.0.0/rcedit-x64.exe
mv rcedit-x64.exe rcedit.exe
export PATH=$(realpath ./):$PATH
- name: Install GDSiON
shell: bash
env:
GDSION_PATH: https://github.com/YuriSizov/gdsion/releases/download/${{ inputs.gdsion-version }}/libgdsion-${{ inputs.platform }}.zip
run: |
curl -JLO ${{ env.GDSION_PATH }}
unzip libgdsion-${{ inputs.platform }}.zip
66 changes: 66 additions & 0 deletions .github/actions/sign-godot-project/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Codesign Godot Project
description: Codesign and notarize Godot project export artifacts.

inputs:
platform:
description: Target platform.
required: true

setup-env:
description: Flag that enables the setup step.
default: false
codesign:
description: Flag that enables the codesign step.
default: false

# Setup arguments.
apple-cert-base64:
required: true
apple-cert-password:
required: true

# Codesign arguments.
apple-dev-id:
required: true
apple-dev-app-id:
required: true
apple-dev-team-id:
required: true
apple-dev-password:
required: true

# Input/output arguments.
directory:
description: Path to the folder with the project.
required: true
target-name:
description: Name of the project executable file or folder (like on macOS).
required: true

runs:
using: composite
steps:
# macOS-specific steps.

# Setup.

- name: Set up the signing environment (macos)
if: ${{ inputs.platform == 'macos' && inputs.setup-env == 'true' }}
shell: bash
env:
APPLE_CERT_BASE64: ${{ inputs.apple-cert-base64 }}
APPLE_CERT_PASSWORD: ${{ inputs.apple-cert-password }}
run: $GITHUB_ACTION_PATH/macos/setup.sh

# Codesign.

- name: Sign and notarize the project (macos)
if: ${{ inputs.platform == 'macos' && inputs.codesign == 'true' }}
shell: bash
env:
APPLE_DEV_ID: ${{ inputs.apple-dev-id }}
APPLE_DEV_APP_ID: ${{ inputs.apple-dev-app-id }}
APPLE_DEV_TEAM_ID: ${{ inputs.apple-dev-team-id }}
APPLE_DEV_PASSWORD: ${{ inputs.apple-dev-password }}
APP_PATH: ${{ inputs.directory }}/${{ inputs.target-name }}
run: $GITHUB_ACTION_PATH/macos/sign.sh
42 changes: 42 additions & 0 deletions .github/actions/sign-godot-project/macos/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# Based on https://github.com/godot-jolt/godot-jolt/blob/master/scripts/ci_sign_macos.ps1

certificate_base64="$APPLE_CERT_BASE64"
certificate_password="$APPLE_CERT_PASSWORD"

if [ -z "${certificate_base64}" ]; then
echo "ERROR: Missing codesign certificate."
exit 1
fi
if [ -z "${certificate_password}" ]; then
echo "ERROR: Missing codesign certificate password."
exit 1
fi

# Convert the certificate back to its file form.

echo "Decoding the base64 certificate..."

certificate_path="certificate.p12"
base64 --decode -o ${certificate_path} <<< "${certificate_base64}"

# Set up the keychain and import the certificate.

keychain="ephemeral.keychain"
keychain_password="$(openssl rand -base64 16)"

echo "Creating the default keychain..."

security create-keychain -p ${keychain_password} ${keychain}
security default-keychain -s ${keychain}

echo "Importing the certificate into the keychain..."

security import ${certificate_path} -k ~/Library/Keychains/${keychain} -P ${certificate_password} -T /usr/bin/codesign
security find-identity

echo "Granting access to the keychain..."

security set-key-partition-list -S "apple-tool:,apple:" -s -k ${keychain_password} ${keychain}
security set-keychain-settings ${keychain}
52 changes: 52 additions & 0 deletions .github/actions/sign-godot-project/macos/sign.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

# Based on https://github.com/godot-jolt/godot-jolt/blob/master/scripts/ci_sign_macos.ps1

apple_dev_id="$APPLE_DEV_ID"
apple_dev_app_id="$APPLE_DEV_APP_ID"
apple_dev_team_id="$APPLE_DEV_TEAM_ID"
apple_dev_password="$APPLE_DEV_PASSWORD"

app_path="$APP_PATH"
archive_path="$APP_PATH.zip"

if [ -z "${apple_dev_id}" ]; then
echo "ERROR: Missing Apple developer ID."
exit 1
fi
if [ -z "${apple_dev_app_id}" ]; then
echo "ERROR: Missing Apple developer application ID."
exit 1
fi
if [ -z "${apple_dev_team_id}" ]; then
echo "ERROR: Missing Apple team ID."
exit 1
fi
if [ -z "${apple_dev_password}" ]; then
echo "ERROR: Missing Apple developer password."
exit 1
fi
if [ -z "${app_path}" ]; then
echo "ERROR: Missing application path to sign."
exit 1
fi

# Sign, notarize, and staple the app.

echo "Signing and verifying the app at '${app_path}'..."

codesign --timestamp --verbose --deep --force --options runtime --sign "${apple_dev_app_id}" "${app_path}"
codesign --verify "${app_path}"

echo "Archiving and notarizing the signed app..."

ditto -ck --keepParent "${app_path}" "${archive_path}"
xcrun notarytool submit "${archive_path}" --apple-id ${apple_dev_id} --team-id ${apple_dev_team_id} --password ${apple_dev_password} --wait

echo "Stapling the notarization ticket to the signed app..."

xcrun stapler staple "${app_path}"

echo "Cleaning up..."

rm -f "${archive_path}"
28 changes: 28 additions & 0 deletions .github/actions/zip-folder/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Zip up a folder
description: Create a zip archive of a folder or folders.

inputs:
filename:
description: Output file name for the archive.
default: ""
path:
description: Base path for archive files.
default: "."
directory:
description: Working directory where the command is called.
default: "."
split:
description: Create a separate archive for each directory in the base path. Folder's name is the file name.
default: false

runs:
using: composite
steps:
- name:
shell: bash
working-directory: ${{ inputs.directory }}
env:
ARCHIVE_OUTPUT_NAME: ${{ inputs.filename }}
ARCHIVE_INCLUDE_PATH: ${{ inputs.path }}
ARCHIVE_SPLIT: ${{ inputs.split == 'true' && 1 || 0 }}
run: $GITHUB_ACTION_PATH/zip.sh
36 changes: 36 additions & 0 deletions .github/actions/zip-folder/zip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# Adapted from https://github.com/TheDoctor0/zip-release.
# Create an archive or exit if the command fails.

set -eu
printf "\n📦 Creating zip archive...\n"

if [ "$RUNNER_OS" = "Windows" ]; then
if [ "$ARCHIVE_SPLIT" = 1 ]; then
for name in $ARCHIVE_INCLUDE_PATH/*; do
if [ -d "$name" ]; then
include_path="$ARCHIVE_INCLUDE_PATH/$name/"
7z a -tzip "$name.zip" $include_path || { printf "\n⛔ Unable to create zip archive from %s.\n" "$include_path"; exit 1; }
printf "\n✔ Successfully created %s archive.\n" "$name.zip"
fi
done
else
7z a -tzip "$ARCHIVE_OUTPUT_NAME" $ARCHIVE_INCLUDE_PATH || { printf "\n⛔ Unable to create zip archive from %s.\n" "$ARCHIVE_INCLUDE_PATH"; exit 1; }
printf "\n✔ Successfully created %s archive.\n" "$ARCHIVE_OUTPUT_NAME"
fi
else
if [ "$ARCHIVE_SPLIT" = 1 ]; then
for name in $ARCHIVE_INCLUDE_PATH/*; do
if [ -d "$name" ]; then
include_path="$ARCHIVE_INCLUDE_PATH/$name/"
zip -r "$name.zip" $include_path || { printf "\n⛔ Unable to create zip archive from %s.\n" "$include_path"; exit 1; }
printf "\n✔ Successfully created %s archive.\n" "$name.zip"
fi
done
else
zip -r "$ARCHIVE_OUTPUT_NAME" $ARCHIVE_INCLUDE_PATH || { printf "\n⛔ Unable to create zip archive from %s.\n" "$ARCHIVE_INCLUDE_PATH"; exit 1; }
printf "\n✔ Successfully created %s archive.\n" "$ARCHIVE_OUTPUT_NAME"
fi
fi

15 changes: 15 additions & 0 deletions .github/workflows/build-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Build and Test Pull Request

on:
pull_request:

# Make sure jobs cannot overlap.
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true

jobs:

export-project:
name: Export the project for target platforms
uses: ./.github/workflows/export-project.yml
28 changes: 28 additions & 0 deletions .github/workflows/build-release-tagged.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build and Publish Tagged Release

on:
push:
tags:
# Match only tags that look like version numbers, e.g. 0.1, 2.3-beta, 4.5.6d, etc.
- '[0-9]+.[0-9]+*'

# Make sure jobs cannot overlap.
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true

jobs:

export-project:
name: Export the project for target platforms
uses: ./.github/workflows/export-project.yml
secrets: inherit
with:
with-codesign: true

publish-project:
name: Package and publish the project
needs: [ export-project ]
uses: ./.github/workflows/publish-project.yml
with:
release-version: ${{ github.ref_name }}
Loading

0 comments on commit ac7d6ef

Please sign in to comment.