Repository navigation
96 lines (91 loc) · 2.93 KB
/
Copy pathci.yml
File metadata and controls
96 lines (91 loc) · 2.93 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
name: CI
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
workflow_dispatch:
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
NUGET_DIRECTORY: ${{ github.workspace }}/nuget
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Test
run: dotnet test --no-build --configuration Release --verbosity normal
pack:
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Get preview version
id: version
run: |
BRANCH_NAME=${GITHUB_REF#refs/heads/}
VERSION=0.1.0-${BRANCH_NAME}-${GITHUB_SHA::7}
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Build and Pack
run: |
dotnet build --configuration Release
dotnet pack src/ModelingEvolution.CanOpen/ModelingEvolution.CanOpen.csproj \
--configuration Release --no-build \
/p:Version=${{ steps.version.outputs.VERSION }} \
--output ${{ env.NUGET_DIRECTORY }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: nuget
if-no-files-found: error
retention-days: 7
path: ${{ env.NUGET_DIRECTORY }}/*.nupkg
publish-preview:
runs-on: ubuntu-latest
needs: pack
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
permissions:
packages: write
contents: read
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: nuget
path: ${{ env.NUGET_DIRECTORY }}
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Publish to GitHub Packages
run: |
for file in ${{ env.NUGET_DIRECTORY }}/*.nupkg; do
dotnet nuget push "$file" --api-key ${{ secrets.GITHUB_TOKEN }} \
--source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json --skip-duplicate
done
- name: Publish to NuGet.org (Preview)
continue-on-error: true
run: |
if [ -n "${{ secrets.NUGET_API_KEY }}" ]; then
for file in ${{ env.NUGET_DIRECTORY }}/*.nupkg; do
dotnet nuget push "$file" --api-key ${{ secrets.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json --skip-duplicate
done
else
echo "NUGET_API_KEY not set, skipping NuGet.org publish"
fi