-
Notifications
You must be signed in to change notification settings - Fork 3
183 lines (180 loc) · 6.71 KB
/
create-latest-develop-build.yml
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: Nightly build
on:
workflow_dispatch:
schedule:
- cron: 0 0 * * *
env:
DEBUG: false
REF_CHECKOUT_BRANCH: develop
RELEASE_NAME: Recent nightly build
APPLICATION_PROJECT_PATH: .\src\ModularToolManager\ModularToolManager.csproj
APPLICATION_PLUGIN_PROJECT_PATH: .\src\DefaultPlugins\DefaultPlugins.csproj
APPLICATION_PUBLISH_FOLDER: ./publish
PLUGIN_PUBLISH_FOLDER: ./publish/plugins
WINDOWS_ARTIFACT_NAME: WindowsBuildArtifact_x64
LINUX_ARTIFACT_NAME: LinuxBuildArtifact_x64
RELEASE_ARTIFACT_FOLDER: artifacts
jobs:
check-for-changes:
runs-on: ubuntu-latest
name: Check for changes in last 24 hours
outputs:
should-run: ${{ steps.should-run.outputs.should-run }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.REF_CHECKOUT_BRANCH }}
- name: get latest commit and check it
id: should-run
continue-on-error: true
if: ${{ env.DEBUG == 'true' }} || ${{ github.event_name == 'schedule' }}
# Based on https://stackoverflow.com/questions/63014786/how-to-schedule-a-github-actions-nightly-build-but-run-it-only-when-there-where
# @Note: Check the comments on the solution!
run: |
latest=$(git log -n 1 --pretty=format:"%H")
# For debug testing remove ${{ env.REF_CHECKOUT_BRANCH }}
sha=$(git rev-list ${{ env.REF_CHECKOUT_BRANCH }} --after="24 hours" $latest)
echo $sha
echo Do the check now
if test -z $sha
then
echo "Check failed"
echo "should-run=false" >> $GITHUB_OUTPUT
else
echo "Check successful"
echo "should-run=true" >> $GITHUB_OUTPUT
fi
check-build:
name: Check and Test build
if: needs.check-for-changes.outputs.should-run == 'true'
needs: [check-for-changes]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.REF_CHECKOUT_BRANCH }}
lfs: true
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
create-windows-build:
name: Create Windows build
if: needs.check-for-changes.outputs.should-run == 'true'
needs: ["check-build"]
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.REF_CHECKOUT_BRANCH }}
lfs: true
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore
- name: Publish Application
run: dotnet publish ${{ env.APPLICATION_PROJECT_PATH }} -r win-x64 -c Release -o ${{ env.APPLICATION_PUBLISH_FOLDER }} -p:Version=0.0.0
- name: Publish Plugin
run: dotnet publish ${{ env.APPLICATION_PLUGIN_PROJECT_PATH }} -r win-x64 -c Release -o ${{ env.PLUGIN_PUBLISH_FOLDER }} /p:DebugType=None /p:DebugSymbols=false -p:Version=0.0.0
- name: Show content for debug
if: ${{ env.DEBUG == 'true' }}
run: ls
- name: Show content to publish
if: ${{ env.DEBUG == 'true' }}
run: |
cd ./publish
ls
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ env.WINDOWS_ARTIFACT_NAME }}
path: ${{ env.APPLICATION_PUBLISH_FOLDER }}
if-no-files-found: error
create-linux-build:
name: Create Linux build
if: needs.check-for-changes.outputs.should-run == 'true'
needs: ["check-build"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.REF_CHECKOUT_BRANCH }}
lfs: true
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore
- name: Publish Application
run: dotnet publish $APPLICATION_PROJECT_PATH -r linux-x64 -c Release -o $APPLICATION_PUBLISH_FOLDER -p:Version=0.0.0
- name: Publish Plugin
run: dotnet publish $APPLICATION_PLUGIN_PROJECT_PATH -r linux-x64 -c Release -o $PLUGIN_PUBLISH_FOLDER /p:DebugType=None /p:DebugSymbols=false -p:Version=0.0.0
- name: Show content for debug
if: ${{ env.DEBUG == 'true' }}
run: ls -la
- name: Show content to publish
if: ${{ env.DEBUG == 'true' }}
run: |
cd ./publish
ls -la
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ env.LINUX_ARTIFACT_NAME }}
path: ${{ env.APPLICATION_PUBLISH_FOLDER }}
if-no-files-found: error
create-release:
name: Create GitHub Release
if: needs.check-for-changes.outputs.should-run == 'true'
needs: ["create-linux-build", "create-windows-build"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.REF_CHECKOUT_BRANCH }}
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ${{ env.RELEASE_ARTIFACT_FOLDER }}
- name: Zip Windows build
run: |
cd ./$RELEASE_ARTIFACT_FOLDER/$WINDOWS_ARTIFACT_NAME
zip -r $WINDOWS_ARTIFACT_NAME.zip ./*
mv $WINDOWS_ARTIFACT_NAME.zip ../
rm -rf ./../$WINDOWS_ARTIFACT_NAME
- name: Zip Linux build
run: |
cd ./$RELEASE_ARTIFACT_FOLDER/$LINUX_ARTIFACT_NAME
zip -r $LINUX_ARTIFACT_NAME.zip ./*
mv $LINUX_ARTIFACT_NAME.zip ../
rm -rf ./../$LINUX_ARTIFACT_NAME
- name: display artifacts folder content
if: ${{ env.DEBUG == 'true' }}
run: ls -la $RELEASE_ARTIFACT_FOLDER
- name: Create release and upload artifacts (DEBUG)
if: ${{ env.DEBUG == 'true' }}
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create Develop-${{ GITHUB.RUN_NUMBER }} \
--title "${{ env.RELEASE_NAME }} [${{ GITHUB.RUN_NUMBER }}]" --target ${{ env.REF_CHECKOUT_BRANCH }} \
--generate-notes --prerelease ${parameters} --notes "Recent version of the develop branch, ready for testing" \
-d ${{ env.RELEASE_ARTIFACT_FOLDER }}/*.*
- name: Create release and upload artifacts
if: ${{ env.DEBUG == 'false' }}
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create Develop-${{ GITHUB.RUN_NUMBER }} \
--title "${{ env.RELEASE_NAME }} [${{ GITHUB.RUN_NUMBER }}]" --target ${{ env.REF_CHECKOUT_BRANCH }} \
--generate-notes --prerelease ${parameters} --notes "Recent version of the develop branch, ready for testing" \
${{ env.RELEASE_ARTIFACT_FOLDER }}/*.* --discussion-category "Releases"