From 6af15b2d32350f43c7dba1ba99e9325eb3337814 Mon Sep 17 00:00:00 2001 From: Stuart Date: Thu, 4 Jan 2024 22:33:57 +1030 Subject: [PATCH 1/6] ci: implement a nightly build script Runs once a day at UTC midnight --- .github/workflows/nightly.yaml | 84 ++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .github/workflows/nightly.yaml diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml new file mode 100644 index 0000000000..b43b1f8840 --- /dev/null +++ b/.github/workflows/nightly.yaml @@ -0,0 +1,84 @@ +name: Nightly Development Build and Release +# Controls when the action will run. +on: + workflow_dispatch: + schedule: + - cron: "0 0 * * *" + +concurrency: + group: release-${{ github.ref_name }} + cancel-in-progress: true + +# 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 + + build-msbuild-releases: + name: Windows Release Build + + uses: ./.github/workflows/msbuild.yml + with: + upload_artefacts: true + + release: + name: Publish Release + runs-on: ubuntu-latest + + needs: [build-msbuild-releases, build-meson-releases] + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - run: mkdir release + + - name: Download build artefacts + uses: actions/download-artifact@v3 + with: + path: release + + - run: ls -R release + + - 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: Create Release + id: create_release + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + files: | + CortexCommand.windows.zip + CortexCommand.linux.zip + CortexCommand.macos.zip + tag_name: "nightly" + name: "Nightly Development Build" + prerelease: true + fail_on_unmatched_files: true From 8d1bed97d9b08690b09e2db88eed5470ca8eae4d Mon Sep 17 00:00:00 2001 From: Stuart Date: Sat, 6 Jan 2024 21:44:06 +1030 Subject: [PATCH 2/6] ci: make msbuild output asset path relative --- .github/workflows/msbuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/msbuild.yml b/.github/workflows/msbuild.yml index 219d70121d..e55f66f668 100644 --- a/.github/workflows/msbuild.yml +++ b/.github/workflows/msbuild.yml @@ -72,5 +72,5 @@ jobs: uses: actions/upload-artifact@v3 with: name: ${{ steps.executable_name.outputs.EXECUTABLE_NAME }} - path: D:/a/Cortex-Command-Community-Project/Cortex-Command-Community-Project/${{ steps.executable_name.outputs.EXECUTABLE_NAME }} + path: ${{ steps.executable_name.outputs.EXECUTABLE_NAME }} if-no-files-found: error From 4ce111616fd6291e154aa0e7b8b4ec71a33e4ed2 Mon Sep 17 00:00:00 2001 From: Stuart Date: Sat, 6 Jan 2024 21:58:44 +1030 Subject: [PATCH 3/6] Implement nightly releases with tagging --- .github/workflows/nightly.yaml | 115 +++++++++++++++++++++++++++++---- 1 file changed, 102 insertions(+), 13 deletions(-) diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml index b43b1f8840..f4efbab564 100644 --- a/.github/workflows/nightly.yaml +++ b/.github/workflows/nightly.yaml @@ -6,14 +6,47 @@ on: - cron: "0 0 * * *" concurrency: - group: release-${{ github.ref_name }} - cancel-in-progress: true + group: nightly-${{ github.ref_name }} +# cancel-in-progress: true + +env: + PREV_TAG: nightly-prev # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: + check-for-changes: + name: Determine if a new nightly build should be released + runs-on: ubuntu-latest + + outputs: + needs_build: ${{ steps.check_build.outputs.needs_build }} + + steps: + - name: Check if tags point to the same commit or if the workflow was manually triggered + id: check_build + run: | + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + echo "Workflow dispatched manually. Continuing..." + echo "needs_build=true" >> $GITHUB_OUTPUT; + else + curr_sha=$(git rev-parse HEAD) + prev_sha=$(git rev-parse ${{ env.PREV_TAG }}}}) + + if [[ "$curr_sha" == "$prev_sha" ]]; then + echo "No changes since last nightly release. Exiting..." + echo "needs_build=false" >> $GITHUB_OUTPUT; + else + echo "Changes since last nightly release detected. Continuing..." + echo "needs_build=true" >> $GITHUB_OUTPUT; + fi + fi + build-meson-releases: name: Linux & macOS Release Builds + needs: check-for-changes + if: needs.check-for-changes.outputs.needs_build == 'true' + uses: ./.github/workflows/meson.yml with: upload_artefacts: true @@ -21,6 +54,9 @@ jobs: build-msbuild-releases: name: Windows Release Build + needs: check-for-changes + if: needs.check-for-changes.outputs.needs_build == 'true' + uses: ./.github/workflows/msbuild.yml with: upload_artefacts: true @@ -35,6 +71,9 @@ jobs: - name: Checkout code uses: actions/checkout@v3 + - name: fetch tags + run: git fetch --tags origin + - run: mkdir release - name: Download build artefacts @@ -68,17 +107,67 @@ jobs: zip -r -u CortexCommand.linux.zip Data zip -r -u CortexCommand.macos.zip Data - - name: Create Release + - name: Get Date + id: get_date + run: | + echo "CURRENT_DATE=$(date +'%d-%m-%Y')" >> $GITHUB_OUTPUT + + - name: Check if a nightly release exists + id: check_nightly + run: | + gh release view nightly --repo ${{ github.repository }} + if [ $? -eq 0 ] ; then + echo "release_exists=true" >> $GITHUB_OUTPUT; + else + echo "release_exists=false" >> $GITHUB_OUTPUT; + fi + shell: bash + continue-on-error: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Delete old nightly release if it exists + if: steps.check_nightly.outputs.release_exists + run: | + gh release delete nightly -y + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get commit SHA + id: get_commit_sha + if: steps.check_nightly.outputs.release_exists + run: | + prev_sha=$(git rev-parse nightly) + echo "prev_SHA=$prev_sha" >> $GITHUB_OUTPUT; + + - name: Create previous nightly tag + if: steps.check_nightly.outputs.release_exists + run: | + curl -X POST \ + -H "Authorization: Bearer ${{ secrets.WORKFLOW_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/git/refs \ + -d '{ + "ref": "refs/tags/${{ env.PREV_TAG }}", + "sha": "${{ steps.get_commit_sha.outputs.prev_SHA }}" + }' + + - name: Remove previous nightly tag + if: steps.check_nightly.outputs.release_exists + run: | + git tag -d nightly + git push origin :refs/tags/nightly + + - name: Create Release if it does not exist id: create_release - uses: softprops/action-gh-release@v1 + run: | + gh release create nightly \ + --title "Nightly Development Build (${{ steps.get_date.outputs.CURRENT_DATE }})" \ + --generate-notes \ + ${{steps.check_nightly.outputs.release_exists && format('--notes-start-tag {0}', env.PREV_TAG) || ''}} \ + --prerelease \ + 'CortexCommand.windows.zip#Cortex Command [Nightly Build] (Windows Release)' \ + 'CortexCommand.linux.zip#Cortex Command [Nightly Build] (Linux Release)' \ + 'CortexCommand.macos.zip#Cortex Command [Nightly Build] (macOS Release)' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - files: | - CortexCommand.windows.zip - CortexCommand.linux.zip - CortexCommand.macos.zip - tag_name: "nightly" - name: "Nightly Development Build" - prerelease: true - fail_on_unmatched_files: true From 97ddddede45559d96b5058457b8e509305d042c8 Mon Sep 17 00:00:00 2001 From: Stuart Date: Sun, 7 Jan 2024 16:44:59 +1030 Subject: [PATCH 4/6] add missing checkout step --- .github/workflows/nightly.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml index f4efbab564..a42862aa2e 100644 --- a/.github/workflows/nightly.yaml +++ b/.github/workflows/nightly.yaml @@ -22,6 +22,12 @@ jobs: needs_build: ${{ steps.check_build.outputs.needs_build }} steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: fetch tags + run: git fetch --tags origin + - name: Check if tags point to the same commit or if the workflow was manually triggered id: check_build run: | From a40760d72d286b3983a81c7ac78b5fef698a5ffe Mon Sep 17 00:00:00 2001 From: Stuart Date: Mon, 8 Jan 2024 23:10:53 +1030 Subject: [PATCH 5/6] Fix tagging issues --- .github/workflows/nightly.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml index a42862aa2e..fe373c35f8 100644 --- a/.github/workflows/nightly.yaml +++ b/.github/workflows/nightly.yaml @@ -146,19 +146,18 @@ jobs: prev_sha=$(git rev-parse nightly) echo "prev_SHA=$prev_sha" >> $GITHUB_OUTPUT; - - name: Create previous nightly tag + - name: Update tag pointing to the previous nightly release if: steps.check_nightly.outputs.release_exists run: | - curl -X POST \ + 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 \ + https://api.github.com/repos/${{ github.repository }}/git/refs/tags/${{ env.PREV_TAG }} \ -d '{ - "ref": "refs/tags/${{ env.PREV_TAG }}", "sha": "${{ steps.get_commit_sha.outputs.prev_SHA }}" }' - - name: Remove previous nightly tag + - name: Remove current nightly tag before release if: steps.check_nightly.outputs.release_exists run: | git tag -d nightly From 9269f11e9ef6ec53dcac18dd1175e26a56fa0c16 Mon Sep 17 00:00:00 2001 From: Stuart Date: Fri, 12 Jan 2024 21:58:14 +1030 Subject: [PATCH 6/6] fix: fix typo in nightly schedule check --- .github/workflows/nightly.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml index fe373c35f8..1f21ddb90d 100644 --- a/.github/workflows/nightly.yaml +++ b/.github/workflows/nightly.yaml @@ -36,7 +36,7 @@ jobs: echo "needs_build=true" >> $GITHUB_OUTPUT; else curr_sha=$(git rev-parse HEAD) - prev_sha=$(git rev-parse ${{ env.PREV_TAG }}}}) + prev_sha=$(git rev-parse ${{ env.PREV_TAG }}) if [[ "$curr_sha" == "$prev_sha" ]]; then echo "No changes since last nightly release. Exiting..."