Skip to content

Commit 5d357f5

Browse files
authored
[chore] Add GitHub Action to build, sign, release NuGet package (#495)
- New GitHub Action config to automate release process on pushing to a tag - Migrate release worker to Windows instead of Ubuntu - Remove unused Unix scripts - Add strong-name certificate to repo (NO SECURITY RISK)
1 parent afb690b commit 5d357f5

15 files changed

+102
-212
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
lint:
1111
runs-on: windows-2022
1212
steps:
13-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@v4
1414

1515
- name: Install .NET SDK
1616
uses: actions/setup-dotnet@v3
@@ -26,7 +26,7 @@ jobs:
2626
Roslyn_Static_Analysis:
2727
runs-on: windows-latest
2828
steps:
29-
- uses: actions/checkout@v3
29+
- uses: actions/checkout@v4
3030

3131
- name: Install .NET SDK
3232
uses: actions/setup-dotnet@v3
@@ -46,7 +46,7 @@ jobs:
4646
Security_Code_Scan:
4747
runs-on: windows-latest
4848
steps:
49-
- uses: actions/checkout@v3
49+
- uses: actions/checkout@v4
5050

5151
- name: Install .NET SDK
5252
uses: actions/setup-dotnet@v3
@@ -62,7 +62,7 @@ jobs:
6262
Coverage_Requirements:
6363
runs-on: ubuntu-22.04
6464
steps:
65-
- uses: actions/checkout@v3
65+
- uses: actions/checkout@v4
6666

6767
- name: Install .NET SDK
6868
uses: actions/setup-dotnet@v3
@@ -79,7 +79,7 @@ jobs:
7979
if: github.ref == 'refs/heads/master'
8080
runs-on: ubuntu-22.04
8181
steps:
82-
- uses: actions/checkout@v3
82+
- uses: actions/checkout@v4
8383

8484
- name: Set up dotnet tools and dependencies
8585
run: make install
@@ -97,7 +97,7 @@ jobs:
9797
if: github.ref == 'refs/heads/master'
9898
runs-on: ubuntu-latest
9999
steps:
100-
- uses: actions/checkout@v3
100+
- uses: actions/checkout@v4
101101

102102
- name: Install .NET SDK
103103
uses: actions/setup-dotnet@v3
@@ -140,7 +140,7 @@ jobs:
140140
- name: Net80
141141
framework: net8.0
142142
steps:
143-
- uses: actions/checkout@v3
143+
- uses: actions/checkout@v4
144144
with:
145145
submodules: true
146146

@@ -180,7 +180,7 @@ jobs:
180180
Integration_Tests:
181181
runs-on: windows-2022
182182
steps:
183-
- uses: actions/checkout@v3
183+
- uses: actions/checkout@v4
184184
with:
185185
submodules: true
186186

@@ -212,7 +212,7 @@ jobs:
212212
FSharp_Compatibility_Tests:
213213
runs-on: windows-2022
214214
steps:
215-
- uses: actions/checkout@v3
215+
- uses: actions/checkout@v4
216216
with:
217217
submodules: true
218218

@@ -245,7 +245,7 @@ jobs:
245245
runs-on: windows-2022
246246
steps:
247247

248-
- uses: actions/checkout@v3
248+
- uses: actions/checkout@v4
249249
with:
250250
submodules: true
251251

.github/workflows/release.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
# ex. "v1.2.3", "v1.2.3-rc1"
7+
- "v[0-9]+.[0-9]+.*"
8+
9+
jobs:
10+
publish:
11+
name: Publish to NuGet
12+
runs-on: windows-latest
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Install .NET SDK
18+
uses: actions/setup-dotnet@v3
19+
with:
20+
# .NET 5 is deprecated and removed from GitHub Actions, we need to manually install it
21+
dotnet-version: |
22+
5.x.x
23+
8.x.x
24+
25+
- name: Setup Nuget
26+
uses: NuGet/[email protected]
27+
28+
- name: Restore NuGet Packages
29+
run: make restore
30+
31+
- name: Set up dotnet tools and dependencies
32+
run: make install
33+
34+
- name: Set up authenticity certificate
35+
run: |
36+
echo "${{ secrets.SM_CLIENT_CERT_FILE_B64 }}" | base64 --decode > /d/Certificate_pkcs12.p12
37+
shell: bash
38+
39+
- name: Set variables
40+
id: variables
41+
run: |
42+
echo "SM_HOST=${{ secrets.SM_HOST }}" >> "$GITHUB_ENV"
43+
echo "SM_API_KEY=${{ secrets.SM_API_KEY }}" >> "$GITHUB_ENV"
44+
echo "SM_CLIENT_CERT_FILE=D:\\Certificate_pkcs12.p12" >> "$GITHUB_ENV"
45+
echo "SM_CLIENT_CERT_PASSWORD=${{ secrets.SM_CLIENT_CERT_PASSWORD }}" >> "$GITHUB_ENV"
46+
echo "C:\Program Files (x86)\Windows Kits\10\App Certification Kit" >> $GITHUB_PATH
47+
echo "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools" >> $GITHUB_PATH
48+
echo "C:\Program Files\DigiCert\DigiCert Keylocker Tools" >> $GITHUB_PATH
49+
shell: bash
50+
51+
- name: Setup Keylocker KSP on Windows
52+
run: |
53+
curl -X GET https://one.digicert.com/signingmanager/api-ui/v1/releases/Keylockertools-windows-x64.msi/download -H "x-api-key:%SM_API_KEY%" -o Keylockertools-windows-x64.msi
54+
msiexec /i Keylockertools-windows-x64.msi /quiet /qn
55+
smksp_registrar.exe list
56+
smctl.exe keypair ls
57+
C:\Windows\System32\certutil.exe -csp "DigiCert Signing Manager KSP" -key -user
58+
shell: cmd
59+
60+
- name: Sync Certificates
61+
run: |
62+
smctl windows certsync
63+
shell: cmd
64+
65+
- name: Build and Sign NuGet package
66+
# TODO: Need to keep signing_cert.snk in the repo
67+
run: |
68+
call scripts\win\build_release_nuget.bat EasyPost EasyPostNETStrongNameSigning.snk "${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }}" Release
69+
shell: cmd
70+
71+
- name: Publish to NuGet
72+
run: make publish key=${{ secrets.NUGET_API_KEY }}

EasyPostNETStrongNameSigning.snk

596 Bytes
Binary file not shown.

Makefile

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ build-prod:
2323
## clean - Clean the project
2424
clean:
2525
dotnet clean
26-
rm -rf *.nupkg
2726

2827
## coverage - Generate coverage reports (unit tests, not integration) for the project
2928
coverage:
@@ -44,10 +43,6 @@ install-tools:
4443
dotnet tool install --local dotnet-format || exit 0
4544
dotnet tool install --local docfx --version 2.60.2 || exit 0
4645

47-
## install-release-tools - Install required tools for release
48-
install-release-tools:
49-
bash scripts/unix/install_osslsigncode.sh
50-
5146
## install-styleguide - Import style guide (Unix only)
5247
install-styleguide: | update-examples-submodule
5348
sh examples/symlink_directory_files.sh examples/style_guides/csharp .
@@ -70,13 +65,13 @@ lint-fix:
7065
lint-scripts:
7166
scripts\win\lint_scripts.bat
7267

73-
## prep-release - Build, sign and package the project for distribution, signing with the provided certificate
68+
## publish - Publish the project to NuGet
7469
# @parameters:
75-
# sncert= - The strong-name certificate to use for signing the built assets.
76-
# cert= - The authenticity certificate to use for signing the built assets.
77-
# pass= - The password for the authenticity certificate.
78-
prep-release:
79-
bash scripts/unix/build_release_nuget.sh EasyPost ${sncert} ${cert} ${pass} Release
70+
# key= - The NuGet API key to use for publishing.
71+
# ref: https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-push
72+
publish:
73+
# Verify that no extraneous .nupkg files exist
74+
dotnet nuget push *.nupkg -Source https://api.nuget.org/v3/index.json -k ${key} -SkipDuplicate
8075

8176
## release - Cuts a release for the project on GitHub (requires GitHub CLI)
8277
# tag = The associated tag title of the release
@@ -135,4 +130,4 @@ fs-compat-test:
135130
vb-compat-test:
136131
dotnet test EasyPost.Compatibility.VB/EasyPost.Compatibility.VB.vbproj -f ${fw} -restore
137132

138-
.PHONY: help analyze build build-fw build-prod clean coverage coverage-check docs format install-styleguide install-tools install-release-tools install lint lint-scripts prep-release release restore scan setup-win setup-unix test update-examples-submodule unit-test integration-test fs-compat-test vb-compat-test
133+
.PHONY: help analyze build build-fw build-prod clean coverage coverage-check docs format install-styleguide install-tools install lint lint-scripts release restore scan setup-win setup-unix test update-examples-submodule unit-test integration-test fs-compat-test vb-compat-test

scripts/unix/build_project.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

scripts/unix/build_release_nuget.sh

Lines changed: 0 additions & 39 deletions
This file was deleted.

scripts/unix/delete_old_assemblies.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

scripts/unix/install_osslsigncode.sh

Lines changed: 0 additions & 38 deletions
This file was deleted.

scripts/unix/pack_nuget.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

scripts/unix/sign_dlls.sh

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)