Skip to content

Commit

Permalink
Merge pull request #2 from V-Sekai/do-framework-signing-for-mac-and-a…
Browse files Browse the repository at this point in the history
…utomate-build

add stuff for build
  • Loading branch information
Ughuuu authored Nov 18, 2023
2 parents 10bb965 + 18ac1fb commit b4aabe6
Show file tree
Hide file tree
Showing 20 changed files with 713 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build
description: Build Godot CPP and GdExtension

inputs:
platform:
required: true
description: Target platform.
arch:
default: ''
description: Target architecture.

runs:
using: composite
steps:
- name: Cache .scons_cache
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/.scons-cache/
${{ github.workspace }}/thirdparty/godot-cpp/.scons-cache/
key: ${{ inputs.platform }}_${{ inputs.arch }}_cache
- uses: paulhatch/[email protected]
id: version
with:
bump_each_commit: true
tag_prefix: "v"
debug: true
- name: Print version
shell: sh
run:
echo v${{ steps.version.outputs.version }} > bin/addons/v-sekai.whisper/VERSION.txt
- name: Setup python and scons
uses: ./.github/actions/deps
- name: Lint
shell: sh
run:
./scripts/clang-format.sh
./scripts/clang-tidy.sh
- name: Build Godot Cpp
shell: sh
env:
SCONS_CACHE: .scons-cache
SCONS_CACHE_DIR: .scons-cache
run: |
cd thirdparty/godot-cpp && \
scons target=template_debug platform=${{ inputs.platform }} arch=${{ inputs.arch }} generate_bindings=yes production=yes && \
scons target=template_release platform=${{ inputs.platform }} arch=${{ inputs.arch }} generate_bindings=yes production=yes
- name: Build
shell: sh
env:
SCONS_CACHE: .scons-cache
SCONS_CACHE_DIR: .scons-cache
run: |
scons target=template_debug platform=${{ inputs.platform }} arch=${{ inputs.arch }} generate_bindings=no production=yes
scons target=template_release platform=${{ inputs.platform }} arch=${{ inputs.arch }} generate_bindings=no production=yes
34 changes: 34 additions & 0 deletions .github/actions/deps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Setup python and scons
description: Setup python, install the pip version of scons.

inputs:
python-version:
description: The python version to use.
default: "3.x"
python-arch:
description: The python architecture.
default: "x64"

runs:
using: "composite"
steps:
# Use python 3.x release (works cross platform)
- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
# Semantic version range syntax or exact version of a Python version
python-version: ${{ inputs.python-version }}
# Optional - x64 or x86 architecture, defaults to x64
architecture: ${{ inputs.python-arch }}

- name: Setup scons
shell: bash
run: |
python -c "import sys; print(sys.version)"
python -m pip install scons==4.4.0
scons --version
- name: Setup clang-format
shell: bash
run: |
python -m pip install clang-format
13 changes: 13 additions & 0 deletions .github/actions/upload/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Upload
description: Upload Extension.

runs:
using: composite
steps:
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: V-Sekai.Whisper
path: |
${{ github.workspace }}/bin/**
retention-days: 14
32 changes: 32 additions & 0 deletions .github/workflows/android_builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: 🤖 Android Builds
on:
workflow_call:

jobs:
android:
runs-on: "ubuntu-20.04"
name: Android Build ${{ matrix.arch }}
strategy:
fail-fast: false
matrix:
arch: [arm64, arm32, x86_64, x86_32]

steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- name: Set up Java 11
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11

- name: Build ${{ matrix.arch }}
uses: ./.github/actions/build
with:
arch: ${{ matrix.arch }}
platform: android

- name: Upload ${{ matrix.arch }}
uses: ./.github/actions/upload
31 changes: 31 additions & 0 deletions .github/workflows/clang-format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# This is based on Godot's clang-format.sh

# This script runs clang-format on all relevant files in the repo.
# This is the primary script responsible for fixing style violations.

set -uo pipefail

# Loop through all code files tracked by Git.
files=$(git ls-files -- '*.h' '*.cpp')


if [ ! -z "$files" ]; then
clang-format --Wno-error=unknown -i $files
fi

diff=$(git diff --color)

# If no diff has been generated all is OK, clean up, and exit.
if [ -z "$diff" ] ; then
printf "\e[1;32m*** Files in this commit comply with the clang-format style rules.\e[0m\n"
exit 0
fi

# A diff has been created, notify the user, clean up, and exit.
printf "\n\e[1;33m*** The following changes must be made to comply with the formatting rules:\e[0m\n\n"
# Perl commands replace trailing spaces with `·` and tabs with `<TAB>`.
printf "$diff\n" | perl -pe 's/(.*[^ ])( +)(\e\[m)$/my $spaces="·" x length($2); sprintf("$1$spaces$3")/ge' | perl -pe 's/(.*[^\t])(\t+)(\e\[m)$/my $tabs="<TAB>" x length($2); sprintf("$1$tabs$3")/ge'

printf "\n\e[1;91m*** Please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\e[0m\n"
exit 1
34 changes: 34 additions & 0 deletions .github/workflows/clang-tidy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
# This is based on Godot's clang-tidy.sh

# This script runs clang-tidy on all relevant files in the repo.
# This is more thorough than clang-format and thus slower; it should only be run manually.

set -uo pipefail

# Loops through all code files tracked by Git.

git ls-files -- '*.h' '*.cpp' |
while read -r f; do
# Run clang-tidy.
clang-tidy --quiet --fix "$f" &> /dev/null

# Run clang-format. This also fixes the output of clang-tidy.
clang-format --Wno-error=unknown -i "$f"
done

diff=$(git diff --color)

# If no diff has been generated all is OK, clean up, and exit.
if [ -z "$diff" ] ; then
printf "\e[1;32m*** Files in this commit comply with the clang-tidy style rules.\e[0m\n"
exit 0
fi

# A diff has been created, notify the user, clean up, and exit.
printf "\n\e[1;33m*** The following changes must be made to comply with the formatting rules:\e[0m\n\n"
# Perl commands replace trailing spaces with `·` and tabs with `<TAB>`.
printf "$diff\n" | perl -pe 's/(.*[^ ])( +)(\e\[m)$/my $spaces="·" x length($2); sprintf("$1$spaces$3")/ge' | perl -pe 's/(.*[^\t])(\t+)(\e\[m)$/my $tabs="<TAB>" x length($2); sprintf("$1$tabs$3")/ge'

printf "\n\e[1;91m*** Please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\e[0m\n"
exit 1
26 changes: 26 additions & 0 deletions .github/workflows/ios_builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 🍏 iOS Builds
on:
workflow_call:

jobs:
ios:
runs-on: "macos-latest"
name: iOS Build ${{ matrix.arch }}
strategy:
fail-fast: false
matrix:
arch: [arm64]

steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- name: Build ${{ matrix.arch }}
uses: ./.github/actions/build
with:
arch: ${{ matrix.arch }}
platform: ios

- name: Upload ${{ matrix.arch }}
uses: ./.github/actions/upload
28 changes: 28 additions & 0 deletions .github/workflows/linux_builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 🐧 Linux Builds
on:
workflow_call:

jobs:
linux:
runs-on: ubuntu-20.04
name: Linux Build ${{ matrix.arch }}
strategy:
fail-fast: false
matrix:
arch: [x86_64]

steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0

- name: Build ${{ matrix.arch }}
uses: ./.github/actions/build
with:
arch: ${{ matrix.arch }}
platform: linux

- name: Upload ${{ matrix.arch }}
uses: ./.github/actions/upload

51 changes: 51 additions & 0 deletions .github/workflows/macos_builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 🍎 macOS Builds
on:
workflow_call:

jobs:
macos:
runs-on: "macos-latest"
name: macOS Build ${{ matrix.arch }}
strategy:
fail-fast: false
matrix:
arch: [universal]

steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0

- name: Build ${{ matrix.arch }}
uses: ./.github/actions/build
with:
arch: ${{ matrix.arch }}
platform: macos

- name: Sign frameworks Debug
shell: pwsh
env:
APPLE_CERT_BASE64: ${{ secrets.PROD_MACOS_CERTIFICATE }}
APPLE_CERT_PASSWORD: ${{ secrets.PROD_MACOS_CERTIFICATE_PWD }}
APPLE_DEV_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_APPLE_ID }}
APPLE_DEV_TEAM_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }}
APPLE_DEV_PASSWORD: ${{ secrets.PROD_MACOS_NOTARIZATION_PWD }}
APPLE_DEV_APP_ID: ${{ secrets.PROD_MACOS_APPLE_DEV_APP_ID }}
run: ./scripts/ci-sign-macos.ps1 bin/addons/v-sekai.whisper/bin/libv-sekai.whisper.macos.template_debug.framework
if: ${{ env.APPLE_DEV_ID }}

- name: Sign frameworks Release
shell: pwsh
env:
APPLE_CERT_BASE64: ${{ secrets.PROD_MACOS_CERTIFICATE }}
APPLE_CERT_PASSWORD: ${{ secrets.PROD_MACOS_CERTIFICATE_PWD }}
APPLE_DEV_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_APPLE_ID }}
APPLE_DEV_TEAM_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }}
APPLE_DEV_PASSWORD: ${{ secrets.PROD_MACOS_NOTARIZATION_PWD }}
APPLE_DEV_APP_ID: ${{ secrets.PROD_MACOS_APPLE_DEV_APP_ID }}
run: ./scripts/ci-sign-macos.ps1 bin/addons/v-sekai.whisper/bin/libv-sekai.whisper.macos.template_release.framework
if: ${{ env.APPLE_DEV_ID }}

- name: Upload ${{ matrix.arch }}
uses: ./.github/actions/upload
45 changes: 45 additions & 0 deletions .github/workflows/runner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: 🔗 Builds
on:
push:
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true

jobs:
static-checks:
name: 📊 Static checks
uses: ./.github/workflows/static_checks.yml

android-build:
name: 🤖 Android
needs: static-checks
uses: ./.github/workflows/android_builds.yml

ios-build:
name: 🍏 iOS
needs: static-checks
uses: ./.github/workflows/ios_builds.yml

linux-build:
name: 🐧 Linux
needs: static-checks
uses: ./.github/workflows/linux_builds.yml

macos-build:
name: 🍎 macOS
needs: static-checks
uses: ./.github/workflows/macos_builds.yml
secrets: inherit

windows-build:
name: 🏁 Windows
needs: static-checks
uses: ./.github/workflows/windows_builds.yml

web-build:
name: 🌐 Web Builds
needs: static-checks
uses: ./.github/workflows/web_builds.yml
15 changes: 15 additions & 0 deletions .github/workflows/static_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: 📊 Static Checks
on:
workflow_call:

jobs:
static-checks:
name: Code style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Clang Format
shell: sh
run: ./scripts/clang-format.sh
Loading

0 comments on commit b4aabe6

Please sign in to comment.