diff --git a/.github/actions/bundle_release/action.yaml b/.github/actions/bundle_release/action.yaml new file mode 100644 index 0000000000..9774653ed3 --- /dev/null +++ b/.github/actions/bundle_release/action.yaml @@ -0,0 +1,48 @@ +name: 'Bundle Release Assets' +description: 'Downloads build assets and packages them into a zip file along with game data and libraries' +runs: + using: "composite" + steps: + - run: mkdir release + shell: bash + + - name: Download build artefacts + uses: actions/download-artifact@v3 + with: + path: release + + - run: ls -R release + shell: bash + + - name: Compress Windows Release + shell: bash + run: | + zip -j CortexCommand.windows.zip \ + "release/Cortex Command.exe" \ + external/lib/win/{fmod,SDL2}.dll + + - name: Compress Linux Release + shell: bash + run: | + zip -j CortexCommand.linux.zip \ + "release/CortexCommand (Linux)/CortexCommand.AppImage" \ + external/lib/linux/x86_64/libfmod.so* + + - name: Compress OSX Release + shell: bash + run: | + zip -j CortexCommand.macos.zip \ + "release/CortexCommand (macOS)/CortexCommand" \ + external/lib/macos/libfmod.dylib + + - name: Package Data files + shell: bash + run: | + zip -r -u CortexCommand.windows.zip Data + zip -r -u CortexCommand.linux.zip Data + zip -r -u CortexCommand.macos.zip Data + + + + + \ No newline at end of file diff --git a/.github/actions/set_version/action.yaml b/.github/actions/set_version/action.yaml new file mode 100644 index 0000000000..5d61d2f107 --- /dev/null +++ b/.github/actions/set_version/action.yaml @@ -0,0 +1,20 @@ +name: 'Set Version' +description: 'Updates all references to the current game version' +inputs: + new_release_version: + description: 'The new version string' + required: true +runs: + using: "composite" + steps: + - name: Set Constants.h GameVersion + run: sed -i -E '/c_VersionString = /s/"[^"]*"/"${{inputs.new_release_version}}"/' Source/System/GameVersion.h + shell: bash + + - uses: actions/setup-python@v3 + + - name: Rewrite meson version + run: | + pip install meson + meson rewrite kwargs set project // version ${{ inputs.new_release_version }} + shell: bash diff --git a/.github/workflows/master_build.yaml b/.github/workflows/master_build.yaml deleted file mode 100644 index e613f5ab94..0000000000 --- a/.github/workflows/master_build.yaml +++ /dev/null @@ -1,27 +0,0 @@ - -name: Master Build - -on: - # Triggers the workflow for pushes to master - push: - branches: [master] - - workflow_dispatch: - -# Cancel in-progress runs if newer changes to the same branch/PR are pushed. -concurrency: - group: ci-${{ github.head_ref || github.ref }} - cancel-in-progress: true - -# Build the game on all platforms and store build artefacts of both jobs -jobs: - meson: - uses: ./.github/workflows/meson.yml - with: - upload_artefacts: true - - msbuild: - uses: ./.github/workflows/msbuild.yml - with: - upload_artefacts: true - diff --git a/.github/workflows/meson.yml b/.github/workflows/meson.yml index 6726e6b9b0..f52877bd8b 100644 --- a/.github/workflows/meson.yml +++ b/.github/workflows/meson.yml @@ -26,6 +26,9 @@ on: - "release" - "minimal" - "full" + new_release_version: + type: string + required: false # Triggers the workflow when called by a top-level workflow workflow_call: @@ -42,6 +45,9 @@ on: type: string required: false default: "release" + new_release_version: + type: string + required: false jobs: build-linux: @@ -59,6 +65,13 @@ jobs: sudo apt-get install --no-install-recommends wget liballegro4-dev libloadpng4-dev libflac++-dev luajit-5.1-dev liblua5.2-dev libminizip-dev liblz4-dev libpng++-dev libx11-dev libboost-dev libtbb-dev libsdl2-dev libsdl2-image-dev libopengl-dev libfuse2 ninja-build sudo pip install meson + - name: Set Version + if: ${{inputs.new_release_version}} + uses: ./.github/actions/set_version + with: + new_release_version: ${{inputs.new_release_version}} + github_token: ${{ secrets.GITHUB_TOKEN }} + - name: Setup Meson env: CC: "gcc" @@ -114,7 +127,7 @@ jobs: build-macos: runs-on: macos-11 name: MacOS Build - + env: GCC_VERSION: "13" MACOSX_DEPLOYMENT_TARGET: 10.15 @@ -124,8 +137,15 @@ jobs: - name: "Install Dependencies" uses: melusina-org/setup-macports@v1 - with: - parameters: ".github/parameters/macports.yml" + with: + parameters: ".github/parameters/macports.yml" + + - name: Set Version + if: ${{inputs.new_release_version}} + uses: ./.github/actions/set_version + with: + new_release_version: ${{inputs.new_release_version}} + github_token: ${{ secrets.GITHUB_TOKEN }} - name: Setup Meson env: diff --git a/.github/workflows/msbuild.yml b/.github/workflows/msbuild.yml index 219d70121d..57f2d2656d 100644 --- a/.github/workflows/msbuild.yml +++ b/.github/workflows/msbuild.yml @@ -19,6 +19,9 @@ on: - "Debug Release" - "Debug Minimal" - "Debug Full" + new_release_version: + type: string + required: false # Triggers the workflow when called by a top-level workflow workflow_call: @@ -31,7 +34,9 @@ on: type: string required: false default: "Final" - + new_release_version: + type: string + required: false env: # Path to the solution file relative to the root of the project. SOLUTION_FILE_PATH: RTEA.sln @@ -54,6 +59,13 @@ jobs: - name: Add MSBuild to PATH uses: microsoft/setup-msbuild@v1 + - name: Set Version + if: ${{inputs.new_release_version}} + uses: ./.github/actions/set_version + with: + new_release_version: ${{inputs.new_release_version}} + github_token: ${{ secrets.GITHUB_TOKEN }} + - name: Build working-directory: ${{env.GITHUB_WORKSPACE}} # Add additional options to the MSBuild command line here (like platform or verbosity level). diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000000..527fb3014e --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,90 @@ +name: Build and Release +# Controls when the action will run. +on: + workflow_dispatch: + inputs: + new_release_version: + description: "New version number to release" + type: string + required: true + +concurrency: + group: release-${{ github.ref_name }} + +env: + LATEST_TAG: latest + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + build-meson-releases: + name: Linux & macOS Release Builds + + uses: ./.github/workflows/meson.yml + with: + upload_artefacts: true + new_release_version: ${{ github.event.inputs.new_release_version }} + + build-msbuild-releases: + name: Windows Release Build + + uses: ./.github/workflows/msbuild.yml + with: + upload_artefacts: true + new_release_version: ${{ github.event.inputs.new_release_version }} + + release: + name: Publish Release + runs-on: ubuntu-latest + + needs: [build-msbuild-releases, build-meson-releases] + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: fetch tags + run: git fetch --tags origin + + - name: Set Version + if: ${{ github.event.inputs.new_release_version}} + uses: ./.github/actions/set_version + with: + new_release_version: ${{ github.event.inputs.new_release_version}} + + - name: Bundle release assets + uses: ./.github/actions/bundle_release + + - name: Create a new Release + run: | + gh release create v${{ github.event.inputs.new_release_version }} \ + --title "Release ${{ github.event.inputs.new_release_version }}" \ + --generate-notes \ + --draft \ + --target ${{ github.ref_name }} \ + ${{format('--notes-start-tag {0}', env.LATEST_TAG) || ''}} \ + 'CortexCommand.windows.zip#Cortex Command [v${{ github.event.inputs.new_release_version }}] (Windows Release)' \ + 'CortexCommand.linux.zip#Cortex Command [v${{ github.event.inputs.new_release_version }}] (Linux Release)' \ + 'CortexCommand.macos.zip#Cortex Command [v${{ github.event.inputs.new_release_version }}] (macOS Release)' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Commit and push Version Changes and Update latest tag + shell: bash + run: | + git config --global user.email "action@github.com" + git config --global user.name "GitHub Action" + git add Source/System/GameVersion.h meson.build + git commit -m "Release v${{ inputs.new_release_version }}" || echo "No changes to commit" + git push + + RELEASE_COMMIT=$(git rev-parse HEAD) + curl -X PATCH \ + -H "Authorization: Bearer ${{ secrets.WORKFLOW_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/git/refs/tags/${{ env.LATEST_TAG }} \ + -d '{ + "sha": "'"$RELEASE_COMMIT"'", + "ref": "${{ github.ref }}" + }' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}