-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge the main branch from https://github.com/aarnott/Library.Template
Specifically, this merges [03ec9e0 from that repo](AArnott/Library.Template@03ec9e0).
- Loading branch information
Showing
6 changed files
with
231 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Publish artifacts | ||
description: Publish artifacts | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: 📥 Collect artifacts | ||
run: azure-pipelines/artifacts/_stage_all.ps1 | ||
shell: pwsh | ||
if: always() | ||
|
||
# TODO: replace this hard-coded list with a loop that utilizes the NPM package at | ||
# https://github.com/actions/toolkit/tree/main/packages/artifact (or similar) to push the artifacts. | ||
|
||
- name: 📢 Upload project.assets.json files | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: projectAssetsJson-${{ runner.os }} | ||
path: ${{ runner.temp }}/_artifacts/projectAssetsJson | ||
continue-on-error: true | ||
- name: 📢 Upload variables | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: variables-${{ runner.os }} | ||
path: ${{ runner.temp }}/_artifacts/Variables | ||
continue-on-error: true | ||
- name: 📢 Upload build_logs | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: build_logs-${{ runner.os }} | ||
path: ${{ runner.temp }}/_artifacts/build_logs | ||
continue-on-error: true | ||
- name: 📢 Upload test_logs | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: test_logs-${{ runner.os }} | ||
path: ${{ runner.temp }}/_artifacts/test_logs | ||
continue-on-error: true | ||
- name: 📢 Upload testResults | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: testResults-${{ runner.os }} | ||
path: ${{ runner.temp }}/_artifacts/testResults | ||
continue-on-error: true | ||
- name: 📢 Upload coverageResults | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: coverageResults-${{ runner.os }} | ||
path: ${{ runner.temp }}/_artifacts/coverageResults | ||
continue-on-error: true | ||
- name: 📢 Upload symbols | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: symbols-${{ runner.os }} | ||
path: ${{ runner.temp }}/_artifacts/symbols | ||
continue-on-error: true | ||
- name: 📢 Upload deployables | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: deployables-${{ runner.os }} | ||
path: ${{ runner.temp }}/_artifacts/deployables | ||
if: always() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: 🏭 Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- validate/* | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
env: | ||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | ||
BUILDCONFIGURATION: Release | ||
# codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/ | ||
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages/ | ||
|
||
jobs: | ||
build: | ||
name: 🏭 Build | ||
|
||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: | ||
- ubuntu-22.04 | ||
- macos-14 | ||
- windows-2022 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # avoid shallow clone so nbgv can do its work. | ||
- name: ⚙ Install prerequisites | ||
run: | | ||
./init.ps1 -UpgradePrerequisites | ||
dotnet --info | ||
# Print mono version if it is present. | ||
if (Get-Command mono -ErrorAction SilentlyContinue) { | ||
mono --version | ||
} | ||
shell: pwsh | ||
- name: ⚙️ Set pipeline variables based on source | ||
run: azure-pipelines/variables/_pipelines.ps1 | ||
shell: pwsh | ||
- name: 🛠 build | ||
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" | ||
- name: 🧪 test | ||
run: azure-pipelines/dotnet-test-cloud.ps1 -Configuration ${{ env.BUILDCONFIGURATION }} -Agent ${{ runner.os }} | ||
shell: pwsh | ||
- name: 💅🏻 Verify formatted code | ||
run: dotnet format --verify-no-changes --no-restore | ||
shell: pwsh | ||
if: runner.os == 'Linux' | ||
- name: 📚 Verify docfx build | ||
run: dotnet docfx docfx/docfx.json --warningsAsErrors --disableGitFeatures | ||
if: runner.os == 'Linux' | ||
- name: ⚙ Update pipeline variables based on build outputs | ||
run: azure-pipelines/variables/_pipelines.ps1 | ||
shell: pwsh | ||
- name: 📢 Publish artifacts | ||
uses: ./.github/actions/publish-artifacts | ||
- name: 📢 Publish code coverage results to codecov.io | ||
run: ./azure-pipelines/publish-CodeCov.ps1 -CodeCovToken "${{ env.codecov_token }}" -PathToCodeCoverage "${{ runner.temp }}/_artifacts/coverageResults" -Name "${{ runner.os }} Coverage Results" -Flags "${{ runner.os }}" | ||
shell: pwsh | ||
timeout-minutes: 3 | ||
continue-on-error: true | ||
if: env.codecov_token != '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: 🎁 Release | ||
|
||
on: | ||
release: | ||
types: [published] | ||
workflow_dispatch: | ||
inputs: | ||
ship_run_id: | ||
description: ID of the GitHub workflow run to ship | ||
required: true | ||
|
||
run-name: ${{ github.ref_name }} | ||
|
||
permissions: | ||
actions: read | ||
contents: write | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: ⚙️ Initialization | ||
shell: pwsh | ||
run: | | ||
if ('${{ secrets.NUGET_API_KEY }}') { | ||
echo "NUGET_API_KEY_DEFINED=true" >> $GITHUB_ENV | ||
} | ||
- name: 🔎 Search for build of ${{ github.ref }} | ||
shell: pwsh | ||
id: findrunid | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
if ('${{ inputs.ship_run_id }}') { | ||
$runid = '${{ inputs.ship_run_id }}' | ||
} else { | ||
$restApiRoot = '/repos/${{ github.repository }}' | ||
# Resolve the tag reference to a commit sha | ||
$resolvedRef = gh api ` | ||
-H "Accept: application/vnd.github+json" ` | ||
-H "X-GitHub-Api-Version: 2022-11-28" ` | ||
$restApiRoot/git/ref/tags/${{ github.ref_name }} ` | ||
| ConvertFrom-Json | ||
$commitSha = $resolvedRef.object.sha | ||
Write-Host "Resolved ${{ github.ref_name }} to $commitSha" | ||
$releases = gh run list -R ${{ github.repository }} -c $commitSha -w .github/workflows/build.yml -s success --json databaseId,startedAt ` | ||
| ConvertFrom-Json | Sort-Object startedAt -Descending | ||
if ($releases.length -eq 0) { | ||
Write-Error "No successful builds found for ${{ github.ref }}." | ||
} elseif ($releases.length -gt 1) { | ||
Write-Warning "More than one successful run found for ${{ github.ref }}. Artifacts from the most recent successful run will ship." | ||
} | ||
$runid = $releases[0].databaseId | ||
} | ||
Write-Host "Using artifacts from run-id: $runid" | ||
Echo "runid=$runid" >> $env:GITHUB_OUTPUT | ||
- name: 🔻 Download deployables artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: deployables-Linux | ||
path: ${{ runner.temp }}/deployables | ||
run-id: ${{ steps.findrunid.outputs.runid }} | ||
github-token: ${{ github.token }} | ||
|
||
- name: 💽 Upload artifacts to release | ||
shell: pwsh | ||
if: ${{ github.event.release.assets_url }} != '' | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
Get-ChildItem '${{ runner.temp }}/deployables' |% { | ||
Write-Host "Uploading $($_.Name) to release..." | ||
gh release -R ${{ github.repository }} upload "${{ github.ref_name }}" $_.FullName | ||
} | ||
- name: 🚀 Push NuGet packages | ||
run: dotnet nuget push ${{ runner.temp }}/deployables/*.nupkg --source https://api.nuget.org/v3/index.json -k '${{ secrets.NUGET_API_KEY }}' | ||
if: ${{ env.NUGET_API_KEY_DEFINED == 'true' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters