124 lines
4.2 KiB
YAML
124 lines
4.2 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 --unshallow || true
|
|
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.2.0")
|
|
|
|
IFS='.' read -r major minor patch <<< "${LAST_TAG#v}"
|
|
NEW_VERSION="$major.$minor.$((patch + 1))"
|
|
NEW_TAG="v$NEW_VERSION"
|
|
|
|
CHANGELOG=$(git log ${LAST_TAG}..HEAD --oneline | sed 's/^/* /')
|
|
[ -z "$CHANGELOG" ] && CHANGELOG="Maintenance build."
|
|
|
|
git tag $NEW_TAG
|
|
git push origin $NEW_TAG
|
|
|
|
echo "version-string=$NEW_VERSION" >> $GITHUB_OUTPUT
|
|
echo "changelog<<EOF" >> $GITHUB_OUTPUT
|
|
echo "## What's Changed" >> $GITHUB_OUTPUT
|
|
echo "$CHANGELOG" >> $GITHUB_OUTPUT
|
|
echo "EOF" >> $GITHUB_OUTPUT
|
|
|
|
- name: Setup Tools Cache
|
|
id: tools-cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
cmake-3.30.5-linux-x86_64
|
|
ccache
|
|
key: ${{ runner.os }}-tools-${{ hashFiles('**/CMakeLists.txt') }}
|
|
|
|
- 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 3.30
|
|
if: steps.tools-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
wget -q https://github.com/Kitware/CMake/releases/download/v3.30.5/cmake-3.30.5-linux-x86_64.tar.gz
|
|
tar xzf cmake-3.30.5-linux-x86_64.tar.gz
|
|
|
|
- name: Add CMake to path
|
|
run: echo "$GITHUB_WORKSPACE/cmake-3.30.5-linux-x86_64/bin" >> $GITHUB_PATH
|
|
|
|
- name: Get OpenSSL for MinGW (pre-built from MSYS2)
|
|
run: |
|
|
if [ ! -d "/usr/x86_64-w64-mingw32/include/openssl" ]; then
|
|
wget -q "https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-openssl-3.3.2-1-any.pkg.tar.zst"
|
|
tar xf mingw-w64-x86_64-openssl-3.3.2-1-any.pkg.tar.zst
|
|
sudo cp -r mingw64/include/openssl /usr/x86_64-w64-mingw32/include/
|
|
sudo cp mingw64/lib/libssl.a mingw64/lib/libcrypto.a /usr/x86_64-w64-mingw32/lib/
|
|
fi
|
|
|
|
- name: Patch missing MinGW headers
|
|
run: |
|
|
[ -f /usr/x86_64-w64-mingw32/include/consoleapi.h ] || \
|
|
printf '#pragma once\n#include <windows.h>\n' | \
|
|
sudo tee /usr/x86_64-w64-mingw32/include/consoleapi.h > /dev/null
|
|
|
|
- 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 \
|
|
-DOPENSSL_ROOT_DIR=/usr/x86_64-w64-mingw32 \
|
|
-DOPENSSL_INCLUDE_DIR=/usr/x86_64-w64-mingw32/include \
|
|
-DOPENSSL_LIBRARIES="/usr/x86_64-w64-mingw32/lib/libssl.a;/usr/x86_64-w64-mingw32/lib/libcrypto.a"
|
|
|
|
- name: Build Unlocker
|
|
run: cmake --build build --target dbd-unlocker
|
|
|
|
- name: Package Build
|
|
run: |
|
|
# Use -not -path "*/CMakeFiles/*" to exclude the temporary "a.exe" files
|
|
EXE=$(find build -name "*.exe" -not -path "*/CMakeFiles/*" | head -1)
|
|
echo "Found EXE: $EXE"
|
|
mkdir -p release
|
|
cp "$EXE" release/
|
|
cp res/*.json release/
|
|
cd release && zip -j ../unlocker.zip *
|
|
|
|
- name: Upload Artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: unlocker-build
|
|
path: unlocker.zip
|
|
|
|
- name: Create Gitea Release
|
|
if: ${{ github.event_name == 'push' }}
|
|
uses: akkuman/gitea-release-action@v1
|
|
with:
|
|
files: unlocker.zip
|
|
tag_name: v${{ steps.calculate-version.outputs.version-string }}
|
|
name: Release v${{ steps.calculate-version.outputs.version-string }}
|
|
body: ${{ steps.calculate-version.outputs.changelog }}
|