-
-
Notifications
You must be signed in to change notification settings - Fork 6
217 lines (182 loc) · 6.19 KB
/
Copy pathcd.yml
File metadata and controls
217 lines (182 loc) · 6.19 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
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: Astrodynamics CD
on:
push:
tags:
- '[0-9]*.[0-9]*.[0-9]*'
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'minimal'
type: choice
options:
- minimal
- normal
- detailed
- diagnostic
env:
BUILD_TYPE: Release
jobs:
# Job 0: Extract version from tag
get-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract.outputs.version }}
steps:
- name: Extract version
id: extract
run: |
REF="${{ github.ref_name }}"
if [[ "$REF" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
VERSION="$REF"
else
VERSION="0.0.0-dev"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
# Job 1: Build and test C++ native library on both platforms
build-native:
needs: get-version
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build C++
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 2
- name: C++ Tests (Linux)
working-directory: ${{github.workspace}}/build/IO.Astrodynamics.Tests
run: ./IO.Astrodynamics.Tests
if: matrix.os == 'ubuntu-latest'
- name: C++ Tests (Windows)
working-directory: ${{github.workspace}}\build\IO.Astrodynamics.Tests\Release
shell: cmd
run: IO.Astrodynamics.Tests.exe
if: matrix.os == 'windows-latest'
- name: Upload native library (Linux)
uses: actions/upload-artifact@v4
with:
name: native-linux
path: build/IO.Astrodynamics/libIO.Astrodynamics.so
retention-days: 5
if: matrix.os == 'ubuntu-latest'
- name: Upload native library (Windows)
uses: actions/upload-artifact@v4
with:
name: native-windows
path: |
build/IO.Astrodynamics/Release/IO.Astrodynamics.dll
build/IO.Astrodynamics/Release/IO.Astrodynamics.lib
retention-days: 5
if: matrix.os == 'windows-latest'
# Job 2: Build, test, and pack the NuGet package
package-dotnet:
needs: [get-version, build-native]
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./IO.Astrodynamics.Net
steps:
- uses: actions/checkout@v4
- name: Download native Linux library
uses: actions/download-artifact@v4
with:
name: native-linux
path: IO.Astrodynamics.Net/IO.Astrodynamics/resources
- name: Download native Windows library
uses: actions/download-artifact@v4
with:
name: native-windows
path: IO.Astrodynamics.Net/IO.Astrodynamics/resources
- name: Verify native libraries
run: |
ls -la IO.Astrodynamics/resources/libIO.Astrodynamics.so
ls -la IO.Astrodynamics/resources/IO.Astrodynamics.dll
ls -la IO.Astrodynamics/resources/IO.Astrodynamics.lib
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Set version in csproj
run: |
sed -i 's|<Version>.*</Version>|<Version>${{ needs.get-version.outputs.version }}</Version>|' \
IO.Astrodynamics/IO.Astrodynamics.csproj
sed -i 's|<Version>.*</Version>|<Version>${{ needs.get-version.outputs.version }}</Version>|' \
IO.Astrodynamics.CLI/IO.Astrodynamics.CLI.csproj
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Test
run: dotnet test --no-build --verbosity ${{ inputs.logLevel || 'minimal' }} --configuration Release
- name: Package Framework
run: dotnet pack IO.Astrodynamics/IO.Astrodynamics.csproj --no-build --configuration Release
- name: Package CLI
run: dotnet pack IO.Astrodynamics.CLI/IO.Astrodynamics.CLI.csproj --no-build --configuration Release
- name: Stage NuGet packages
run: |
mkdir -p nupkg-staging
cp IO.Astrodynamics/bin/Release/*.nupkg nupkg-staging/
cp IO.Astrodynamics.CLI/bin/Release/*.nupkg nupkg-staging/
ls -la nupkg-staging/
- name: Upload NuGet package
uses: actions/upload-artifact@v4
with:
name: nuget-package
path: IO.Astrodynamics.Net/nupkg-staging/*.nupkg
retention-days: 5
# Job 3: Smoke-test the NuGet package on both platforms
smoke-test:
needs: package-dotnet
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ./IO.Astrodynamics.Net
steps:
- uses: actions/checkout@v4
- name: Download NuGet package
uses: actions/download-artifact@v4
with:
name: nuget-package
path: IO.Astrodynamics.Net/local-feed
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Restore smoke tests from local feed
run: dotnet restore IO.Astrodynamics.SmokeTests/IO.Astrodynamics.SmokeTests.csproj
- name: Run smoke tests
run: >
dotnet test IO.Astrodynamics.SmokeTests/IO.Astrodynamics.SmokeTests.csproj
--no-restore --verbosity ${{ inputs.logLevel || 'minimal' }} --configuration Release
# Job 4: Publish to NuGet (only after smoke tests pass on both platforms)
publish:
needs: smoke-test
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./IO.Astrodynamics.Net
steps:
- name: Download NuGet package
uses: actions/download-artifact@v4
with:
name: nuget-package
path: IO.Astrodynamics.Net/nupkg
- name: Publish package to NuGet.org
run: >
dotnet nuget push nupkg/*.nupkg
--skip-duplicate
--api-key ${{secrets.NUGET_TOKEN}}
--source https://api.nuget.org/v3/index.json
- name: Publish package to Private Feed
run: >
dotnet nuget push "nupkg/*.nupkg"
--skip-duplicate
--api-key ${{secrets.PROGET_API_KEY}}
--source ${{secrets.PROGET_FEED_URL}}