-
Notifications
You must be signed in to change notification settings - Fork 11
189 lines (180 loc) · 6.97 KB
/
ci-publish.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
184
185
186
187
188
189
name: Publish
on:
schedule:
- cron: '40 9 * * *'
workflow_dispatch:
release:
types: [published]
inputs:
is_release_event:
description: Should this be a release or a preview package
required: true
default: 'false'
jobs:
activity-short-circuit:
runs-on: ubuntu-latest
outputs:
same_sha: ${{ steps.check.outputs.same_sha }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Activity Short Circuit
id: check
run: |
echo "Event name: ${{ github.event_name }}"
git branch -a
git fetch origin nightly:nightly
head_sha=$(git rev-parse --verify HEAD)
nightly_sha=$(git rev-parse --verify nightly)
if [[ "$head_sha" == "$nightly_sha" && ${{ github.event_name }} != "release" ]]; then
same_sha=true;
else
same_sha=false;
fi
echo "head_sha=$head_sha"
echo "nightly_sha=$nightly_sha"
echo "same_sha=${same_sha}"
echo "same_sha=${same_sha}" >> $GITHUB_OUTPUT
build-test:
needs: activity-short-circuit
if: needs.activity-short-circuit.outputs.same_sha == 'false'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
sln:
- Spriggit.sln
- Spriggit.Linux.sln
exclude:
- os: ubuntu-latest
sln: Spriggit.sln
- os: ubuntu-latest
sln: Spriggit.Tests.Windows.sln
- os: macos-latest
sln: Spriggit.sln
- os: macos-latest
sln: Spriggit.Tests.Windows.sln
- os: windows-latest
sln: Spriggit.Linux.sln
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v3.0.3
with:
versionSpec: '6.0.5'
- name: Determine Version
id: version_step # step id used as reference for output values
uses: gittools/actions/gitversion/execute@v3.0.3
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.*
- name: Install dependencies
run: |
dotnet clean ${{ matrix.sln }} -c Release && dotnet nuget locals all --clear
dotnet restore ${{ matrix.sln }}
- name: Build
run: dotnet build ${{ matrix.sln }} -c Release --no-restore
- name: Test
run: dotnet test ${{ matrix.sln }} -c Release --no-build
build-test-push:
needs: [build-test, activity-short-circuit]
if: needs.activity-short-circuit.outputs.same_sha == 'false'
runs-on: windows-latest
steps:
- name: Get timestamp
uses: 1466587594/get-current-time@v1
id: current-time
with:
format: YYYYMMDD-HHmmSS
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.*
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v3.0.3
with:
versionSpec: '6.0.5'
- name: Determine Version
id: version_step # step id used as reference for output values
uses: gittools/actions/gitversion/execute@v3.0.3
- name: Install dependencies
run: |
dotnet clean Spriggit.sln -c Release && dotnet nuget locals all --clear
dotnet restore Spriggit.sln
- name: Build
run: dotnet build Spriggit.sln -c Release --no-restore /p:GeneratePackageOnBuild=false
- name: Pack Preview
if: ${{ success() && (github.event.release.prerelease || github.event_name != 'release') }}
run: |
dotnet pack Spriggit.sln -c Release -o out --include-symbols
- name: Pack Release
if: ${{ success() && !github.event.release.prerelease && github.event_name == 'release' }}
run: |
dotnet pack Spriggit.sln -c Release -o out --include-symbols
- name: Pack GUI
if: ${{ success() && !github.event.release.prerelease && github.event_name == 'release' }}
run: dotnet publish "Spriggit.UI/Spriggit.UI.csproj" --configuration Release -p:PublishSingleFile=true
- name: Pack Linux CLI
if: ${{ success() && !github.event.release.prerelease && github.event_name == 'release' }}
run: dotnet publish "Spriggit.CLI/Spriggit.CLI.csproj" --configuration Release -r linux-x64 -p:PublishSingleFile=True --self-contained True
- name: Pack CLI
if: ${{ success() && !github.event.release.prerelease && github.event_name == 'release' }}
run: dotnet publish "Spriggit.CLI/Spriggit.CLI.csproj" --configuration Release -r win-x64 -p:PublishSingleFile=True --self-contained True
- name: Archive GUI
if: ${{ success() && !github.event.release.prerelease && github.event_name == 'release' }}
run: |
powershell Compress-Archive Spriggit.UI/bin/Release/net9.0-windows/win-x64/publish/* Spriggit.zip
- name: Archive Linux CLI
if: ${{ success() && !github.event.release.prerelease && github.event_name == 'release' }}
run: |
powershell Compress-Archive Spriggit.CLI/bin/Release/net9.0/linux-x64/publish/* SpriggitLinuxCLI.zip
- name: Archive CLI
if: ${{ success() && !github.event.release.prerelease && github.event_name == 'release' }}
run: |
powershell Compress-Archive Spriggit.CLI/bin/Release/net9.0/win-x64/publish/* SpriggitCLI.zip
- name: Publish GUI to Github
if: ${{ success() && !github.event.release.prerelease && github.event_name == 'release' }}
uses: svenstaro/upload-release-action@v2
with:
file: Spriggit.zip
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.event.release.tag_name }}
- name: Publish Linux CLI to Github
if: ${{ success() && !github.event.release.prerelease && github.event_name == 'release' }}
uses: svenstaro/upload-release-action@v2
with:
file: SpriggitLinuxCLI.zip
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.event.release.tag_name }}
- name: Publish CLI to Github
if: ${{ success() && !github.event.release.prerelease && github.event_name == 'release' }}
uses: svenstaro/upload-release-action@v2
with:
file: SpriggitCLI.zip
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.event.release.tag_name }}
- name: Publish to Nuget.org
run: dotnet nuget push **/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --no-symbols
update-nightly:
needs: [build-test-push, activity-short-circuit]
if: needs.activity-short-circuit.outputs.same_sha == 'false'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Reset nightly to release
run: |
head_sha=$(git rev-parse --verify HEAD)
echo "head_sha=$head_sha"
git checkout nightly
git reset --hard $head_sha
git push