-
Notifications
You must be signed in to change notification settings - Fork 4
142 lines (122 loc) · 4.45 KB
/
ci.yaml
File metadata and controls
142 lines (122 loc) · 4.45 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
name: build
on:
push:
branches:
- master
pull_request:
branches:
- master
env:
VERSION_MAJOR: 0
VERSION_MINOR: 1
jobs:
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
build: ${{ steps.version.outputs.build }}
revision: ${{ steps.version.outputs.revision }}
steps:
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: generate version
id: version
shell: bash
run: |
BUILD_NUMBER=0
REVISION=${{ github.run_number }}
VERSION="${{ env.VERSION_MAJOR }}.${{ env.VERSION_MINOR }}.${BUILD_NUMBER}.${REVISION}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "build=${BUILD_NUMBER}" >> $GITHUB_OUTPUT
echo "revision=${REVISION}" >> $GITHUB_OUTPUT
echo "Generated version: ${VERSION}"
echo " - Build: ${BUILD_NUMBER}"
echo " - Revision (Run Number): ${REVISION}"
build:
needs: version
strategy:
matrix:
include:
- os: windows-latest
platform: windows
- os: ubuntu-latest
platform: linux
runs-on: ${{ matrix.os }}
steps:
- name: checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
- name: build (Linux)
if: runner.os == 'Linux'
run: |
echo "[+] build linux"
dotnet publish -r linux-x64 --self-contained=true -c Release -p:PublishDir=build /p:Version=${{ needs.version.outputs.version }} /p:FileVersion=${{ needs.version.outputs.version }} /p:AssemblyVersion=${{ needs.version.outputs.version }} /p:ProductVersion=${{ needs.version.outputs.version }}
- name: build (Windows)
if: runner.os == 'Windows'
run: |
echo "[+] build windows"
dotnet publish -r win-x64 --self-contained=true -c Release -p:PublishDir=build /p:Version=${{ needs.version.outputs.version }} /p:FileVersion=${{ needs.version.outputs.version }} /p:AssemblyVersion=${{ needs.version.outputs.version }} /p:ProductVersion=${{ needs.version.outputs.version }}
- name: pack
if: runner.os == 'Linux'
run: |
echo "[+] Packing NuGet package"
dotnet pack --configuration Release -o build -p:PublishDir=build /p:Version=${{ needs.version.outputs.version }} /p:FileVersion=${{ needs.version.outputs.version }} /p:AssemblyVersion=${{ needs.version.outputs.version }} /p:ProductVersion=${{ needs.version.outputs.version }}
- name: collect artifacts
shell: bash
run: |
mkdir -p artifacts
cp build/* artifacts/
ls -lh artifacts
- name: upload artifacts
uses: actions/upload-artifact@v4
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
name: ${{ matrix.platform }}-v${{ needs.version.outputs.version }}
path: artifacts/**
release:
needs: [ version , build ]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' && github.ref == 'refs/heads/master' && github.event_name == 'push'
steps:
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: create release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.version.outputs.version }}
name: release v${{ needs.version.outputs.version }}
generate_release_notes: true
draft: false
prerelease: true
files: artifacts/**
- name: publish to NuGet
continue-on-error: true
env:
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}
run: |
echo "[+] Publishing NuGet packages with version ${{ needs.version.outputs.version }}"
shopt -s globstar nullglob
for pkg in artifacts/**/*.nupkg; do
if [[ "$pkg" == *.snupkg ]]; then
continue
fi
echo "-> dotnet nuget push $pkg"
dotnet nuget push "$pkg" \
--api-key "$NUGET_AUTH_TOKEN" \
--source "https://api.nuget.org/v3/index.json" \
--skip-duplicate
done