Skip to content

Nightly (Development) Build and Release #378

Nightly (Development) Build and Release

Nightly (Development) Build and Release #378

Workflow file for this run

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_manual_run.outputs.needs_build == 'true' || steps.check_tags.outputs.needs_build == 'true' }}
steps:
- name: Check if workflow was manually triggered
id: check_manual_run
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "Workflow dispatched manually. Continuing..."
echo "needs_build=true" >> $GITHUB_OUTPUT;
else
echo "Workflow triggered by a scheduled run. Continuing..."
echo "needs_build=false" >> $GITHUB_OUTPUT;
fi
- name: Checkout code
if: ${{ steps.check_manual_run.outputs.needs_build == 'false' }}
uses: actions/checkout@v4
- name: fetch tags
if: ${{ steps.check_manual_run.outputs.needs_build == 'false' }}
run: git fetch --tags origin
- name: Check if tags point to the same commit or if the workflow was manually triggered
if: ${{ steps.check_manual_run.outputs.needs_build == 'false' }}
id: check_tags
run: |
curr_sha=$(git rev-parse HEAD)
prev_sha=$(git rev-parse ${{ env.PREV_TAG }} 2>/dev/null)
if [[ $? -ne 0 ]]; then
echo "Tag ${{ env.PREV_TAG }} cannot be resolved. Continuing..."
echo "needs_build=true" >> $GITHUB_OUTPUT;
elif [[ "$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
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_type: "debug"
debug_level: "release"
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
build_configuration: "Debug Release"
release:
name: Publish Release
runs-on: ubuntu-latest
needs: [build-msbuild-releases, build-meson-releases]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: fetch tags
run: git fetch --tags origin
- name: Bundle Release Assets
uses: ./.github/actions/bundle_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: Get commit SHA of the last nightly release
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 --fail-with-body -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: Delete the existing nightly tag and release
if: steps.check_nightly.outputs.release_exists
run: |
gh release delete nightly -y --cleanup-tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create a new nightly release
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 }}