-
Notifications
You must be signed in to change notification settings - Fork 32
157 lines (131 loc) · 5.26 KB
/
nightly.yaml
File metadata and controls
157 lines (131 loc) · 5.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
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 }}