Skip to content

Commit 9bd8eb5

Browse files
committed
Move to GitHub actions.
1 parent 2a4fc5b commit 9bd8eb5

File tree

4 files changed

+104
-17
lines changed

4 files changed

+104
-17
lines changed

.github/workflows/release.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Package and publish nupkg
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build:
8+
name: Build app
9+
runs-on: windows-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
14+
- name: Setup MSBuild
15+
uses: microsoft/setup-msbuild@v1
16+
17+
- name: Restore NuGet packages
18+
run: cd src && nuget restore && cd ..
19+
20+
- name: Build
21+
run: msbuild .\src\Org.Openfeed.Client\Org.Openfeed.Client.csproj /t:Pack /p:Configuration=Release /p:PackageOutputPath=..\..\publish
22+
23+
- name: List files in publish directory
24+
run: dir .\publish
25+
26+
- name: Upload build artifacts
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: BuildArtifacts
30+
path: ./publish/*.nupkg
31+
32+
sign:
33+
name: Sign files with Trusted Signing
34+
needs: build
35+
runs-on: windows-latest
36+
permissions:
37+
id-token: write # Required for requesting the JWT
38+
39+
steps:
40+
- name: Download build artifacts
41+
uses: actions/download-artifact@v4
42+
with:
43+
name: BuildArtifacts
44+
path: BuildArtifacts
45+
46+
# .NET is required on the agent for the tool to run
47+
- name: Setup .NET
48+
uses: actions/setup-dotnet@v3
49+
with:
50+
dotnet-version: "9.x"
51+
52+
# Install the code signing tool
53+
- name: Install Sign CLI tool
54+
run: dotnet tool install --tool-path . --prerelease sign
55+
56+
# Login to Azure using a ServicePrincipal configured to authenticate agaist a GitHub Action
57+
- name: "Az CLI login"
58+
uses: azure/login@v1
59+
with:
60+
allow-no-subscriptions: true
61+
enable-AzPSSession: true
62+
creds: ${{ secrets.AZURE_CREDS }}
63+
64+
# Run the signing command
65+
- name: Sign artifacts
66+
uses: azure/powershell@v1
67+
with:
68+
azPSVersion: "latest"
69+
inlineScript: |
70+
./sign code trusted-signing *.nupkg -tse ${{ secrets.AZURE_ENDPOINT }} -tsa ${{secrets.AZURE_CODE_SIGNING_NAME}} -tscp ${{secrets.AZURE_CERT_PROFILE_NAME}} -act azure-powershell --base-directory "./BuildArtifacts"
71+
72+
- name: Extract Certificates For NuGet
73+
run: |
74+
$files = Get-ChildItem -Path ./BuildArtifacts -Filter *.nupkg
75+
if ($files.Count -ne 1) {
76+
Write-Error "Expected exactly one .nupkg file, but found $($files.Count)."
77+
exit 1
78+
}
79+
dotnet tool install Knapcode.CertificateExtractor --global
80+
$file = $files[0].FullName
81+
nuget-cert-extractor --file $file --output ./BuildArtifacts --author --code-signing --leaf
82+
83+
# Publish the signed packages
84+
- name: Upload build artifacts
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: NugetReleaseArtifacts
88+
path: ./BuildArtifacts/*.nupkg

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ To update the protobuf auto-generated files, follow the steps:
2727
## User Guide
2828

2929
The User Guide for this project can be found in the [documentation](DOCUMENTATION.md) page.
30+
31+
## Release Guide
32+
33+
Since we moved to GitHub actions, releasing to NuGet will require additional steps as seen [here](RELEASE_GUIDE.md).

RELEASE_GUIDE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Release
2+
3+
We use GitHub Actions for the release process. It is a manual action that can be triggered in the repository.
4+
5+
### Steps:
6+
7+
1. Trigger the GitHub Action to build, sign, and package the `.nupkg` file.
8+
2. Download the `NugetReleaseArtifacts` files from the workflow artifacts.
9+
3. Log in to [NuGet.org](https://www.nuget.org/):
10+
- Go to **Account > Manage Organizations > Barchart > Edit Icon > Certificates** and upload the `.cer` file (if not already registered).
11+
- Go to **Account > Manage Packages** and upload the `.nupkg` file.
12+
4. Verify that the package is published successfully.

src/Org.Openfeed.Client/Org.Openfeed.Client.csproj

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,4 @@
4646
<PackagePath></PackagePath>
4747
</None>
4848
</ItemGroup>
49-
50-
<PropertyGroup>
51-
<TargetsTriggeredByCompilation>Sign</TargetsTriggeredByCompilation>
52-
</PropertyGroup>
53-
54-
<Target Name="Sign" Condition="'$(Configuration)' == 'Publish'">
55-
<SignFile CertificateThumbprint="$(CertificateThumbprint)" SigningTarget="@(IntermediateAssembly)" TimestampUrl="$(TimestampUrl)" />
56-
</Target>
57-
58-
<Target Name="SignAfterPack" DependsOnTargets="Pack" Condition="'$(Configuration)' == 'Publish'">
59-
<Exec Command="nuget sign $(OutputPath)..\$(PackageId).$(PackageVersion).nupkg -CertificateFingerprint $(CertificateThumbprint) -Timestamper $(TimestampUrl)" />
60-
<Exec Command="nuget sign $(OutputPath)..\$(PackageId).$(PackageVersion).snupkg -CertificateFingerprint $(CertificateThumbprint) -Timestamper $(TimestampUrl)" />
61-
</Target>
62-
63-
<Target Name="PublishToNuGet" DependsOnTargets="SignAfterPack" Condition="'$(Configuration)' == 'Publish'">
64-
<Exec Command="nuget push $(OutputPath)..\$(PackageId).$(PackageVersion).nupkg -ApiKey $(NuGetApiKey) -Source https://api.nuget.org/v3/index.json" />
65-
</Target>
6649
</Project>

0 commit comments

Comments
 (0)