From 04fce5af27e604921c8e1a7f2a45345236ba884b Mon Sep 17 00:00:00 2001 From: Felipe Keller Braz Date: Sun, 22 Jun 2025 16:27:00 -0300 Subject: [PATCH] [GITHUB] Add weekly pre-releases workflow for Generals and GeneralsMD builds --- .github/workflows/base-version.txt | 1 + .github/workflows/build-toolchain.yml | 11 + .github/workflows/weekly-release.yml | 298 ++++++++++++++++++++++++++ 3 files changed, 310 insertions(+) create mode 100644 .github/workflows/base-version.txt create mode 100644 .github/workflows/weekly-release.yml diff --git a/.github/workflows/base-version.txt b/.github/workflows/base-version.txt new file mode 100644 index 0000000000..f514a2f0bd --- /dev/null +++ b/.github/workflows/base-version.txt @@ -0,0 +1 @@ +0.9.1 \ No newline at end of file diff --git a/.github/workflows/build-toolchain.yml b/.github/workflows/build-toolchain.yml index 8413ff6804..27bf7ba502 100644 --- a/.github/workflows/build-toolchain.yml +++ b/.github/workflows/build-toolchain.yml @@ -25,6 +25,10 @@ on: default: false type: boolean description: "Build extras" + release: + required: false + type: string + description: "Release build (true/false)" jobs: build: @@ -35,6 +39,13 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 + - uses: actions/checkout@v4 + - name: Download version file + if: inputs.release == 'true' + uses: actions/download-artifact@v4 + with: + name: version_files + - name: Cache VC6 Installation if: startsWith(inputs.preset, 'vc6') id: cache-vc6 diff --git a/.github/workflows/weekly-release.yml b/.github/workflows/weekly-release.yml new file mode 100644 index 0000000000..0474a05cf4 --- /dev/null +++ b/.github/workflows/weekly-release.yml @@ -0,0 +1,298 @@ +name: Weekly Release + +permissions: + contents: write + pull-requests: write + +on: + workflow_dispatch: + inputs: + force_changed: + description: 'Force build' + required: false + default: 'false' + type: choice + options: + - 'false' + - 'true' + pre-release: + description: 'Mark release as pre-release' + required: false + default: 'false' + type: choice + options: + - 'false' + - 'true' + + schedule: + - cron: '0 8 * * 1' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + detect-scm-changes: + runs-on: ubuntu-latest + outputs: + changed: ${{ steps.check.outputs.changed }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + - id: check + run: | + if [ "${{ github.event.inputs.force_changed }}" = "true" ]; then + echo "changed=true" >> $GITHUB_OUTPUT + exit 0 + fi + + echo LAST TAG: + git describe --tags --abbrev=0 2>/dev/null || echo "" + + LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + if [ -z "$LAST_TAG" ]; then + echo "changed=true" >> $GITHUB_OUTPUT + exit 0 + fi + CHANGED=$(git diff --name-only $LAST_TAG..HEAD | grep -v '.github/workflows/' | wc -l) + if [ "$CHANGED" -eq "0" ]; then + echo "changed=false" >> $GITHUB_OUTPUT + else + echo "changed=true" >> $GITHUB_OUTPUT + fi + + calculate-version: + name: Generate version files + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + + - name: Create Version Files + run: | + BASE_TAG=$(cat .github/workflows/base-version.txt) + IFS='.' read -r major minor patch <<<"$BASE_TAG" + CURRENT_TAG=$(git tag --list "$major.$minor*" --sort=-v:refname | head -n1) + CURRENT_COMMIT=$(git rev-parse HEAD) + + if [ -z "$CURRENT_TAG" ]; then + CURRENT_TAG="$BASE_TAG" + NEXT_TAG="$BASE_TAG" + else + IFS='.' read -r major minor patch <<<"$CURRENT_TAG" + NEXT_TAG="$major.$minor.$((patch+1))" + fi + + echo "CURRENT_TAG: $CURRENT_TAG" + echo "NEXT_TAG: $NEXT_TAG" + + echo "$CURRENT_TAG" > current_tag.txt + echo "$NEXT_TAG" > next_tag.txt + echo "$CURRENT_COMMIT" > git_commit.txt + + - name: Upload version files + uses: actions/upload-artifact@v4 + with: + name: version_files + path: | + next_tag.txt + current_tag.txt + git_commit.txt + + build-generals: + needs: [detect-scm-changes, calculate-version] + if: needs.detect-scm-changes.outputs.changed == 'true' + name: Build Generals${{ matrix.preset && '' }} + strategy: + matrix: + include: + - preset: "vc6" + tools: true + extras: true + release: true + - preset: "win32-vcpkg" + tools: true + extras: true + release: true + fail-fast: false + uses: ./.github/workflows/build-toolchain.yml + with: + game: "Generals" + preset: ${{ matrix.preset }} + tools: ${{ matrix.tools }} + extras: ${{ matrix.extras }} + release: ${{ matrix.release }} + secrets: inherit + + build-generalsmd: + needs: [detect-scm-changes, calculate-version] + if: needs.detect-scm-changes.outputs.changed == 'true' + name: Build GeneralsMD${{ matrix.preset && '' }} + strategy: + matrix: + include: + - preset: "vc6" + tools: true + extras: true + release: true + - preset: "win32" + tools: true + extras: true + release: true + fail-fast: false + uses: ./.github/workflows/build-toolchain.yml + with: + game: "GeneralsMD" + preset: ${{ matrix.preset }} + tools: ${{ matrix.tools }} + extras: ${{ matrix.extras }} + release: ${{ matrix.release }} + secrets: inherit + + create-release: + name: Create Release + needs: [ build-generals, build-generalsmd ] + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + + - name: Download version file + uses: actions/download-artifact@v4 + with: + name: version_files + + - name: Read base version + id: base_version + run: echo "base_version=$(cat .github/workflows/base-version.txt)" >> $GITHUB_OUTPUT + + - name: Get latest semver tag + id: get_tag + run: echo "current_tag=$(cat current_tag.txt)" >> $GITHUB_OUTPUT + + - name: Calculate next version + id: next_version + run: echo "next_tag=$(cat next_tag.txt)" >> $GITHUB_OUTPUT + + - name: Collect commits since last release + id: changelog + run: | + TAG=${{ steps.get_tag.outputs.current_tag }} + NEXT=${{ steps.next_version.outputs.next_tag }} + if [ "$TAG" == "$NEXT" ]; then + { + echo "commits<> $GITHUB_OUTPUT + else + { + echo "commits<> $GITHUB_OUTPUT + fi + + # Generals vc6 + - name: Download Generals VC6 Artifacts + uses: actions/download-artifact@v4 + with: + name: Generals-vc6+t+e + path: generals-vc6-artifacts + + - name: Prepare and Zip Generals VC6 + run: | + mkdir generals-vc6-release + cp generals-vc6-artifacts/generalsv.exe generals-vc6-release/GeneralsV.exe + cp generals-vc6-artifacts/W3DViewV.exe generals-vc6-release/W3DViewV.exe + cp generals-vc6-artifacts/WorldBuilderV.exe generals-vc6-release/WorldBuilderV.exe + zip -j generals-vc6-${{ steps.next_version.outputs.next_tag }}.zip generals-vc6-release/* + + # Generals win32 + - name: Download Generals Win32 Artifacts + uses: actions/download-artifact@v4 + with: + name: Generals-win32-vcpkg+t+e + path: generals-win32-artifacts + + - name: Prepare and Zip Generals Win32 + run: | + mkdir generals-win32-release + cp generals-win32-artifacts/generalsv.exe generals-win32-release/GeneralsV.exe + cp generals-win32-artifacts/W3DViewV.exe generals-win32-release/W3DViewV.exe + cp generals-win32-artifacts/WorldBuilderV.exe generals-win32-release/WorldBuilderV.exe + zip -j generals-win32-${{ steps.next_version.outputs.next_tag }}.zip generals-win32-release/* + + # GeneralsMD vc6 + - name: Download GeneralsMD VC6 Artifacts + uses: actions/download-artifact@v4 + with: + name: GeneralsMD-vc6+t+e + path: generalsmd-vc6-artifacts + + - name: Prepare and Zip GeneralsMD VC6 + run: | + mkdir generalsmd-vc6-release + cp generalsmd-vc6-artifacts/generalszh.exe generalsmd-vc6-release/GeneralsZHv.exe + cp generalsmd-vc6-artifacts/W3DViewZH.exe generalsmd-vc6-release/W3DViewZHv.exe + cp generalsmd-vc6-artifacts/WorldBuilderZH.exe generalsmd-vc6-release/WorldBuilderZHv.exe + zip -j generalszh-vc6-${{ steps.next_version.outputs.next_tag }}.zip generalsmd-vc6-release/* + + # GeneralsMD win32 + - name: Download GeneralsMD Win32 Artifacts + uses: actions/download-artifact@v4 + with: + name: GeneralsMD-win32+t+e + path: generalsmd-win32-artifacts + + - name: Prepare and Zip GeneralsMD Win32 + run: | + mkdir generalsmd-win32-release + cp generalsmd-win32-artifacts/generalszh.exe generalsmd-win32-release/GeneralsZHv.exe + cp generalsmd-win32-artifacts/W3DViewZH.exe generalsmd-win32-release/W3DViewZHv.exe + cp generalsmd-win32-artifacts/WorldBuilderZH.exe generalsmd-win32-release/WorldBuilderZHv.exe + zip -j generalszh-win32-${{ steps.next_version.outputs.next_tag }}.zip generalsmd-win32-release/* + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.next_version.outputs.next_tag }} + name: ${{ steps.next_version.outputs.next_tag }} + prerelease: ${{ github.event.inputs.pre-release == 'true' }} + body: | + ## Build notes + + - **VC6 builds**: May be less compatible with modern systems, but guarantee compatibility with the original binary for multiplayer. + - **Win32 builds**: Offer better compatibility with modern systems, but multiplayer will only work with other win32 builds. + + ### Known issues + + - Fullscreen execution can freeze the game. For that case, you should add the `-win` parameter to run the game in windowed mode. + + ### Changelog + ${{ steps.changelog.outputs.commits }} + files: | + generals-vc6-${{ steps.next_version.outputs.next_tag }}.zip + generals-win32-${{ steps.next_version.outputs.next_tag }}.zip + generalszh-vc6-${{ steps.next_version.outputs.next_tag }}.zip + generalszh-win32-${{ steps.next_version.outputs.next_tag }}.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Clean up release folders + if: always() + run: | + rm -rf generals-vc6-release generals-win32-release generalsmd-vc6-release generalsmd-win32-release + rm -rf generals-vc6-artifacts generals-win32-artifacts generalsmd-vc6-artifacts generalsmd-win32-artifacts + rm -f generals-vc6-${{ steps.next_version.outputs.next_tag }}.zip + rm -f generals-win32-${{ steps.next_version.outputs.next_tag }}.zip + rm -f generalszh-vc6-${{ steps.next_version.outputs.next_tag }}.zip + rm -f generalszh-win32-${{ steps.next_version.outputs.next_tag }}.zip \ No newline at end of file