Skip to content

Commit aa4813a

Browse files
authored
Switch from Azure Pipelines to GitHub Actions (#1141)
1 parent 02d60f9 commit aa4813a

File tree

20 files changed

+327
-790
lines changed

20 files changed

+327
-790
lines changed

.github/actions/publish-artifacts/action.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,9 @@ runs:
6565
name: deployables-${{ runner.os }}
6666
path: ${{ runner.temp }}/_artifacts/deployables
6767
if: always()
68+
- name: 📢 Upload deployables-LKG
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: deployables-LKG-${{ runner.os }}
72+
path: ${{ runner.temp }}/_artifacts/deployables-LKG
73+
if: always()

.github/workflows/build.yml

Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
1+
name: 🏭 Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- 'v*.*'
8+
- validate/*
9+
pull_request:
10+
workflow_dispatch:
11+
12+
env:
13+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
14+
BUILDCONFIGURATION: Release
15+
# codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/
16+
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages/
17+
18+
# dotnetfoundation code signing
19+
20+
jobs:
21+
build:
22+
name: 🏭 Build
23+
24+
runs-on: ${{ matrix.os }}
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
os:
29+
- ubuntu-22.04
30+
- windows-2022
31+
32+
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
36+
submodules: true
37+
- name: ⚙ Install prerequisites
38+
run: |
39+
./init.ps1 -UpgradePrerequisites
40+
dotnet --info
41+
42+
# Print mono version if it is present.
43+
if (Get-Command mono -ErrorAction SilentlyContinue) {
44+
mono --version
45+
}
46+
shell: pwsh
47+
- name: ⚙ Install 32-bit .NET SDK and runtimes
48+
shell: pwsh
49+
run: |
50+
Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile dotnet-install.ps1
51+
& .\dotnet-install.ps1 -Architecture x86 -Version 9.0.101 -InstallDir "C:\Program Files (x86)\dotnet\" -NoPath -Verbose
52+
if: runner.os == 'Windows'
53+
- name: ⚙️ Set pipeline variables based on source
54+
run: tools/variables/_define.ps1
55+
shell: pwsh
56+
- name: 🛠 build
57+
run: dotnet build -t:build,pack --no-restore -c ${{ env.BUILDCONFIGURATION }} -warnAsError -warnNotAsError:NU1901,NU1902,NU1903,NU1904 /bl:"${{ runner.temp }}/_artifacts/build_logs/build.binlog"
58+
- name: 🛠️ Build LKG package
59+
run: dotnet pack -c ${{ env.BUILDCONFIGURATION }} --no-build -p:PackLKG=true /bl:"${{ runner.temp }}/_artifacts/build_logs/msbuild_lkg.binlog"
60+
working-directory: src/Nerdbank.GitVersioning.Tasks
61+
- name: 📢 Publish nbgv tool
62+
run: dotnet publish -c ${{ env.BUILDCONFIGURATION }} -o ../nerdbank-gitversioning.npm/out/nbgv.cli/tools/net8.0/any /bl:"${{ runner.temp }}/_artifacts/build_logs/nbgv_publish.binlog"
63+
working-directory: src/nbgv
64+
- name: 🛠️ Build nerdbank-gitversioning NPM package
65+
run: yarn build
66+
working-directory: src/nerdbank-gitversioning.npm
67+
- name: Capture .git directory
68+
shell: pwsh
69+
run: |
70+
md ${{ runner.temp }}\_artifacts\drop
71+
7z a ${{ runner.temp }}\_artifacts\drop\nbgv.7z * -r
72+
Write-Host "##vso[artifact.upload containerfolder=drop;artifactname=drop;]${{ runner.temp }}\_artifacts\drop"
73+
if: failure() && runner.os == 'Windows'
74+
- name: 🧪 test
75+
run: |
76+
Write-Host "⚙️ Configure git commit author for testing"
77+
git config --global user.name ci
78+
git config --global user.email [email protected]
79+
80+
Write-Host "🧪 Run tests"
81+
tools/dotnet-test-cloud.ps1 -Configuration ${{ env.BUILDCONFIGURATION }} -Agent ${{ runner.os }} -PublishResults
82+
shell: pwsh
83+
- name: 🧪 test x86
84+
run: tools/dotnet-test-cloud.ps1 -Configuration ${{ env.BUILDCONFIGURATION }} -Agent ${{ runner.os }} -PublishResults -X86
85+
if: success() && runner.os == 'Windows'
86+
- name: 💅🏻 Verify formatted code
87+
run: dotnet format --verify-no-changes --no-restore
88+
shell: pwsh
89+
if: runner.os == 'Linux'
90+
- name: 📚 Verify docfx build
91+
run: dotnet docfx docfx/docfx.json --warningsAsErrors --disableGitFeatures
92+
if: runner.os == 'Linux'
93+
- name: ⚙ Update pipeline variables based on build outputs
94+
run: tools/variables/_define.ps1
95+
shell: pwsh
96+
- name: 📢 Publish artifacts
97+
uses: ./.github/actions/publish-artifacts
98+
if: cancelled() == false
99+
- name: 📦 Push CI package
100+
shell: pwsh
101+
run: |
102+
if ('${{ secrets.AZP_TOKEN }}') {
103+
dotnet nuget add source https://pkgs.dev.azure.com/andrewarnott/OSS/_packaging/PublicCI/nuget/v3/index.json -n publicCI -u andrewarnott -p ${{ secrets.AZP_TOKEN }} --store-password-in-clear-text
104+
dotnet nuget push ${{ runner.temp }}\_artifacts\deployables\*.nupkg -s publicCI -k x
105+
dotnet nuget push ${{ runner.temp }}\_artifacts\deployables-LKG\*.nupkg -s publicCI -k x
106+
}
107+
if: success() && runner.os == 'Windows' && github.event_name != 'pull_request'
108+
continue-on-error: true
109+
- name: 📢 Publish code coverage results to codecov.io
110+
run: ./tools/publish-CodeCov.ps1 -CodeCovToken "${{ env.codecov_token }}" -PathToCodeCoverage "${{ runner.temp }}/_artifacts/coverageResults" -Name "${{ runner.os }} Coverage Results" -Flags "${{ runner.os }}"
111+
shell: pwsh
112+
timeout-minutes: 3
113+
continue-on-error: true
114+
if: env.codecov_token != ''
115+
116+
functional_testing:
117+
name: 🧪 Functional testing
118+
needs: build
119+
runs-on: ${{ matrix.os }}
120+
121+
strategy:
122+
fail-fast: false
123+
matrix:
124+
include:
125+
- os: ubuntu-22.04
126+
container: mcr.microsoft.com/dotnet/sdk:8.0-jammy
127+
- os: ubuntu-22.04
128+
container: mcr.microsoft.com/dotnet/sdk:9.0-noble
129+
- os: ubuntu-22.04
130+
container: mcr.microsoft.com/dotnet/sdk:8.0
131+
- os: ubuntu-22.04
132+
container: mcr.microsoft.com/dotnet/sdk:9.0
133+
- os: macos-14
134+
container: ""
135+
136+
# This uses a matrix value for the container; macOS will have an empty string, which means no container.
137+
container:
138+
image: ${{ matrix.container }}
139+
# GitHub Actions will ignore an empty image automatically.
140+
141+
steps:
142+
- name: Show .NET SDK info
143+
shell: pwsh
144+
run: dotnet --info
145+
146+
- name: Download Build Artifacts
147+
uses: actions/download-artifact@v4
148+
with:
149+
name: deployables-Windows
150+
path: deployables
151+
152+
- name: Set up git username and email address
153+
shell: pwsh
154+
run: |
155+
git config --global init.defaultBranch main
156+
git config --global user.name ci
157+
git config --global user.email [email protected]
158+
159+
- name: Consume NB.GV from .NET build
160+
shell: bash
161+
run: >
162+
PkgFileName=$(ls deployables/Nerdbank.GitVersioning.*nupkg)
163+
164+
NBGV_NuGetPackageVersion=$([[ $PkgFileName =~ Nerdbank.GitVersioning\.(.*)\.nupkg ]] && echo "${BASH_REMATCH[1]}")
165+
166+
echo "<configuration><packageSources><add key='local' value='deployables' /></packageSources></configuration>" > nuget.config &&
167+
dotnet new classlib -o lib &&
168+
cd lib &&
169+
echo '{"version":"42.42"}' > version.json &&
170+
git init &&
171+
git add version.json &&
172+
git commit -m "Initial commit" &&
173+
mkdir lib && cd lib &&
174+
for l in c# f# vb;
175+
do
176+
echo Testing language $l &&
177+
dotnet new classlib -lang=$l &&
178+
dotnet add package nerdbank.gitversioning -v $NBGV_NuGetPackageVersion &&
179+
dotnet pack -c debug /p:TreatWarningsAsErrors=false &&
180+
ls bin/debug/lib.42.42.1*.nupkg 1> /dev/null 2>&1 &&
181+
rm -r *
182+
if [ $? -ne 0 ]; then exit 1; fi
183+
done
184+
185+
- name: Consume Cake.GitVersioning
186+
shell: bash
187+
run: >
188+
PkgFileName=$(ls deployables/Cake.GitVersioning.*nupkg)
189+
190+
NBGV_NuGetPackageVersion=$([[ $PkgFileName =~ Cake.GitVersioning\.(.*)\.nupkg ]] && echo "${BASH_REMATCH[1]}")
191+
192+
echo $NBGV_NuGetPackageVersion
193+
194+
mkdir caketest &&
195+
cd caketest &&
196+
git init &&
197+
dotnet new tool-manifest &&
198+
dotnet tool install Cake.Tool
199+
200+
echo "#addin nuget:?package=Cake.GitVersioning&version=${NBGV_NuGetPackageVersion}&prerelease=true"
201+
202+
echo "#addin nuget:?package=Cake.GitVersioning&version=${NBGV_NuGetPackageVersion}&prerelease=true" > build.cake
203+
204+
echo "Information(GitVersioningGetVersion().Version.ToString());" >> build.cake
205+
206+
dotnet cake
207+
208+
- name: Use nbgv dotnet CLI tool
209+
shell: bash
210+
run: >
211+
echo DOTNET_ROOT=$DOTNET_ROOT
212+
213+
PkgFileName=$(ls deployables/Nerdbank.GitVersioning.*nupkg)
214+
215+
NBGV_NuGetPackageVersion=$([[ $PkgFileName =~ Nerdbank.GitVersioning\.(.*)\.nupkg ]] && echo "${BASH_REMATCH[1]}")
216+
217+
dotnet tool install nbgv --tool-path . --version $NBGV_NuGetPackageVersion --add-source deployables-Windows &&
218+
./nbgv get-version -f json -p lib &&
219+
./nbgv get-version -f json -p lib | grep 42.42.1
220+
221+
perf_testing:
222+
name: 🫏 Performance testing
223+
224+
runs-on: ${{ matrix.os }}
225+
strategy:
226+
fail-fast: false
227+
matrix:
228+
include:
229+
- os: ubuntu-22.04
230+
repoDir: '~/git'
231+
- os: windows-2022
232+
repoDir: '${USERPROFILE}/source/repos'
233+
- os: macos-14
234+
repoDir: '~/git'
235+
236+
steps:
237+
- uses: actions/checkout@v4
238+
with:
239+
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
240+
submodules: true
241+
242+
- name: Install .NET SDK
243+
uses: actions/setup-dotnet@v2
244+
with:
245+
global-json-file: global.json
246+
247+
- name: Show .NET SDK info
248+
run: dotnet --info
249+
250+
- name: Clone test repos
251+
shell: bash
252+
run: |
253+
mkdir -p ${{ matrix.repoDir }}
254+
git clone https://github.com/xunit/xunit ${{ matrix.repoDir }}/xunit
255+
git clone https://github.com/gimlichael/Cuemon ${{ matrix.repoDir }}/Cuemon
256+
git clone https://github.com/kerryjiang/SuperSocket ${{ matrix.repoDir }}/SuperSocket
257+
git clone https://github.com/dotnet/Nerdbank.GitVersioning ${{ matrix.repoDir }}/Nerdbank.GitVersioning
258+
259+
- name: Build in Release mode
260+
run: dotnet build -c Release
261+
working-directory: test/Nerdbank.GitVersioning.Benchmarks
262+
263+
- name: Run benchmarks (packed)
264+
run: dotnet run -c Release -f net9.0 --no-build -- --filter '*GetVersionBenchmarks*' --artifacts ${{ runner.temp }}/_artifacts//benchmarks/packed/${{ matrix.os }}
265+
working-directory: test/Nerdbank.GitVersioning.Benchmarks
266+
267+
- name: Unpack Git repositories
268+
shell: bash
269+
run: |
270+
cd ${{ matrix.repoDir }}/xunit
271+
git unpack-objects < .git/objects/pack/*.pack
272+
273+
cd ${{ matrix.repoDir }}/Cuemon
274+
git unpack-objects < .git/objects/pack/*.pack
275+
276+
cd ${{ matrix.repoDir }}/SuperSocket
277+
git unpack-objects < .git/objects/pack/*.pack
278+
279+
cd ${{ matrix.repoDir }}/Nerdbank.GitVersioning
280+
git unpack-objects < .git/objects/pack/*.pack
281+
282+
- name: Run benchmarks (unpacked)
283+
run: dotnet run -c Release -f net9.0 --no-build -- --filter '*GetVersionBenchmarks*' --artifacts ${{ runner.temp }}/_artifacts//benchmarks/unpacked/${{ matrix.os }}
284+
working-directory: test/Nerdbank.GitVersioning.Benchmarks
285+
286+
- name: Publish benchmarks artifacts
287+
uses: actions/upload-artifact@v4
288+
with:
289+
name: benchmarks-${{ matrix.os }}
290+
path: ${{ runner.temp }}/_artifacts/benchmarks

.github/workflows/release.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
release:
2020
runs-on: ubuntu-24.04
2121
steps:
22+
- uses: actions/checkout@v4
23+
2224
- name: ⚙️ Initialization
2325
shell: pwsh
2426
run: |
@@ -67,11 +69,26 @@ jobs:
6769
- name: 🔻 Download deployables artifacts
6870
uses: actions/download-artifact@v4
6971
with:
70-
name: deployables-Linux
72+
name: deployables-Windows
7173
path: ${{ runner.temp }}/deployables
7274
run-id: ${{ steps.findrunid.outputs.runid }}
7375
github-token: ${{ github.token }}
7476

77+
- name: 🔏 Code sign
78+
shell: pwsh
79+
run: >
80+
dotnet tool install --tool-path obj SignClient
81+
82+
obj/SignClient sign
83+
--baseDirectory '${{ runner.temp }}/deployables'
84+
--input '**/*'
85+
--config '${{ github.workspace }}/.github/SignClient.json'
86+
--filelist '${{ github.workspace }}/.github/signfiles.txt'
87+
--user '${{ secrets.CODESIGN_USERNAME }}'
88+
--secret '${{ secrets.CODESIGN_SECRET }}'
89+
--name 'Nerdbank.GitVersioning'
90+
--descriptionUrl 'https://github.com/dotnet/Nerdbank.GitVersioning'
91+
7592
- name: 💽 Upload artifacts to release
7693
shell: pwsh
7794
if: ${{ github.event.release.assets_url }} != ''
@@ -86,3 +103,12 @@ jobs:
86103
- name: 🚀 Push NuGet packages
87104
run: dotnet nuget push ${{ runner.temp }}/deployables/*.nupkg --source https://api.nuget.org/v3/index.json -k '${{ secrets.NUGET_API_KEY }}'
88105
if: ${{ env.NUGET_API_KEY_DEFINED == 'true' }}
106+
107+
- name: 🚀 Push NPM packages
108+
run: |
109+
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_API_KEY }}
110+
Get-ChildItem '${{ runner.temp }}/deployables/*.tgz' |% {
111+
npm publish $_ --registry=https://registry.npmjs.org/
112+
}
113+
env:
114+
NPM_AUTH_TOKEN: ${{ secrets.NPM_API_KEY }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Nerdbank.GitVersioning
22

3-
[![Build Status](https://dev.azure.com/andrewarnott/OSS/_apis/build/status/Nerdbank.GitVersioning)](https://dev.azure.com/andrewarnott/OSS/_build/latest?definitionId=18)
3+
[![🏭 Build](https://github.com/dotnet/Nerdbank.GitVersioning/actions/workflows/build.yml/badge.svg)](https://github.com/dotnet/Nerdbank.GitVersioning/actions/workflows/build.yml)
44
[![NuGet package](https://img.shields.io/nuget/v/Nerdbank.GitVersioning.svg)](https://nuget.org/packages/Nerdbank.GitVersioning)
55
[![NuGet downloads](https://img.shields.io/nuget/dt/Nerdbank.GitVersioning.svg)](https://nuget.org/packages/Nerdbank.GitVersioning)
66
[![NPM package](https://img.shields.io/npm/v/nerdbank-gitversioning.svg)](https://www.npmjs.com/package/nerdbank-gitversioning)

0 commit comments

Comments
 (0)