-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (91 loc) · 2.96 KB
/
ci.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
name: CI
on:
push:
pull_request:
workflow_dispatch:
inputs:
push-packages:
description: 'Push nuget packages'
required: true
default: false
type: boolean
use-auto-generated-version:
description: 'Use auto-generated version'
required: true
default: true
type: boolean
nuget-registry:
description: 'NuGet registry'
required: true
default: 'GitLab'
type: choice
options:
- GitLab
- NuGet
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, windows-latest]
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
8.0.x
- name: Set Version Suffix
shell: bash
run: |
if [ '${{ github.event.inputs.use-auto-generated-version }}' != 'false' ]; then
echo "NugetVersionSuffix=-dev-$(date +'%Y-%m-%d-%H-%M-%S')" >> $GITHUB_ENV
fi
- name: Restore Dependencies
shell: bash
run: dotnet restore
- name: Generate Bindings
shell: bash
run: dotnet run --project Box2D.NET.Bindgen
- name: Build Projects
shell: bash
run: |
dotnet build -c Debug
dotnet build -c Release
- name: Run Tests
shell: bash
run: dotnet test
- name: Pack Nuget Packages
shell: bash
run: |
if [ '${{ github.event.inputs.nuget-registry }}' == 'NuGet' ]; then
dotnet pack --property:NugetVersionSuffix=$NugetVersionSuffix -c Debug
dotnet pack --property:NugetVersionSuffix=$NugetVersionSuffix -c Release
else
dotnet pack --property:NugetVersionSuffix=$NugetVersionSuffix --property:Box2DPackPdb=true -c Debug
dotnet pack --property:NugetVersionSuffix=$NugetVersionSuffix --property:Box2DPackPdb=true -c Release
fi
- name: Upload Artifacts
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: Nuget Packages
path: |
**/Box2D.NET.*.nupkg
**/Box2D.NET.*.snupkg
- name: Push NuGet Packages
if: matrix.os == 'ubuntu-latest' && github.event_name == 'workflow_dispatch' && github.event.inputs.push-packages == 'true'
shell: bash
run: |
if [ '${{ github.event.inputs.nuget-registry }}' == 'GitLab' ]; then
dotnet nuget push **/Box2D.NET.*.nupkg --api-key '${{ secrets.GITLAB_ACCESS_TOKEN }}' --source 'https://gitlab.com/api/v4/projects/53993416/packages/nuget/index.json'
elif [ '${{ github.event.inputs.nuget-registry }}' == 'NuGet' ]; then
dotnet nuget push **/Box2D.NET.*.nupkg --api-key '${{ secrets.NUGET_ACCESS_TOKEN }}' --source 'https://api.nuget.org/v3/index.json'
fi