Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/msbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
178 changes: 178 additions & 0 deletions .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
name: Nightly Development Build and Release
# Controls when the action will run.
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"

concurrency:
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: 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: |
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

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

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

- 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: 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: Update tag pointing to the previous nightly release
if: steps.check_nightly.outputs.release_exists
run: |
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.PREV_TAG }} \
-d '{
"sha": "${{ steps.get_commit_sha.outputs.prev_SHA }}"
}'

- name: Remove current nightly tag before release
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
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 }}