126 lines
3.8 KiB
YAML
126 lines
3.8 KiB
YAML
name: Build
|
|
|
|
on:
|
|
push:
|
|
branches: [ "main", "master" ]
|
|
pull_request:
|
|
branches: [ "main", "master" ]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
fetch-depth: 0
|
|
fetch-tags: true
|
|
|
|
- name: Configure version information
|
|
id: calculate-version
|
|
if: ${{ github.event_name == 'push' }}
|
|
shell: bash
|
|
run: |
|
|
git fetch --tags --force
|
|
|
|
if LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null); then
|
|
RANGE="${LAST_TAG}..HEAD"
|
|
else
|
|
LAST_TAG="v0.1.9"
|
|
RANGE="HEAD"
|
|
fi
|
|
|
|
IFS='.' read -r major minor patch <<< "${LAST_TAG#v}"
|
|
NEW_VERSION="$major.$minor.$((patch + 1))"
|
|
|
|
CHANGELOG=$(git log $RANGE --oneline | sed 's/^/* /')
|
|
if [ -z "$CHANGELOG" ]; then
|
|
CHANGELOG="Re-run of version $NEW_VERSION or maintenance build."
|
|
fi
|
|
|
|
echo "version-string=$NEW_VERSION" >> $GITHUB_OUTPUT
|
|
echo "new-tag=v$NEW_VERSION" >> $GITHUB_OUTPUT
|
|
{
|
|
echo "changelog<<EOF"
|
|
echo "## What's Changed"
|
|
echo "$CHANGELOG"
|
|
echo "EOF"
|
|
} >> $GITHUB_OUTPUT
|
|
|
|
- name: Cache CMake Binary
|
|
id: cmake-cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: cmake-4.3.4-linux-x86_64
|
|
key: ${{ runner.os }}-cmake-4.3.4
|
|
|
|
- name: Cache FetchContent & ccache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
build/_deps
|
|
ccache
|
|
key: ${{ runner.os }}-deps-${{ hashFiles('**/CMakeLists.txt') }}-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-deps-${{ hashFiles('**/CMakeLists.txt') }}-
|
|
${{ runner.os }}-deps-
|
|
|
|
- name: Install tools
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y mingw-w64 zstd ccache zip
|
|
mkdir -p ccache
|
|
echo "CCACHE_DIR=$GITHUB_WORKSPACE/ccache" >> $GITHUB_ENV
|
|
|
|
- name: Install CMake 4.3.4
|
|
if: steps.tools-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
wget -q https://github.com/Kitware/CMake/releases/download/v4.3.4/cmake-4.3.4-linux-x86_64.tar.gz
|
|
tar xzf cmake-4.3.4-linux-x86_64.tar.gz
|
|
|
|
- name: Add CMake to path
|
|
run: echo "$GITHUB_WORKSPACE/cmake-4.3.4-linux-x86_64/bin" >> $GITHUB_PATH
|
|
|
|
- name: Configure CMake
|
|
run: |
|
|
cmake -B build -S . \
|
|
-DCMAKE_SYSTEM_NAME=Windows \
|
|
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \
|
|
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \
|
|
-DCMAKE_RC_COMPILER=x86_64-w64-mingw32-windres \
|
|
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
|
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
|
|
|
- name: Build Unlocker
|
|
run: cmake --build build --target hex-unlocked
|
|
|
|
- name: Package Build
|
|
run: |
|
|
EXE=$(find build -name "*.exe" -not -path "*/CMakeFiles/*" | head -1)
|
|
echo "Found EXE: $EXE"
|
|
mkdir -p release
|
|
cp "$EXE" release/
|
|
if [ -d "res" ]; then cp res/*.json release/; fi
|
|
cd release && zip -j ../hex-unlocked.zip *
|
|
|
|
- name: Upload Artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: runner-build
|
|
path: hex-unlocked.zip
|
|
|
|
- name: Finalize Version and Push Tag
|
|
if: ${{ github.event_name == 'push' && success() }}
|
|
run: |
|
|
git tag ${{ steps.calculate-version.outputs.new-tag }}
|
|
git push origin ${{ steps.calculate-version.outputs.new-tag }}
|
|
|
|
- name: Create Gitea Release
|
|
if: ${{ github.event_name == 'push' && success() }}
|
|
uses: akkuman/gitea-release-action@v1
|
|
with:
|
|
files: hex-unlocked.zip
|
|
tag_name: ${{ steps.calculate-version.outputs.new-tag }}
|
|
name: Release ${{ steps.calculate-version.outputs.new-tag }}
|
|
body: ${{ steps.calculate-version.outputs.changelog }} |