Skip to content

Commit c47acef

Browse files
committed
Merge the microbuild branch from https://github.com/aarnott/Library.Template
Specifically, this merges [6ac5aae from that repo](AArnott/Library.Template@6ac5aae).
2 parents 78f6083 + 6ac5aae commit c47acef

File tree

87 files changed

+540
-113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+540
-113
lines changed

.config/dotnet-tools.json

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,29 @@
66
"version": "7.4.6",
77
"commands": [
88
"pwsh"
9-
]
9+
],
10+
"rollForward": false
1011
},
1112
"dotnet-coverage": {
12-
"version": "17.12.6",
13+
"version": "17.13.1",
1314
"commands": [
1415
"dotnet-coverage"
15-
]
16+
],
17+
"rollForward": false
1618
},
1719
"nbgv": {
18-
"version": "3.6.146",
20+
"version": "3.7.112",
1921
"commands": [
2022
"nbgv"
21-
]
23+
],
24+
"rollForward": false
25+
},
26+
"docfx": {
27+
"version": "2.78.2",
28+
"commands": [
29+
"docfx"
30+
],
31+
"rollForward": false
2232
}
2333
}
24-
}
34+
}

.devcontainer/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Refer to https://hub.docker.com/_/microsoft-dotnet-sdk for available versions
2+
FROM mcr.microsoft.com/dotnet/sdk:9.0.101-noble
3+
4+
# Installing mono makes `dotnet test` work without errors even for net472.
5+
# But installing it takes a long time, so it's excluded by default.
6+
#RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
7+
#RUN echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | tee /etc/apt/sources.list.d/mono-official-stable.list
8+
#RUN apt-get update
9+
#RUN DEBIAN_FRONTEND=noninteractive apt-get install -y mono-devel
10+
11+
# Clear the NUGET_XMLDOC_MODE env var so xml api doc files get unpacked, allowing a rich experience in Intellisense.
12+
# See https://github.com/dotnet/dotnet-docker/issues/2790 for a discussion on this, where the prioritized use case
13+
# was *not* devcontainers, sadly.
14+
ENV NUGET_XMLDOC_MODE=

.devcontainer/devcontainer.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "Dev space",
3+
"dockerFile": "Dockerfile",
4+
"customizations": {
5+
"vscode": {
6+
"settings": {
7+
"terminal.integrated.shell.linux": "/usr/bin/pwsh"
8+
},
9+
"extensions": [
10+
"ms-azure-devops.azure-pipelines",
11+
"ms-dotnettools.csharp",
12+
"k--kato.docomment",
13+
"editorconfig.editorconfig",
14+
"esbenp.prettier-vscode",
15+
"pflannery.vscode-versionlens",
16+
"davidanson.vscode-markdownlint",
17+
"dotjoshjohnson.xml",
18+
"ms-vscode-remote.remote-containers",
19+
"ms-azuretools.vscode-docker",
20+
"tintoy.msbuild-project-tools"
21+
]
22+
}
23+
},
24+
"postCreateCommand": "./init.ps1 -InstallLocality machine"
25+
}

.github/.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[renovate.json*]
2+
indent_style = tab
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Publish artifacts
2+
description: Publish artifacts
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: 📥 Collect artifacts
8+
run: tools/artifacts/_stage_all.ps1
9+
shell: pwsh
10+
if: always()
11+
12+
# TODO: replace this hard-coded list with a loop that utilizes the NPM package at
13+
# https://github.com/actions/toolkit/tree/main/packages/artifact (or similar) to push the artifacts.
14+
15+
- name: 📢 Upload project.assets.json files
16+
if: always()
17+
uses: actions/upload-artifact@v4
18+
with:
19+
name: projectAssetsJson-${{ runner.os }}
20+
path: ${{ runner.temp }}/_artifacts/projectAssetsJson
21+
continue-on-error: true
22+
- name: 📢 Upload variables
23+
uses: actions/upload-artifact@v4
24+
with:
25+
name: variables-${{ runner.os }}
26+
path: ${{ runner.temp }}/_artifacts/Variables
27+
continue-on-error: true
28+
- name: 📢 Upload build_logs
29+
if: always()
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: build_logs-${{ runner.os }}
33+
path: ${{ runner.temp }}/_artifacts/build_logs
34+
continue-on-error: true
35+
- name: 📢 Upload testResults
36+
if: always()
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: testResults-${{ runner.os }}
40+
path: ${{ runner.temp }}/_artifacts/testResults
41+
continue-on-error: true
42+
- name: 📢 Upload coverageResults
43+
if: always()
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: coverageResults-${{ runner.os }}
47+
path: ${{ runner.temp }}/_artifacts/coverageResults
48+
continue-on-error: true
49+
- name: 📢 Upload symbols
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: symbols-${{ runner.os }}
53+
path: ${{ runner.temp }}/_artifacts/symbols
54+
continue-on-error: true
55+
- name: 📢 Upload deployables
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: deployables-${{ runner.os }}
59+
path: ${{ runner.temp }}/_artifacts/deployables
60+
if: always()

.github/dependabot.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/renovate.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": ["config:recommended"],
4+
"semanticCommits": "disabled",
5+
"labels": ["dependencies"],
6+
"packageRules": [
7+
{
8+
"matchPackageNames": ["nbgv", "nerdbank.gitversioning"],
9+
"groupName": "nbgv and nerdbank.gitversioning updates"
10+
},
11+
{
12+
"matchPackageNames": ["xunit*"],
13+
"groupName": "xunit"
14+
},
15+
{
16+
"matchDatasources": ["dotnet-version", "docker"],
17+
"matchDepNames": ["dotnet-sdk", "mcr.microsoft.com/dotnet/sdk"],
18+
"groupName": "Dockerfile and global.json updates"
19+
}
20+
]
21+
}

.github/workflows/docs.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: 📚 Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
9+
permissions:
10+
actions: read
11+
pages: write
12+
id-token: write
13+
contents: read
14+
15+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
16+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
17+
concurrency:
18+
group: pages
19+
cancel-in-progress: false
20+
21+
jobs:
22+
publish-docs:
23+
environment:
24+
name: github-pages
25+
url: ${{ steps.deployment.outputs.page_url }}
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
31+
- name: ⚙ Install prerequisites
32+
run: ./init.ps1 -UpgradePrerequisites
33+
34+
- run: dotnet docfx docfx/docfx.json
35+
name: 📚 Generate documentation
36+
37+
- name: Upload artifact
38+
uses: actions/upload-pages-artifact@v3
39+
with:
40+
path: docfx/_site
41+
42+
- name: Deploy to GitHub Pages
43+
id: deployment
44+
uses: actions/deploy-pages@v4

.github/workflows/libtemplate-update.yml

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
name: Library.Template update
1+
name: Library.Template update
22

3-
# PREREQUISITE: This workflow requires the repo to be configured to allow workflows to push commits and create pull requests.
3+
# PREREQUISITE: This workflow requires the repo to be configured to allow workflows to create pull requests.
44
# Visit https://github.com/USER/REPO/settings/actions
5-
# Under "Workflow permissions", select "Read and write permissions" and check "Allow GitHub Actions to create ...pull requests"
5+
# Under "Workflow permissions" check "Allow GitHub Actions to create ...pull requests"
66
# Click Save.
77

88
on:
@@ -13,15 +13,19 @@ on:
1313
jobs:
1414
merge:
1515
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write
18+
pull-requests: write
1619
steps:
1720
- uses: actions/checkout@v4
1821
with:
1922
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
2023

2124
- name: merge
25+
id: merge
2226
shell: pwsh
2327
run: |
24-
$LibTemplateBranch = & ./azure-pipelines/Get-LibTemplateBasis.ps1 -ErrorIfNotRelated
28+
$LibTemplateBranch = & ./tools/Get-LibTemplateBasis.ps1 -ErrorIfNotRelated
2529
if ($LASTEXITCODE -ne 0) {
2630
exit $LASTEXITCODE
2731
}
@@ -31,15 +35,37 @@ jobs:
3135
exit $LASTEXITCODE
3236
}
3337
$LibTemplateCommit = git rev-parse FETCH_HEAD
38+
git diff --stat ...FETCH_HEAD
3439
3540
if ((git rev-list FETCH_HEAD ^HEAD --count) -eq 0) {
3641
Write-Host "There are no Library.Template updates to merge."
42+
echo "uptodate=true" >> $env:GITHUB_OUTPUT
3743
exit 0
3844
}
3945
40-
git -c http.extraheader="AUTHORIZATION: bearer $env:GH_TOKEN" push origin -u FETCH_HEAD:refs/heads/auto/libtemplateUpdate
46+
# Pushing commits that add or change files under .github/workflows will cause our workflow to fail.
47+
# But it usually isn't necessary because the target branch already has (or doesn't have) these changes.
48+
# So if the merged doesn't bring in any changes to these files, try the merge locally and push that
49+
# to keep github happy.
50+
if ((git rev-list FETCH_HEAD ^HEAD --count -- .github/workflows) -eq 0) {
51+
# Indeed there are no changes in that area. So merge locally to try to appease GitHub.
52+
git checkout -b auto/libtemplateUpdate
53+
git config user.name "Andrew Arnott"
54+
git config user.email "[email protected]"
55+
git merge FETCH_HEAD
56+
if ($LASTEXITCODE -ne 0) {
57+
Write-Host "Merge conflicts prevent creating the pull request. Please run tools/MergeFrom-Template.ps1 locally and push the result as a pull request."
58+
exit 2
59+
}
60+
61+
git -c http.extraheader="AUTHORIZATION: bearer $env:GH_TOKEN" push origin -u HEAD
62+
} else {
63+
Write-Host "Changes to github workflows are included in this update. Please run tools/MergeFrom-Template.ps1 locally and push the result as a pull request."
64+
exit 1
65+
}
4166
- name: pull request
4267
shell: pwsh
68+
if: success() && steps.merge.outputs.uptodate != 'true'
4369
run: |
4470
# If there is already an active pull request, don't create a new one.
4571
$existingPR = gh pr list -H auto/libtemplateUpdate --json url | ConvertFrom-Json
@@ -51,6 +77,8 @@ jobs:
5177
$prTitle = "Merge latest Library.Template"
5278
$prBody = "This merges the latest features and fixes from [Library.Template's branch](https://github.com/AArnott/Library.Template/tree/).
5379
80+
⚠️ Do **not** squash this pull request when completing it. You must *merge* it.
81+
5482
<details>
5583
<summary>Merge conflicts?</summary>
5684
Resolve merge conflicts locally by carrying out these steps:
@@ -63,9 +91,7 @@ jobs:
6391
git commit
6492
git push
6593
```
66-
</details>
67-
68-
⚠️ Do **not** squash this pull request when completing it. You must *merge* it."
94+
</details>"
6995
7096
gh pr create -H auto/libtemplateUpdate -b $prBody -t $prTitle
7197
env:

.github/workflows/release.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: 🎁 Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
ship_run_id:
9+
description: ID of the GitHub workflow run to ship
10+
required: true
11+
12+
run-name: ${{ github.ref_name }}
13+
14+
permissions:
15+
actions: read
16+
contents: write
17+
18+
jobs:
19+
release:
20+
runs-on: ubuntu-24.04
21+
steps:
22+
- name: ⚙️ Initialization
23+
shell: pwsh
24+
run: |
25+
if ('${{ secrets.NUGET_API_KEY }}') {
26+
Write-Host "NUGET_API_KEY secret detected. NuGet packages will be pushed."
27+
echo "NUGET_API_KEY_DEFINED=true" >> $env:GITHUB_ENV
28+
}
29+
30+
- name: 🔎 Search for build of ${{ github.ref }}
31+
shell: pwsh
32+
id: findrunid
33+
env:
34+
GH_TOKEN: ${{ github.token }}
35+
run: |
36+
if ('${{ inputs.ship_run_id }}') {
37+
$runid = '${{ inputs.ship_run_id }}'
38+
} else {
39+
$restApiRoot = '/repos/${{ github.repository }}'
40+
41+
# Resolve the tag reference to a commit sha
42+
$resolvedRef = gh api `
43+
-H "Accept: application/vnd.github+json" `
44+
-H "X-GitHub-Api-Version: 2022-11-28" `
45+
$restApiRoot/git/ref/tags/${{ github.ref_name }} `
46+
| ConvertFrom-Json
47+
$commitSha = $resolvedRef.object.sha
48+
49+
Write-Host "Resolved ${{ github.ref_name }} to $commitSha"
50+
51+
$releases = gh run list -R ${{ github.repository }} -c $commitSha -w .github/workflows/build.yml -s success --json databaseId,startedAt `
52+
| ConvertFrom-Json | Sort-Object startedAt -Descending
53+
54+
if ($releases.length -eq 0) {
55+
Write-Error "No successful builds found for ${{ github.ref }}."
56+
} elseif ($releases.length -gt 1) {
57+
Write-Warning "More than one successful run found for ${{ github.ref }}. Artifacts from the most recent successful run will ship."
58+
}
59+
60+
$runid = $releases[0].databaseId
61+
}
62+
63+
Write-Host "Using artifacts from run-id: $runid"
64+
65+
Echo "runid=$runid" >> $env:GITHUB_OUTPUT
66+
67+
- name: 🔻 Download deployables artifacts
68+
uses: actions/download-artifact@v4
69+
with:
70+
name: deployables-Linux
71+
path: ${{ runner.temp }}/deployables
72+
run-id: ${{ steps.findrunid.outputs.runid }}
73+
github-token: ${{ github.token }}
74+
75+
- name: 💽 Upload artifacts to release
76+
shell: pwsh
77+
if: ${{ github.event.release.assets_url }} != ''
78+
env:
79+
GH_TOKEN: ${{ github.token }}
80+
run: |
81+
Get-ChildItem '${{ runner.temp }}/deployables' |% {
82+
Write-Host "Uploading $($_.Name) to release..."
83+
gh release -R ${{ github.repository }} upload "${{ github.ref_name }}" $_.FullName
84+
}
85+
86+
- name: 🚀 Push NuGet packages
87+
run: dotnet nuget push ${{ runner.temp }}/deployables/*.nupkg --source https://api.nuget.org/v3/index.json -k '${{ secrets.NUGET_API_KEY }}'
88+
if: ${{ env.NUGET_API_KEY_DEFINED == 'true' }}

0 commit comments

Comments
 (0)