Skip to content

Commit

Permalink
Merge branch 'develop' into window_mode_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
WizzardMaker authored Sep 9, 2024
2 parents edf6c65 + 18034bc commit 7d3696c
Show file tree
Hide file tree
Showing 107 changed files with 4,297 additions and 2,443 deletions.
36 changes: 0 additions & 36 deletions .github/workflows/cmake.yml

This file was deleted.

43 changes: 0 additions & 43 deletions .github/workflows/msbuild.yml

This file was deleted.

57 changes: 0 additions & 57 deletions .github/workflows/release.yml

This file was deleted.

213 changes: 213 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
# This starter workflow is for a CMake project running on multiple platforms
name: build and package

on:
push:
branches: [ "main", "develop" ]
pull_request:
branches: [ "main", "develop" ]

jobs:
env:
runs-on: ubuntu-latest
outputs:
cmake-build-dir: ${{ steps.compute-env.outputs.cmake-build-dir }}
artifact-name: ${{ steps.compute-env.outputs.artifact-name }}
artifact-dir: ${{ steps.compute-env.outputs.artifact-dir }}
build-type: ${{ steps.compute-env.outputs.build-type }}
release-name: ${{ steps.compute-env.outputs.release-name }}
release-tag: ${{ steps.compute-env.outputs.release-tag }}
steps:
# Get the code
- uses: actions/checkout@v4

# Extract VERSION from resource.h and format it
# Set global variables and variables based on the branch name
- name: Compute env
id: compute-env
run: |
VERSION=$(grep -oP 'FILE_VERSION\s+\K\d+(,\s+\d+){2}' src/Res/resource.h | sed -E 's/[, ]+/./g')
echo "cmake-build-dir=cmake-build" >> "$GITHUB_OUTPUT"
echo "artifact-dir=artifacts" >> "$GITHUB_OUTPUT"
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
echo "Setting production environment variables..."
echo "build-type=Release" >> "$GITHUB_OUTPUT"
echo "release-name=ATD Version $VERSION Release" >> "$GITHUB_OUTPUT"
echo "artifact-name=AT-$VERSION" >> "$GITHUB_OUTPUT"
echo "release-tag=v$VERSION" >> "$GITHUB_OUTPUT"
elif [ "${{ github.ref }}" == "refs/heads/develop" ]; then
echo "Setting development environment variables..."
echo "build-type=Release" >> "$GITHUB_OUTPUT"
echo "release-name=ATD Version $VERSION Pre-Release" >> "$GITHUB_OUTPUT"
echo "artifact-name=AT-$VERSION-preview" >> "$GITHUB_OUTPUT"
echo "release-tag=v$VERSION-preview" >> "$GITHUB_OUTPUT"
else
echo "Setting branch environment variables..."
echo "build-type=Debug" >> "$GITHUB_OUTPUT"
echo "release-name=ATD Version $VERSION Preview" >> "$GITHUB_OUTPUT"
echo "artifact-name=AT-$VERSION-${{ github.sha }}" >> "$GITHUB_OUTPUT"
echo "release-tag=v$VERSION-${{ github.sha }}" >> "$GITHUB_OUTPUT"
fi
cat $GITHUB_OUTPUT
build:
needs: env
runs-on: ${{ matrix.os }}

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false

# Set up a matrix to run the following 2 configurations:
# 1. <Windows, Release or Debug, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release or Debug, latest GCC compiler toolchain on the default runner image, default generator>
matrix:
os: [ubuntu-latest, windows-latest, macos-13]
name: ['linux', 'windows', 'macos']
build_type:
- ${{ needs.env.outputs.build-type }}
c_compiler: [gcc, cl]
exclude: # exclude all by default
- os: windows-latest
- os: ubuntu-latest
- os: macos-13
include: # only include the configurations we want
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
name: 'windows'
build_type: ${{ needs.env.outputs.build-type }}
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
name: 'linux'
build_type: ${{ needs.env.outputs.build-type }}
- os: macos-13
c_compiler: gcc
cpp_compiler: g++
name: 'macos'
build_type: ${{ needs.env.outputs.build-type }}

# Execute this for each matrix
# Warning: Don't get ${{ github.workspace }} from elsewhere! (like precomputed from env job)
# as GitHub actually set a different path for Windows that make the build fail
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install Linux dependencies
if: matrix.name == 'linux'
run: |
sudo apt-get update
sudo apt-get install libjansson-dev libsdl2*-dev
- name: Setup homebrew (macOS)
if: matrix.name == 'macos'
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Install macOS dependencies
if: matrix.name == 'macos'
run: |
brew install cmake sdl2 sdl2_mixer sdl2_image sdl2_ttf jansson
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
# Make it verbose with -DCMAKE_VERBOSE_MAKEFILE=ON
run: >
cmake -B ${{ needs.env.outputs.cmake-build-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}
- name: Build
# Build the program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ needs.env.outputs.cmake-build-dir }} --config ${{ matrix.build_type }}

# Package the build results (windows)
- name: Package artifact
id: artifact-win
if: matrix.name == 'windows'
run: |
# Set variables
$artifactName = "${{ needs.env.outputs.artifact-name }}-${{ matrix.name }}.zip"
$artifactPath = "${{ needs.env.outputs.artifact-dir }}/$artifactName"
# Create the artifact directory if it doesn't exist
if (!(Test-Path -Path ${{ needs.env.outputs.artifact-dir }} -PathType Container)) {
New-Item -Path ${{ needs.env.outputs.artifact-dir }} -ItemType Directory -Force
}
# Compress the files into the artifact
Compress-Archive -Path "${{ needs.env.outputs.cmake-build-dir }}/${{ matrix.build_type }}/*" -DestinationPath $artifactPath -Update
# Output artifact information
Write-Host "Building windows $artifactName"
Write-Host "artifact-name=$artifactName"
Write-Host "artifact-path=$artifactPath"
echo "artifact-name=$artifactName" >> $Env:GITHUB_OUTPUT
echo "artifact-path=$artifactPath" >> $Env:GITHUB_OUTPUT
# Package the build results (linux)
- name: Package artifact
id: artifact-linux
if: matrix.name == 'linux' || matrix.name == 'macos'
run: |
echo "Building linux ${{ needs.env.outputs.artifact-name }}-${{ matrix.name }}.tar"
ARTIFACT_NAME=${{ needs.env.outputs.artifact-name }}-${{ matrix.name }}.tar
ARTIFACT_PATH=${{ needs.env.outputs.artifact-dir }}/$ARTIFACT_NAME
mkdir -p ${{ needs.env.outputs.artifact-dir }}
tar -cvf $ARTIFACT_PATH -C ${{ github.workspace }}/${{ needs.env.outputs.cmake-build-dir }}/${{ matrix.build_type }} .
echo "artifact-name=$ARTIFACT_NAME" >> "$GITHUB_OUTPUT"
echo "artifact-path=$ARTIFACT_PATH" >> "$GITHUB_OUTPUT"
cat $GITHUB_OUTPUT
- name: Upload sentry debug files
shell: pwsh
# Only publish on main/dev build & windows
if: matrix.name == 'windows' && (github.ref_name == 'main' || github.ref_name == 'develop') && vars.SENTRY_ORG != ''
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
# SENTRY_URL: https://sentry.io/
run: |
curl -sL https://github.com/getsentry/sentry-cli/releases/download/2.32.1/sentry-cli-Windows-x86_64.exe > sentry-cli.exe
./sentry-cli.exe debug-files upload ${{ needs.env.outputs.cmake-build-dir }}/${{ matrix.build_type }}/
- name: Publish artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.artifact-win.outputs.artifact-name || steps.artifact-linux.outputs.artifact-name }}
path: ${{ steps.artifact-win.outputs.artifact-path || steps.artifact-linux.outputs.artifact-path }}

release:
runs-on: ubuntu-latest
needs: [ build, env ]
if: github.ref_name == 'main' || github.ref_name == 'develop'

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: ${{ needs.env.outputs.artifact-name }}*
path: ${{ needs.env.outputs.artifact-dir }}
merge-multiple: true
- name: Release
uses: softprops/action-gh-release@v1
with:
target_commitish: ${{ github.sha }}
name: ${{ needs.env.outputs.release-name }}
tag_name: ${{ needs.env.outputs.release-tag }}
prerelease: ${{ github.ref_name == 'develop' }}
draft: ${{ github.ref_name == 'main' }}
files: |
${{ needs.env.outputs.artifact-dir }}/${{ needs.env.outputs.artifact-name }}*
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ CMakeCache.txt
cmake_install.cmake
/libs/libsmacker/smk2avi
/libs/libsmacker/driver
gamefiles/*
!gamefiles/*.md
.vscode
!.vscode/extensions.json
.DS_Store
13 changes: 13 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"ms-vscode.cpptools-extension-pack"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": [
"ms-dotnettools.csdevkit"
]
}
Loading

0 comments on commit 7d3696c

Please sign in to comment.