From 19cc8c1dbac0e24d66f14d80db4d2814e655b192 Mon Sep 17 00:00:00 2001 From: Stuart Date: Wed, 3 Jan 2024 11:48:16 +1030 Subject: [PATCH 1/3] ci: add a new github action to update references to the Game Version --- .github/actions/set_version/action.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/actions/set_version/action.yaml diff --git a/.github/actions/set_version/action.yaml b/.github/actions/set_version/action.yaml new file mode 100644 index 0000000000..3b883cdd06 --- /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 GameVersion.h GameVersion + run: sed -i -E '/c_VersionString = /s/"[^"]*"/"${{inputs.new_release_version}}"/' System/GameVersion.h + shell: bash + + - uses: actions/setup-python@v3 + + - name: Rewrite meson version + run: | + pip install meson==0.60.3 + meson rewrite kwargs set project // version ${{ inputs.new_release_version }} + shell: bash From a6679f6ea598529f10bb4457a69d69555050414a Mon Sep 17 00:00:00 2001 From: Stuart Date: Wed, 3 Jan 2024 11:49:07 +1030 Subject: [PATCH 2/3] ci: update build scripts to set the game version before compiling if provided Using the new `set-version` action --- .github/workflows/ci.yml | 3 +-- .github/workflows/master_build.yaml | 8 +++----- .github/workflows/meson.yml | 15 ++++++++++++--- .github/workflows/msbuild.yml | 9 +++++++++ 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 854fcecb84..92d0b20666 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,6 @@ concurrency: jobs: meson: uses: ./.github/workflows/meson.yml - + msbuild: uses: ./.github/workflows/msbuild.yml - diff --git a/.github/workflows/master_build.yaml b/.github/workflows/master_build.yaml index e613f5ab94..b0de758b3a 100644 --- a/.github/workflows/master_build.yaml +++ b/.github/workflows/master_build.yaml @@ -1,4 +1,3 @@ - name: Master Build on: @@ -17,11 +16,10 @@ concurrency: jobs: meson: uses: ./.github/workflows/meson.yml - with: - upload_artefacts: true + with: + upload_artefacts: true msbuild: uses: ./.github/workflows/msbuild.yml with: - upload_artefacts: true - + upload_artefacts: true diff --git a/.github/workflows/meson.yml b/.github/workflows/meson.yml index 6726e6b9b0..2985be1a38 100644 --- a/.github/workflows/meson.yml +++ b/.github/workflows/meson.yml @@ -42,6 +42,9 @@ on: type: string required: false default: "release" + new_release_version: + type: string + required: false jobs: build-linux: @@ -66,6 +69,12 @@ jobs: run: | meson setup --buildtype=${{inputs.build_type}} -Ddebug_type=${{inputs.debug_level}} -Db_lto=true build + - name: Set Version + if: ${{inputs.new_release_version}} + uses: ./.github/actions/set_version + with: + new_release_version: ${{inputs.new_release_version}} + - name: Configure for AppImage if: ${{inputs.upload_artefacts}} env: @@ -114,7 +123,7 @@ jobs: build-macos: runs-on: macos-11 name: MacOS Build - + env: GCC_VERSION: "13" MACOSX_DEPLOYMENT_TARGET: 10.15 @@ -124,8 +133,8 @@ jobs: - name: "Install Dependencies" uses: melusina-org/setup-macports@v1 - with: - parameters: ".github/parameters/macports.yml" + with: + parameters: ".github/parameters/macports.yml" - name: Setup Meson env: diff --git a/.github/workflows/msbuild.yml b/.github/workflows/msbuild.yml index 219d70121d..331a5d62b8 100644 --- a/.github/workflows/msbuild.yml +++ b/.github/workflows/msbuild.yml @@ -31,6 +31,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. @@ -54,6 +57,12 @@ 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}} + - name: Build working-directory: ${{env.GITHUB_WORKSPACE}} # Add additional options to the MSBuild command line here (like platform or verbosity level). From 56977ef767184f2491d767f6b8c5a659b230e498 Mon Sep 17 00:00:00 2001 From: Stuart Date: Wed, 3 Jan 2024 11:55:50 +1030 Subject: [PATCH 3/3] feat!: add the new release workflow and semantic release config file --- .github/workflows/release.yaml | 130 +++++++++++++++++++++++++++++++++ .releaserc.json | 53 ++++++++++++++ 2 files changed, 183 insertions(+) create mode 100644 .github/workflows/release.yaml create mode 100644 .releaserc.json diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000000..b327de1649 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,130 @@ +name: Build and Release +# Controls when the action will run. +on: + # Triggers the workflow on push to the development or master branches + push: + branches: [master, development] + workflow_dispatch: + +concurrency: + group: release-${{ github.ref_name }} + cancel-in-progress: true + +#trigger new dev release again +env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SEMANTIC_RELEASE_CORE_VERSION: 19 + SEMANTIC_RELEASE_EXPORT_VERSION: 1 + SEMANTIC_RELEASE_GIT_VERSION: 10 + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + get-version: + name: Determine release version. + runs-on: ubuntu-latest + + outputs: + new-release-published: ${{ steps.get-next-version.outputs.new-release-published }} + new-release-version: ${{ steps.get-next-version.outputs.new-release-version }} + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 16 + + - name: Install Node Dependencies + run: npm install -g --save-dev semantic-release@${{env.SEMANTIC_RELEASE_CORE_VERSION}} @semantic-release/git@${{env.SEMANTIC_RELEASE_GIT_VERSION}} semantic-release-export-data@${{env.SEMANTIC_RELEASE_EXPORT_VERSION}} + + - name: Determine version number + id: get-next-version + run: npx semantic-release --dry-run + + - run: echo "Does a new version need to be published? ${{steps.get-next-version.outputs.new-release-published}}" + - if: steps.get-next-version.outputs.new-release-published == 'true' + run: echo "The new release version is ${{ steps.get-next-version.outputs.new-release-version }}" + + build-meson-releases: + name: Linux & macOS Release Builds + + needs: get-version + if: needs.get-version.outputs.new-release-published == 'true' + + uses: ./.github/workflows/meson.yml + with: + new_release_version: ${{needs.get-version.outputs.new-release-version}} + upload_artefacts: true + + build-msbuild-releases: + name: Windows Release Build + + needs: get-version + if: needs.get-version.outputs.new-release-published == 'true' + + uses: ./.github/workflows/msbuild.yml + with: + new_release_version: ${{needs.get-version.outputs.new-release-version}} + upload_artefacts: true + + release: + name: Publish Release + runs-on: ubuntu-latest + + needs: [get-version, build-msbuild-releases, build-meson-releases] + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 16 + + - name: Install Node Dependencies + run: npm install -g --save-dev semantic-release@${{env.SEMANTIC_RELEASE_CORE_VERSION}} @semantic-release/git@${{env.SEMANTIC_RELEASE_GIT_VERSION}} semantic-release-export-data@${{env.SEMANTIC_RELEASE_EXPORT_VERSION}} + + - run: mkdir release + + - name: Download build artefacts + uses: actions/download-artifact@v3 + with: + path: release + + - run: ls -R release + + - name: Set Version + uses: ./.github/actions/set_version + with: + new_release_version: ${{needs.get-version.outputs.new-release-version}} + + - name: Compress Windows Release + run: | + zip -j CortexCommand.windows.zip \ + "release/Cortex Command.exe" \ + external/lib/win/{fmod,SDL2}.dll + + - name: Compress Linux Release + run: | + zip -j CortexCommand.linux.zip \ + "release/CortexCommand (Linux)/CortexCommand.AppImage" \ + external/lib/linux/x86_64/libfmod.so* + + - name: Compress OSX Release + run: | + zip -j CortexCommand.macos.zip \ + "release/CortexCommand (macOS)/CortexCommand" \ + external/lib/macos/libfmod.dylib + + - name: Package Data files + run: | + zip -r -u CortexCommand.windows.zip Data + zip -r -u CortexCommand.linux.zip Data + zip -r -u CortexCommand.macos.zip Data + + - name: Semantic Release + run: npx semantic-release diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000000..94aece1d09 --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,53 @@ +{ + "branches": [ + "master", + { + "name": "development", + "prerelease": "pre" + } + ], + "repositoryUrl": "https://github.com/cortex-command-community/Cortex-Command-Community-Project", + "debug": "true", + "plugins": [ + "@semantic-release/commit-analyzer", + "semantic-release-export-data", + [ + "@semantic-release/release-notes-generator", + { + "writerOpts": { + "commitsSort": ["scope", "header"] + } + } + ], + [ + "@semantic-release/git", + { + "assets": ["System/GameVersion.h", "meson.build"] + } + ], + [ + "@semantic-release/github", + { + "assets": [ + { + "path": "CortexCommand.windows.zip", + "label": "Cortex Command v${nextRelease.version} (Windows Release)" + }, + { + "path": "CortexCommand.linux.zip", + "label": "Cortex Command v${nextRelease.version} (Linux Release)" + }, + { + "path": "CortexCommand.macos.zip", + "label": "Cortex Command v${nextRelease.version} (macOS Release)" + } + ], + "successComment": false, + "failComment": false, + "failTitle": false, + "releasedLabels": false, + "labels": false + } + ] + ] +}