forked from snatch-dev/Convey
-
Notifications
You must be signed in to change notification settings - Fork 4
108 lines (93 loc) · 2.93 KB
/
main.yml
File metadata and controls
108 lines (93 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
97
98
99
100
101
102
103
104
105
106
107
108
name: Build and Push NuGet Packages
on:
push:
branches:
- master
paths:
- .github/workflows/main.yml
- src/**/*
- Directory.Build.props
pull_request:
branches:
- master
types:
- opened
- reopened
- synchronize
paths:
- .github/workflows/main.yml
- src/**/*
- Directory.Build.props
workflow_dispatch:
repository_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
SOLUTION: "Convey.slnx"
BUILD_CONFIG: "Release"
PACKAGE_SOURCE: "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
steps:
- name: Checkout Source
uses: actions/checkout@v6
- name: Get .NET Version from Directory.Build.props
id: dotnet_version
shell: bash
run: |
# 1. Grep the line, extracting only the matched segment
# 2. Sed capture group to get the digit after 'net'
MAJOR_VERSION=$(grep -oP '<TargetFramework>.*</TargetFramework>' Directory.Build.props | sed -E 's/.*net([0-9]+).*/\1/')
echo "Detected .NET Major Version: $MAJOR_VERSION"
# 3. Write to GitHub Output
echo "major=$MAJOR_VERSION" >> $GITHUB_OUTPUT
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ steps.dotnet_version.outputs.major }}
dotnet-quality: "ga"
- name: Get Year
id: year
uses: josStorer/get-current-time@v2
with:
format: YY
- name: Build
run: |
VERSION="${{ steps.year.outputs.formattedTime }}.${{ steps.dotnet_version.outputs.major }}.${{ github.run_number }}"
dotnet build \
$SOLUTION \
--configuration $BUILD_CONFIG \
--verbosity minimal \
--property:Version="$VERSION" \
--property:ContinuousIntegrationBuild=true \
--property:Deterministic=true \
--property:DeterministicSourcePaths=true \
--property:SourceLinkCreate=true \
--property:DebugType=pdbonly \
--property:IncludeSymbols=true \
--property:SymbolPackageFormat=snupkg
- name: Run Tests
run: |
dotnet test \
--configuration $BUILD_CONFIG \
--no-restore \
--no-build \
--verbosity minimal
- name: Publish Packages
if: github.event_name != 'pull_request'
run: |
dotnet nuget push \
**\*.nupkg \
--source $PACKAGE_SOURCE \
--api-key ${{ secrets.GITHUB_TOKEN }} \
--skip-duplicate
- name: Publish Symbols
if: github.event_name != 'pull_request'
run: |
dotnet nuget push \
**\*.snupkg \
--source $PACKAGE_SOURCE \
--api-key ${{ secrets.GITHUB_TOKEN }} \
--skip-duplicate