diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b90024e..3188e58 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,65 +1,155 @@ -#--- -#name: Build Linux -#run-name: ${{ github.actor }} test -#on: -# - pull_request -#jobs: -# build-linux: -# runs-on: ubuntu-latest -# steps: -# - name: Check out repository code -# uses: actions/checkout@v6 -# -# - name: Set PATH -# run: | -# echo "/usr/local/cmake/bin:/usr/local/zig:\$PATH" > $GITHUB_PATH -# -# - name: Install CMake -# run: | -# curl -sS -L -o /tmp/cmake.tgz https://github.com/Kitware/CMake/releases/download/v4.3.3/cmake-4.3.3-linux-x86_64.tar.gz -# tar -zxvf /tmp/cmake.tgz -C /tmp -# sudo mkdir -p /usr/local/cmake -# sudo mv /tmp/cmake-4.3.3-linux-x86_64/* /usr/local/cmake/ -# -# - name: Install Ninja -# run: | -# curl -sS -L -o /tmp/ninja.zip https://github.com/ninja-build/ninja/releases/download/v1.13.2/ninja-linux.zip -# sudo unzip -d /usr/bin /tmp/ninja.zip -# -# - name: Install Zig -# run: | -# curl -sS -L -o /tmp/zig.tar.xz https://ziglang.org/builds/zig-x86_64-linux-0.17.0-dev.813+2153f8143.tar.xz -# sudo mkdir -p /usr/local/zig -# tar -xvf /tmp/zig.tar.xz -C /tmp -# sudo mv /tmp/zig-x86_64-linux-0.17.0-dev.813+2153f8143/* /usr/local/zig -# -# - name: Build release -# run: | -# cmake --preset static-release -B out -# cmake --build out -# -# build-windows: -# runs-on: windows-2025-vs2026 -# steps: -# - name: Check out repository code -# uses: actions/checkout@v6 -# -# - name: Set PATH -# run: | -# echo "/usr/local/cmake/bin:/usr/local/zig:\$PATH" > $GITHUB_PATH -# -# - name: Install CMake -# run: | -# Invoke-WebRequest -Uri https://github.com/Kitware/CMake/releases/download/v4.3.3/cmake-4.3.3-windows-x86_64.zip -OutFile Env::Temp\cmake.zip -# 7z x cmake.zip -oc:\outputdir -# -# - name: Install Ninja -# run: | -# Invoke-WebRequest -Uri https://github.com/ninja-build/ninja/releases/download/v1.13.2/ninja-win.zip -OutFile ninja.zip -# 7z x ninja.zip -oc:\outputdir -# -# - name: Build release -# run: | -# cmake --preset windows-x86-release -B out -# cmake --build out -# \ No newline at end of file +--- +name: Build Workflow +run-name: Build Workflow +on: + pull_request: + workflow_call: + inputs: + upload-artifacts: + required: true + type: boolean + version: + required: true + type: string + outputs: + version_major: + value: ${{ jobs.version.outputs.version_major }} + version_minor: + value: ${{ jobs.version.outputs.version_minor }} + version_patch: + value: ${{ jobs.version.outputs.version_patch }} + is_valid: + value: ${{ jobs.version.outputs.is_valid }} + + +jobs: + version: + runs-on: ubuntu-latest + outputs: + version_major: ${{ steps.get-version.outputs.version_major }} + version_minor: ${{ steps.get-version.outputs.version_minor }} + version_patch: ${{ steps.get-version.outputs.version_patch }} + is_valid: ${{ steps.get-version.outputs.is_valid }} + steps: + - name: Create version file + id: get-version + env: + VERSION: ${{ inputs.version || 'v1.0.0' }} + run: | + if echo "${VERSION}" | grep -q -Eo 'v[0-9]+\.[0-9]+\.[0-9]+'; then + echo "is_valid=true" >> "$GITHUB_OUTPUT" + else + echo "is_valid=false" >> "$GITHUB_OUTPUT" + fi + echo ${VERSION} | awk -F'[v.]' '{print "version_major=" $2}' >> "$GITHUB_OUTPUT" + echo ${VERSION} | awk -F'[v.]' '{print "version_minor=" $3}' >> "$GITHUB_OUTPUT" + echo ${VERSION} | awk -F'[v.]' '{print "version_patch=" $4}' >> "$GITHUB_OUTPUT" + + build-linux: + if: needs.version.outputs.is_valid == 'true' + runs-on: ubuntu-latest + needs: version + steps: + - name: Check out repository code + uses: actions/checkout@v6 + + - name: Set PATH + run: | + echo "~/.tools/cmake/bin:~/.tools/zig:~/.tools/ninja:\$PATH" > $GITHUB_PATH + + - name: Cache CMake + id: linux-cmake-tools + uses: actions/cache@v5 + with: + path: ~/.tools/cmake + key: ${{ runner.os }}-cmake-4.3.3 + + - name: Cache Ninja + id: linux-ninja-tools + uses: actions/cache@v5 + with: + path: ~/.tools/ninja + key: ${{ runner.os }}-ninja-1.13.2 + + - name: Cache Zig + id: linux-zig-tools + uses: actions/cache@v5 + with: + path: ~/.tools/zig + key: ${{ runner.os }}-zig-0.17.0 + + - name: Install CMake + if: steps.linux-cmake-tools.outputs.cache-hit != 'true' + env: + CMAKE_URL: https://github.com/Kitware/CMake/releases/download/v4.3.3/cmake-4.3.3-linux-x86_64.tar.gz + run: | + curl -sS -L -o /tmp/cmake.tgz "${CMAKE_URL}" + tar -zxvf /tmp/cmake.tgz -C /tmp + sudo mkdir -p ~/.tools/cmake + sudo mv /tmp/cmake-4.3.3-linux-x86_64/* ~/.tools/cmake/ + + - name: Install Ninja + if: steps.linux-ninja-tools.outputs.cache-hit != 'true' + env: + NINJA_URL: https://github.com/ninja-build/ninja/releases/download/v1.13.2/ninja-linux.zip + run: | + curl -sS -L -o /tmp/ninja.zip "${NINJA_URL}" + sudo mkdir -p ~/.tools/ninja + sudo unzip -d ~/.tools/ninja /tmp/ninja.zip + + - name: Install Zig + if: steps.linux-zig-tools.outputs.cache-hit != 'true' + env: + ZIG_URL: https://ziglang.org/builds/zig-x86_64-linux-0.17.0-dev.813+2153f8143.tar.xz + run: | + curl -sS -L -o /tmp/zig.tar.xz "${ZIG_URL}" + sudo mkdir -p ~/.tools/zig + tar -xvf /tmp/zig.tar.xz -C /tmp + sudo mv /tmp/zig-x86_64-linux-0.17.0-dev.813+2153f8143/* ~/.tools/zig/ + + - name: Build release + run: | + cmake --preset static-release -B out + cmake --build out + + - name: Upload Linux artifact + if: inputs.upload-artifacts + uses: actions/upload-artifact@v7 + with: + name: Linux artifact + path: out/suffer2gether + + + build-windows: + if: needs.version.outputs.is_valid == 'true' + runs-on: windows-2025-vs2026 + needs: version + defaults: + run: + shell: cmd + steps: + - name: Check out repository code + uses: actions/checkout@v6 + + - name: Build release + run: | + echo "VERSION_MAJOR ${{ needs.version.outputs.version_major }}" > version.txt + echo "VERSION_MINOR ${{ needs.version.outputs.version_minor }}" >> version.txt + echo "VERSION_PATCH ${{ needs.version.outputs.version_patch }}" >> version.txt + call "C:\Program Files\Microsoft Visual Studio\18\Enterprise\VC\Auxiliary\Build\vcvars32.bat" + cmake --preset windows-x86-release -B out + cmake --build out + + - name: Upload Windows MFC artifact + if: inputs.upload-artifacts + uses: actions/upload-artifact@v7 + with: + name: Windows MFC artifact + path: out/suffer2gether.exe + + - name: Upload Windows CLI artifact + if: inputs.upload-artifacts + uses: actions/upload-artifact@v7 + with: + name: Windows CLI artifact + path: out/suffer2gether-cli.exe diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..91b829d --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,74 @@ +--- +name: +run-name: Build and Release +on: + push: + tags: + - v* + + +jobs: + build: + uses: ./.github/workflows/build.yaml + with: + upload-artifacts: true + version: ${{ github.ref_name }} + + + package-and-release: + if: needs.build.outputs.is_valid == 'true' + runs-on: ubuntu-latest + needs: build + permissions: + contents: write + steps: + - name: Check out repository code + uses: actions/checkout@v6 + + - name: Download artifacts + uses: actions/download-artifact@v8 + with: + path: release + merge-multiple: true + + - name: Create release notes + env: + VERSION_MAJOR: ${{ needs.build.outputs.version_major }} + VERSION_MINOR: ${{ needs.build.outputs.version_minor }} + VERSION_PATCH: ${{ needs.build.outputs.version_patch }} + run: | + if [ ! -f ./CHANGELOG.md ]; then + touch ./release_notes.md + else + awk -v ver="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" \ + '/^## \[/ { if (found) { exit } if ($0 ~ "\\[" ver "\\]") { found=1 } } found' \ + ./CHANGELOG.md > ./release_notes.md + fi + + - name: Package Linux binaries + env: + RELEASE_FILE: suffer2gether-${{ github.ref_name }}-linux-x86_64.tgz + run: | + cd release + chmod a+x ./suffer2gether + tar -zcvf ./${RELEASE_FILE} ./suffer2gether + sha256sum ${RELEASE_FILE} >> SHA256SUMS + + - name: Package Windows binaries + env: + RELEASE_FILE: suffer2gether-${{ github.ref_name }}-windows-x86.zip + run: | + cd release + zip -9 -D ./${RELEASE_FILE} ./suffer2gether.exe ./suffer2gether-cli.exe + sha256sum ${RELEASE_FILE} >> SHA256SUMS + + - name: Create release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + LINUX_FILE: suffer2gether-${{ github.ref_name }}-linux-x86_64.tgz + WINDOWS_FILE: suffer2gether-${{ github.ref_name }}-windows-x86.zip + run: | + gh release create "${{ github.ref_name }}" -F ./release_notes.md --title "${{ github.ref_name }}" \ + "./release/${LINUX_FILE}" \ + "./release/${WINDOWS_FILE}" \ + "./release/SHA256SUMS" diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..b957ad5 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,31 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/2.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.2.1] - 2026-06-14 + +1.2.1 is the first release to include a change log. The main focus of this release was a command line interface that +will work in Windows and multiple distros of Linux. The build system has been moved over to CMake and should be much +easier to build from source on different systems. + +### Added + +- Mutex to limit running instances to one. +- Windows CLI build. The patch can now be applied using the Windows command line. +- Linux CLI build. The release will be statically linked for a wider range of compatible distros, including Steam Deck. +- Dockerfile and scripts to help building the linux binary locally. + +### Changed + +- Renamed and reorganized files and directories. +- Changed build system to CMake. +- Changed from the Windows four-part version number to semantic versioning. + +### Removed + +- Removed Visual Studio project and solution files in favor of CMake. diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a0a5cc..74254bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,25 @@ cmake_minimum_required(VERSION 4.3.3) set(PROJECT_NAME "suffer2gether") + +if(EXISTS "version.txt") + file(READ "version.txt" version_data) + string(REGEX MATCH "VERSION_MAJOR ([0-9]+)" _ "${version_data}") + set(VERSION_MAJOR "${CMAKE_MATCH_1}") + string(REGEX MATCH "VERSION_MINOR ([0-9]+)" _ "${version_data}") + set(VERSION_MINOR "${CMAKE_MATCH_1}") + string(REGEX MATCH "VERSION_PATCH ([0-9]+)" _ "${version_data}") + set(VERSION_PATCH "${CMAKE_MATCH_1}") +else() + set(VERSION_MAJOR "1") + set(VERSION_MINOR "0") + set(VERSION_PATCH "0") +endif() + + project( ${PROJECT_NAME} - VERSION 1.2.0 + VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" ) diff --git a/src/apps/windows/res/suffer2gether.rc.in b/src/apps/windows/res/suffer2gether.rc.in index b0f02b9..4d4be7b 100644 --- a/src/apps/windows/res/suffer2gether.rc.in +++ b/src/apps/windows/res/suffer2gether.rc.in @@ -1,4 +1,4 @@ -#include "resource.h" +#include "res/resource.h" #include "afxres.h"