forked from contre/Windows-API-Code-Pack-1.1
-
Notifications
You must be signed in to change notification settings - Fork 4
167 lines (131 loc) · 4.61 KB
/
main.yml
File metadata and controls
167 lines (131 loc) · 4.61 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
name: Build
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
release:
types: [ "published" ]
permissions:
contents: read
concurrency:
group: main-${{ github.head_ref || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
jobs:
build:
name: ${{ matrix.os }} / ${{ matrix.configuration }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
configuration: [ Debug, Release ]
os: [ windows-2022 ]
env:
SRC_SLN_PATH: source/WindowsAPICodePack
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
steps:
- uses: actions/checkout@v5
# Assuming .NET Framework flavors are available in OS
- name: Install .NET Core Runtimes
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
10.0.x
9.0.x
8.0.x
7.0.x
6.0.x
5.0.x
3.1.x
# https://github.com/microsoft/setup-msbuild
- name: Add MSBuild.exe to PATH
uses: microsoft/setup-msbuild@v2
# Setup Short SHA
- name: Setup Short SHA
run: echo "build_sha=$("${{ github.sha }}".SubString(0, 7))" >> $env:GITHUB_ENV
# Setup Build Suffix (for staging)
- name: Setup Build Suffix
if: github.event_name != 'release'
run: echo "build_suffix=build.${{ env.build_sha }}" >> $env:GITHUB_ENV
# Setup Build Suffix (for release)
- name: Setup Build Suffix
if: github.event_name == 'release'
run: |
$suffix = "${{ github.ref_name }}".Split("-",2)[1]
echo "build_suffix=$( if($suffix) { "${suffix}.${{ env.build_sha }}" } else { '' } )" >> $env:GITHUB_ENV
# Create NuGet Cache
- name: NuGet Cache
id: nuget-cache
uses: actions/cache@v4
with:
path: ${{ env.NUGET_PACKAGES }}
key: ${{ matrix.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ matrix.os }}-nuget-
# Restore Build Deps
- name: Restore Dependencies
run: dotnet restore
working-directory: ${{ env.SRC_SLN_PATH }}
# Build Library
- name: Build the Application
run: dotnet build --no-restore -c $env:Configuration -p:VersionSuffix=${{ env.build_suffix }}
working-directory: ${{ env.SRC_SLN_PATH }}
env:
Configuration: ${{ matrix.configuration }}
# Upload Build Artifacts
- name: Upload Build Artifacts
if: matrix.configuration == 'Release'
uses: actions/upload-artifact@v4
with:
name: nupkg-${{ env.build_sha }}
path: ${{env.SRC_SLN_PATH}}/**/bin/${{ matrix.configuration }}/*.*nupkg
stage:
needs: build
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
name: Stage Artifacts
runs-on: ubuntu-latest
steps:
- name: Setup Short SHA
run: echo "build_sha=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: nupkg-${{ env.build_sha }}
- uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'
- name: Push to NuGet
run: |
for pkg in $GITHUB_WORKSPACE/**/bin/Release/*.nupkg
do
cd $(dirname $pkg)
echo "Publishing $(basename $pkg)"
dotnet nuget push "$(basename $pkg)" -k ${{ secrets.NUGET_TEST_API_KEY }} -s ${{ vars.NUGET_TEST_API_KEY_SOURCE }} --skip-duplicate
done
deploy:
needs: build
if: github.event_name == 'release'
name: Release Artifacts
runs-on: ubuntu-latest
steps:
- name: Setup Short SHA
run: echo "build_sha=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: nupkg-${{ env.build_sha }}
- uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'
- name: Push to NuGet
run: |
for pkg in $GITHUB_WORKSPACE/**/bin/Release/*.nupkg
do
cd $(dirname $pkg)
echo "Publishing $(basename $pkg)"
dotnet nuget push "$(basename $pkg)" -k ${{ secrets.NUGET_API_KEY }} -s ${{ vars.NUGET_API_KEY_SOURCE }} --skip-duplicate
done