Skip to content

Commit 9481a5c

Browse files
committed
Specifically, this merges [7bb9a6c from that repo](AArnott/Library.Template@7bb9a6c).
2 parents a8a1b65 + 7bb9a6c commit 9481a5c

File tree

6 files changed

+185
-5
lines changed

6 files changed

+185
-5
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Publish artifacts
2+
description: Publish artifacts
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: 📥 Collect artifacts
8+
run: azure-pipelines/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 test_logs
36+
if: always()
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: test_logs-${{ runner.os }}
40+
path: ${{ runner.temp }}/_artifacts/test_logs
41+
continue-on-error: true
42+
- name: 📢 Upload testResults
43+
if: always()
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: testResults-${{ runner.os }}
47+
path: ${{ runner.temp }}/_artifacts/testResults
48+
continue-on-error: true
49+
- name: 📢 Upload coverageResults
50+
if: always()
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: coverageResults-${{ runner.os }}
54+
path: ${{ runner.temp }}/_artifacts/coverageResults
55+
continue-on-error: true
56+
- name: 📢 Upload symbols
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: symbols-${{ runner.os }}
60+
path: ${{ runner.temp }}/_artifacts/symbols
61+
continue-on-error: true
62+
- name: 📢 Upload deployables
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: deployables-${{ runner.os }}
66+
path: ${{ runner.temp }}/_artifacts/deployables
67+
if: always()

.github/workflows/docs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ permissions:
1010
actions: read
1111
pages: write
1212
id-token: write
13+
contents: read
1314

1415
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
1516
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.

.github/workflows/libtemplate-update.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Library.Template update
1+
name: Library.Template update
22

33
# 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

.github/workflows/release.yml

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

CONTRIBUTING.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,29 @@ NPM packages too.
4545

4646
The Visual Studio 2019 Test Explorer will list and execute all tests.
4747

48+
## Releases
49+
50+
Use `nbgv tag` to create a tag for a particular commit that you mean to release.
51+
[Learn more about `nbgv` and its `tag` and `prepare-release` commands](https://github.com/dotnet/Nerdbank.GitVersioning/blob/main/doc/nbgv-cli.md).
52+
53+
Push the tag.
54+
55+
### GitHub Actions
56+
57+
When your repo is hosted by GitHub and you are using GitHub Actions, you should create a GitHub Release using the standard GitHub UI.
58+
Having previously used `nbgv tag` and pushing the tag will help you identify the precise commit and name to use for this release.
59+
60+
After publishing the release, the `.github\workflows\release.yml` workflow will be automatically triggered, which will:
61+
62+
1. Find the most recent `.github\workflows\build.yml` GitHub workflow run of the tagged release.
63+
1. Upload the `deployables` artifact from that workflow run to your GitHub Release.
64+
1. If you have `NUGET_API_KEY` defined as a secret variable for your repo or org, any nuget packages in the `deployables` artifact will be pushed to nuget.org.
65+
66+
### Azure Pipelines
67+
68+
When your repo builds with Azure Pipelines, use the `azure-pipelines/release.yml` pipeline.
69+
Trigger the pipeline by adding the `auto-release` tag on a run of your main `azure-pipelines.yml` pipeline.
70+
4871
## Tutorial and API documentation
4972

5073
API and hand-written docs are found under the `docfx/` directory. and are built by [docfx](https://dotnet.github.io/docfx/).

azure-pipelines/artifacts/coverageResults.ps1

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ $RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..")
33
$coverageFiles = @(Get-ChildItem "$RepoRoot/test/*.cobertura.xml" -Recurse | Where {$_.FullName -notlike "*/In/*" -and $_.FullName -notlike "*\In\*" })
44

55
# Prepare code coverage reports for merging on another machine
6-
if ($env:SYSTEM_DEFAULTWORKINGDIRECTORY) {
7-
Write-Host "Substituting $env:SYSTEM_DEFAULTWORKINGDIRECTORY with `"{reporoot}`""
6+
$repoRoot = $env:SYSTEM_DEFAULTWORKINGDIRECTORY
7+
if (!$repoRoot) { $repoRoot = $env:GITHUB_WORKSPACE }
8+
if ($repoRoot) {
9+
Write-Host "Substituting $repoRoot with `"{reporoot}`""
810
$coverageFiles |% {
9-
$content = Get-Content -LiteralPath $_ |% { $_ -Replace [regex]::Escape($env:SYSTEM_DEFAULTWORKINGDIRECTORY), "{reporoot}" }
11+
$content = Get-Content -LiteralPath $_ |% { $_ -Replace [regex]::Escape($repoRoot), "{reporoot}" }
1012
Set-Content -LiteralPath $_ -Value $content -Encoding UTF8
1113
}
1214
} else {
13-
Write-Warning "coverageResults: Azure Pipelines not detected. Machine-neutral token replacement skipped."
15+
Write-Warning "coverageResults: Cloud build not detected. Machine-neutral token replacement skipped."
1416
}
1517

1618
if (!((Test-Path $RepoRoot\bin) -and (Test-Path $RepoRoot\obj))) { return }

0 commit comments

Comments
 (0)