mirror of
https://github.com/Smaug123/unofficial-nunit-runner
synced 2025-10-12 04:08:38 +00:00
Prerelease packaging (#45)
This commit is contained in:
119
.github/workflows/dotnet.yaml
vendored
119
.github/workflows/dotnet.yaml
vendored
@@ -165,8 +165,125 @@ jobs:
|
|||||||
- name: Flake check
|
- name: Flake check
|
||||||
run: nix flake check
|
run: nix flake check
|
||||||
|
|
||||||
|
nuget-pack:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # so that NerdBank.GitVersioning has access to history
|
||||||
|
- name: Install Nix
|
||||||
|
uses: cachix/install-nix-action@V27
|
||||||
|
with:
|
||||||
|
extra_nix_config: |
|
||||||
|
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Restore dependencies
|
||||||
|
run: nix develop --command dotnet restore
|
||||||
|
- name: Build
|
||||||
|
run: nix develop --command dotnet build --no-restore --configuration Release
|
||||||
|
- name: Pack
|
||||||
|
run: nix develop --command dotnet pack --configuration Release
|
||||||
|
- name: Upload NuGet artifact (lib)
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: nuget-package-lib
|
||||||
|
path: TestRunner.Lib/bin/Release/WoofWare.NUnitTestRunner.Lib.*.nupkg
|
||||||
|
- name: Upload NuGet artifact (tool)
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: nuget-package-tool
|
||||||
|
path: TestRunner/bin/Release/WoofWare.NUnitTestRunner.*.nupkg
|
||||||
|
|
||||||
|
expected-pack:
|
||||||
|
needs: [nuget-pack]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Download NuGet artifact (lib)
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: nuget-package-lib
|
||||||
|
path: packed-lib
|
||||||
|
- name: Check NuGet contents (lib)
|
||||||
|
# Verify that there is exactly one nupkg in the artifact that would be NuGet published
|
||||||
|
run: if [[ $(find packed-lib -maxdepth 1 -name 'WoofWare.NUnitTestRunner.Lib.*.nupkg' -printf c | wc -c) -ne "1" ]]; then exit 1; fi
|
||||||
|
- name: Download NuGet artifact (tool)
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: nuget-package-tool
|
||||||
|
path: packed-tool
|
||||||
|
- name: Check NuGet contents
|
||||||
|
# Verify that there is exactly one nupkg in the artifact that would be NuGet published
|
||||||
|
run: if [[ $(find packed-tool -maxdepth 1 -name 'WoofWare.NUnitTestRunner.*.nupkg' -printf c | wc -c) -ne "1" ]]; then exit 1; fi
|
||||||
|
|
||||||
|
github-release-tool-dry-run:
|
||||||
|
needs: [nuget-pack]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Download NuGet artifact (lib)
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: nuget-package-lib
|
||||||
|
- name: Download NuGet artifact (tool)
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: nuget-package-tool
|
||||||
|
- name: Tag and release tool
|
||||||
|
env:
|
||||||
|
DRY_RUN: 1
|
||||||
|
GITHUB_TOKEN: mock-token
|
||||||
|
run: sh .github/workflows/tag.sh
|
||||||
|
|
||||||
all-required-checks-complete:
|
all-required-checks-complete:
|
||||||
needs: [check-dotnet-format, check-nix-format, build, build-nix, linkcheck, flake-check, analyzers]
|
needs: [check-dotnet-format, check-nix-format, build, build-nix, linkcheck, flake-check, analyzers, nuget-pack, expected-pack, github-release-tool-dry-run]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- run: echo "All required checks complete."
|
- run: echo "All required checks complete."
|
||||||
|
|
||||||
|
nuget-publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: ${{ !github.event.repository.fork && github.ref == 'refs/heads/main' }}
|
||||||
|
needs: [all-required-checks-complete]
|
||||||
|
environment: main-deploy
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Install Nix
|
||||||
|
uses: cachix/install-nix-action@V27
|
||||||
|
with:
|
||||||
|
extra_nix_config: |
|
||||||
|
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Download NuGet artifact (lib)
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: nuget-package-lib
|
||||||
|
path: packed-lib
|
||||||
|
- name: Publish to NuGet (lib)
|
||||||
|
run: nix develop --command dotnet nuget push "packed-lib/WoofWare.NUnitTestRunner.Lib.*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
|
||||||
|
- name: Download NuGet artifact (tool)
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: nuget-package-tool
|
||||||
|
path: packed-tool
|
||||||
|
- name: Publish to NuGet (tool)
|
||||||
|
run: nix develop --command dotnet nuget push "packed-tool/WoofWare.NUnitTestRunner.*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
|
||||||
|
|
||||||
|
github-release-tool:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: ${{ !github.event.repository.fork && github.ref == 'refs/heads/main' }}
|
||||||
|
needs: [all-required-checks-complete]
|
||||||
|
environment: main-deploy
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Download NuGet artifact (tool)
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: nuget-package-tool
|
||||||
|
- name: Download NuGet artifact (lib)
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: nuget-package-lib
|
||||||
|
- name: Tag and release plugin
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: sh .github/workflows/tag.sh
|
||||||
|
124
.github/workflows/tag.sh
vendored
Normal file
124
.github/workflows/tag.sh
vendored
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Dry-run? $DRY_RUN!"
|
||||||
|
|
||||||
|
find . -maxdepth 1 -type f ! -name "$(printf "*\n*")" -name '*.nupkg' | while IFS= read -r file
|
||||||
|
do
|
||||||
|
tag=$(basename "$file" .nupkg)
|
||||||
|
git tag "$tag"
|
||||||
|
${DRY_RUN:+echo} git push origin "$tag"
|
||||||
|
done
|
||||||
|
|
||||||
|
export TAG
|
||||||
|
TAG=$(find . -maxdepth 1 -type f -name 'WoofWare.NUnitTestRunner.*.nupkg' -exec sh -c 'basename "$1" .nupkg' shell {} \; | grep -v Lib)
|
||||||
|
|
||||||
|
case "$TAG" in
|
||||||
|
*"
|
||||||
|
"*)
|
||||||
|
echo "Error: TAG contains a newline; multiple tools found."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# target_commitish empty indicates the repo default branch
|
||||||
|
IS_PRERELEASE="false"
|
||||||
|
if [ "${TAG#*prerelease}" != "$TAG" ]; then
|
||||||
|
IS_PRERELEASE="true"
|
||||||
|
fi
|
||||||
|
curl_body='{"tag_name":"'"$TAG"'","target_commitish":"","name":"'"$TAG"'","draft":false,"prerelease":'"$IS_PRERELEASE"',"generate_release_notes":false}'
|
||||||
|
|
||||||
|
echo "cURL body: $curl_body"
|
||||||
|
|
||||||
|
failed_output=$(cat <<'EOF'
|
||||||
|
{
|
||||||
|
"message": "Validation Failed",
|
||||||
|
"errors": [
|
||||||
|
{
|
||||||
|
"resource": "Release",
|
||||||
|
"code": "already_exists",
|
||||||
|
"field": "tag_name"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"documentation_url": "https://docs.github.com/rest/releases/releases#create-a-release"
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
success_output=$(cat <<'EOF'
|
||||||
|
{
|
||||||
|
"url": "https://api.github.com/repos/Smaug123/unofficial-nunit-runner/releases/158152116",
|
||||||
|
"assets_url": "https://api.github.com/repos/Smaug123/unofficial-nunit-runner/releases/158152116/assets",
|
||||||
|
"upload_url": "https://uploads.github.com/repos/Smaug123/unofficial-nunit-runner/releases/158152116/assets{?name,label}",
|
||||||
|
"html_url": "https://github.com/Smaug123/unofficial-nunit-runner/releases/tag/WoofWare.NUnitTestRunner.2.1.30",
|
||||||
|
"id": 158152116,
|
||||||
|
"author": {
|
||||||
|
"login": "github-actions[bot]",
|
||||||
|
"id": 41898282,
|
||||||
|
"node_id": "MDM6Qm90NDE4OTgyODI=",
|
||||||
|
"avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
|
||||||
|
"gravatar_id": "",
|
||||||
|
"url": "https://api.github.com/users/github-actions%5Bbot%5D",
|
||||||
|
"html_url": "https://github.com/apps/github-actions",
|
||||||
|
"followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
|
||||||
|
"following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
|
||||||
|
"gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
|
||||||
|
"starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
|
||||||
|
"subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
|
||||||
|
"organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
|
||||||
|
"repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
|
||||||
|
"events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
|
||||||
|
"received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
|
||||||
|
"type": "Bot",
|
||||||
|
"site_admin": false
|
||||||
|
},
|
||||||
|
"node_id": "RE_kwDOJfksgc4JbTW0",
|
||||||
|
"tag_name": "WoofWare.NUnitTestRunner.2.1.30",
|
||||||
|
"target_commitish": "main",
|
||||||
|
"name": "WoofWare.NUnitTestRunner.2.1.30",
|
||||||
|
"draft": false,
|
||||||
|
"prerelease": false,
|
||||||
|
"created_at": "2024-05-30T11:00:55Z",
|
||||||
|
"published_at": "2024-05-30T11:03:02Z",
|
||||||
|
"assets": [
|
||||||
|
|
||||||
|
],
|
||||||
|
"tarball_url": "https://api.github.com/repos/Smaug123/unofficial-nunit-runner/tarball/WoofWare.NUnitTestRunner.2.1.30",
|
||||||
|
"zipball_url": "https://api.github.com/repos/Smaug123/unofficial-nunit-runner/zipball/WoofWare.NUnitTestRunner.2.1.30",
|
||||||
|
"body": null
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
HANDLE_OUTPUT=''
|
||||||
|
handle_error() {
|
||||||
|
ERROR_OUTPUT="$1"
|
||||||
|
exit_message=$(echo "$ERROR_OUTPUT" | jq -r --exit-status 'if .errors | length == 1 then .errors[0].code else null end')
|
||||||
|
if [ "$exit_message" = "already_exists" ] ; then
|
||||||
|
HANDLE_OUTPUT="Did not create GitHub release because it already exists at this version."
|
||||||
|
else
|
||||||
|
echo "Unexpected error output from curl: $(cat curl_output.json)"
|
||||||
|
echo "JQ output: $(exit_message)"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
run_tests() {
|
||||||
|
handle_error "$failed_output"
|
||||||
|
if [ "$HANDLE_OUTPUT" != "Did not create GitHub release because it already exists at this version." ]; then
|
||||||
|
echo "Bad output from handler: $HANDLE_OUTPUT"
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
HANDLE_OUTPUT=''
|
||||||
|
echo "Tests passed."
|
||||||
|
}
|
||||||
|
|
||||||
|
run_tests
|
||||||
|
|
||||||
|
if [ "$DRY_RUN" != 1 ] ; then
|
||||||
|
if curl --fail-with-body -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/Smaug123/unofficial-nunit-runner/releases -d "$curl_body" > curl_output.json; then
|
||||||
|
echo "Curl succeeded."
|
||||||
|
else
|
||||||
|
handle_error "$(cat curl_output.json)"
|
||||||
|
echo "$HANDLE_OUTPUT"
|
||||||
|
fi
|
||||||
|
fi
|
@@ -1,8 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
<PackAsTool>true</PackAsTool>
|
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<Authors>Patrick Stevens</Authors>
|
<Authors>Patrick Stevens</Authors>
|
||||||
<Copyright>Copyright (c) Patrick Stevens 2024</Copyright>
|
<Copyright>Copyright (c) Patrick Stevens 2024</Copyright>
|
||||||
@@ -12,6 +11,7 @@
|
|||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||||
<PackageTags>nunit;test;runner</PackageTags>
|
<PackageTags>nunit;test;runner</PackageTags>
|
||||||
|
<PackageId>WoofWare.NUnitTestRunner.Lib</PackageId>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
<WarnOn>FS3559</WarnOn>
|
<WarnOn>FS3559</WarnOn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"version": "0.7",
|
"version": "0.7-prerelease",
|
||||||
"publicReleaseRefSpec": null,
|
"publicReleaseRefSpec": ["^refs/heads/main$"],
|
||||||
"pathFilters": [
|
"pathFilters": [
|
||||||
"./",
|
"./",
|
||||||
":/Directory.Build.props",
|
":/Directory.Build.props",
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||||
<PackageTags>nunit;test;runner</PackageTags>
|
<PackageTags>nunit;test;runner</PackageTags>
|
||||||
|
<PackageId>WoofWare.NUnitTestRunner</PackageId>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
<WarnOn>FS3559</WarnOn>
|
<WarnOn>FS3559</WarnOn>
|
||||||
<WoofWareMyriadPluginVersion>2.1.40</WoofWareMyriadPluginVersion>
|
<WoofWareMyriadPluginVersion>2.1.40</WoofWareMyriadPluginVersion>
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"version": "0.1",
|
"version": "0.1-prerelease",
|
||||||
|
"publicReleaseRefSpec": ["^refs/heads/main$"],
|
||||||
"pathFilters": [
|
"pathFilters": [
|
||||||
"./",
|
"./",
|
||||||
"^TestRunner.Test/",
|
"^TestRunner.Test/",
|
||||||
|
Reference in New Issue
Block a user