-
Notifications
You must be signed in to change notification settings - Fork 1
72 lines (69 loc) · 3.3 KB
/
Copy pathrelease.yml
File metadata and controls
72 lines (69 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Release
on:
push:
tags: ['v[0-9]+.[0-9]+.[0-9]+*']
permissions:
attestations: write
contents: write
id-token: write
jobs:
publish:
runs-on: ubuntu-latest
environment: release
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-dotnet@v6
with:
dotnet-version: |
8.x
9.x
10.x
- name: Verify tag commit is on main
shell: bash
run: git merge-base --is-ancestor "$GITHUB_SHA" origin/main
- name: Derive version
shell: bash
run: echo "PACKAGE_VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV"
- run: dotnet restore --locked-mode
- run: dotnet build --configuration Release --no-restore --no-incremental -p:Version=${{ env.PACKAGE_VERSION }}
- run: dotnet test --configuration Release --no-build
- run: dotnet pack src/OpenDisNet/OpenDisNet.csproj --configuration Release --no-build --no-restore --output artifacts/packages -p:Version=${{ env.PACKAGE_VERSION }} -p:PackageVersion=${{ env.PACKAGE_VERSION }}
- name: Inspect package
shell: pwsh
run: ./eng/Validate-Package.ps1 -PackagePath ./artifacts/packages/OpenDisNet.${{ env.PACKAGE_VERSION }}.nupkg -ExpectedVersion ${{ env.PACKAGE_VERSION }}
- name: Restore packed-package consumer
run: dotnet restore tests/OpenDisNet.PackageSmoke/OpenDisNet.PackageSmoke.csproj --source "${{ github.workspace }}/artifacts/packages" --force --no-cache -p:OpenDisNetPackageVersion=${{ env.PACKAGE_VERSION }}
- name: Run packed-package consumer on .NET 8
run: dotnet run --project tests/OpenDisNet.PackageSmoke/OpenDisNet.PackageSmoke.csproj --configuration Release --framework net8.0 --no-restore -p:OpenDisNetPackageVersion=${{ env.PACKAGE_VERSION }}
- name: Run packed-package consumer on .NET 9
run: dotnet run --project tests/OpenDisNet.PackageSmoke/OpenDisNet.PackageSmoke.csproj --configuration Release --framework net9.0 --no-restore -p:OpenDisNetPackageVersion=${{ env.PACKAGE_VERSION }}
- name: Run packed-package consumer on .NET 10
run: dotnet run --project tests/OpenDisNet.PackageSmoke/OpenDisNet.PackageSmoke.csproj --configuration Release --framework net10.0 --no-restore -p:OpenDisNetPackageVersion=${{ env.PACKAGE_VERSION }}
- name: Create package checksums
shell: bash
run: |
cd artifacts/packages
sha256sum *.nupkg *.snupkg > SHA256SUMS
- name: Attest package provenance
uses: actions/attest-build-provenance@v4
with:
subject-path: artifacts/packages/*
- name: Authenticate to NuGet.org
uses: NuGet/login@v1
id: nuget
with:
user: ${{ secrets.NUGET_USER }}
- name: Publish NuGet packages
run: dotnet nuget push "artifacts/packages/*.nupkg" --api-key "${{ steps.nuget.outputs.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
flags=(--generate-notes --verify-tag)
if [[ "${{ github.ref_name }}" == *-* ]]; then
flags+=(--prerelease)
fi
gh release create "${{ github.ref_name }}" artifacts/packages/* "${flags[@]}"