Skip to content

Commit dd53a1e

Browse files
authored
Update build (#136)
Uses same pattern as the SDK, with the version number now contained in a file. We need to do it this way, since tags are branches, and only master is authorized to run in CD.
1 parent ca84d3c commit dd53a1e

File tree

8 files changed

+76
-30
lines changed

8 files changed

+76
-30
lines changed

.github/workflows/publish.yml

Lines changed: 70 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
on:
2+
pull_request:
3+
branches: [ master ]
24
push:
3-
tags:
4-
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
5+
branches: [ master ]
56

67
name: Publish Release
78
jobs:
89
build:
9-
name: Create Release
10+
name: Build Release Package
1011
runs-on: ubuntu-latest
1112
timeout-minutes: 10
13+
outputs:
14+
should-release: ${{ steps.confirm-release.outputs.test }}
15+
branch: ${{ steps.get-branch.outputs.branch }}
16+
version: ${{ steps.get-version.outputs.version }}
1217
steps:
1318
- name: Checkout code
1419
uses: actions/checkout@v4
@@ -18,48 +23,83 @@ jobs:
1823
with:
1924
dotnet-version: 6.0.200
2025

26+
- name: Get version
27+
id: get-version
28+
run: echo "version=$(cat version)" >> $GITHUB_OUTPUT
29+
30+
- name: Get branch
31+
id: get-branch
32+
run: echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT
33+
34+
- name: Confirm release
35+
id: confirm-release
36+
run: echo "test=$(git tag --list 'v${{ steps.get-version.outputs.version }}' | wc -l | sed s/\ //g)" >> $GITHUB_OUTPUT
37+
2138
- name: Setup tools
2239
run: dotnet tool restore
2340

2441
- name: Dotnet restore
2542
run: dotnet restore
26-
# Download the code signing certificate from github actions
27-
- name: Download code signing certificate
28-
run: echo -n "${{ secrets.CODE_SIGNING_CERTIFICATE }}" | base64 -w 0 --decode > ./cognite_code_signing.pfx
29-
# Pull out the public key. sn only supports extracting the public key, not the private key as well...
30-
- name: Extract public key
31-
run: echo -n "${{ secrets.CODE_SIGNING_CERTIFICATE_PASSWORD }}" | sn -p cognite_code_signing.pfx pub_key.snk
32-
# Build with public key. This leaves "space" for a private key signature later.
33-
- name: Build for test publish
34-
run: dotnet build --configuration Release --no-restore -p:SignAssembly=True -p:AssemblyOriginatorKeyFile="$(realpath pub_key.snk)" -p:DelaySign=True -p:PackageVersion=${GITHUB_REF##*/v} -p:FileVersion=${GITHUB_REF##*/v} -p:InformationalVersion=${GITHUB_REF##*/v}
35-
# Sign each library with the private key.
36-
- name: Sign Oryx
37-
run: echo "${{ secrets.CODE_SIGNING_CERTIFICATE_PASSWORD }}" | sn -R src/bin/Release/netstandard2.0/Oryx.dll ./cognite_code_signing.pfx
38-
- name: Sign Oryx.Protobuf
39-
run: echo "${{ secrets.CODE_SIGNING_CERTIFICATE_PASSWORD }}" | sn -R extensions/Oryx.Protobuf/bin/Release/netstandard2.0/Oryx.Protobuf.dll ./cognite_code_signing.pfx
40-
- name: Sign Oryx.SystemTextJson
41-
run: echo "${{ secrets.CODE_SIGNING_CERTIFICATE_PASSWORD }}" | sn -R extensions/Oryx.SystemTextJson/bin/Release/netstandard2.0/Oryx.SystemTextJson.dll ./cognite_code_signing.pfx
42-
- name: Sign Oryx.NewtonsoftJson
43-
run: echo "${{ secrets.CODE_SIGNING_CERTIFICATE_PASSWORD }}" | sn -R extensions/Oryx.NewtonsoftJson/bin/Release/netstandard2.0/Oryx.NewtonsoftJson.dll ./cognite_code_signing.pfx
44-
- name: Sign Oryx.ThothJsonNet
45-
run: echo "${{ secrets.CODE_SIGNING_CERTIFICATE_PASSWORD }}" | sn -R extensions/Oryx.ThothJsonNet/bin/Release/netstandard2.0/Oryx.ThothJsonNet.dll ./cognite_code_signing.pfx
43+
44+
- name: Build for publish
45+
run: dotnet build --configuration Release --no-restore -p:PackageVersion=${{ steps.get-version.outputs.version }} -p:FileVersion=${{ steps.get-version.outputs.version }} -p:InformationalVersion=${{ steps.get-version.outputs.version }}
46+
4647
# Package without rebuilding the binaries. TargetsForTfmSpecificContentInPackage is a workaround for a bug related to --no-build with fsharp projects.
4748
# See https://github.com/dotnet/fsharp/issues/12320
4849
- name: Dotnet Pack
49-
run: dotnet pack -c release -p:PackageVersion=${GITHUB_REF##*/v} -p:FileVersion=${GITHUB_REF##*/v} -p:InformationalVersion=${GITHUB_REF##*/v} --no-build --output nuget-packages -p:TargetsForTfmSpecificContentInPackage=
50-
# Sign the nuget package itself
50+
run: dotnet pack -c release -p:PackageVersion=${{ steps.get-version.outputs.version }} -p:FileVersion=${{ steps.get-version.outputs.version }} -p:InformationalVersion=${{ steps.get-version.outputs.version }} --no-build --output nuget-packages -p:TargetsForTfmSpecificContentInPackage=
51+
52+
- name: Package will be released
53+
if: ${{ steps.confirm-release.outputs.test == 0 }}
54+
run: echo "Will release nuget package"
55+
56+
- name: Upload nuget packages
57+
uses: actions/upload-artifact@v3
58+
if: ${{ steps.get-branch.outputs.branch == 'master' && steps.confirm-release.outputs.test == 0 }}
59+
with:
60+
name: nuget-packages
61+
path: nuget-packages/
62+
retention-days: 1
63+
64+
publish:
65+
name: Create Release
66+
runs-on: windows-latest
67+
environment: CD
68+
if: ${{ needs.build.outputs.branch == 'master' && needs.build.outputs.should-release == 0 }}
69+
needs:
70+
- build
71+
steps:
72+
- name: Setup .NET Core
73+
uses: actions/setup-dotnet@v3
74+
with:
75+
dotnet-version: 6.0.200
76+
- name: Download nuget packages
77+
uses: actions/download-artifact@v3
78+
with:
79+
name: nuget-packages
80+
path: nuget-packages/
81+
5182
- name: Sign nuget packages
52-
run: dotnet nuget sign nuget-packages/*.nupkg --certificate-path ./cognite_code_signing.pfx --certificate-password ${{ secrets.CODE_SIGNING_CERTIFICATE_PASSWORD }} --timestamper http://timestamp.digicert.com
83+
env:
84+
CERTIFICATE_HOST: ${{ secrets.CODE_SIGNING_CERT_HOST }}
85+
CERTIFICATE_HOST_API_KEY: ${{ secrets.CODE_SIGNING_CERT_HOST_API_KEY }}
86+
CERTIFICATE_SHA1_HASH: ${{ secrets.CODE_SIGNING_CERT_SHA1_HASH }}
87+
CLIENT_CERTIFICATE: ${{ secrets.CODE_SIGNING_CLIENT_CERT }}
88+
CLIENT_CERTIFICATE_PASSWORD: ${{ secrets.CODE_SIGNING_CLIENT_CERT_PASSWORD }}
89+
uses: cognitedata/code-sign-action/@v2
90+
with:
91+
path-to-binary: 'nuget-packages/'
5392

54-
- name: Push Oryx
55-
run: dotnet nuget push nuget-packages/*.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
93+
- name: Push nuget packages
94+
run: dotnet nuget push .\nuget-packages\*.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
5695
continue-on-error: false
5796

5897
- name: Create Release
5998
uses: actions/create-release@master
6099
env:
61100
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62101
with:
63-
tag_name: ${{ github.ref }}
64-
release_name: Release ${{ github.ref }}
102+
tag_name: v${{ needs.build.outputs.version }}
103+
release_name: Release v${{ needs.build.outputs.version }}
65104
draft: false
105+
prerelease: false

extensions/Oryx.NewtonsoftJson/Oryx.NewtonsoftJson.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<Company>Cognite AS</Company>
99
<Copyright>Cognite AS</Copyright>
1010
<PackageLicenseFile>LICENSE</PackageLicenseFile>
11+
<AssemblyOriginatorKeyFile>$(SolutionDir)/strong_name.snk</AssemblyOriginatorKeyFile>
1112
</PropertyGroup>
1213

1314
<ItemGroup>

extensions/Oryx.Protobuf/Oryx.Protobuf.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<Company>Cognite AS</Company>
99
<Copyright>Cognite AS</Copyright>
1010
<PackageLicenseFile>LICENSE</PackageLicenseFile>
11+
<AssemblyOriginatorKeyFile>$(SolutionDir)/strong_name.snk</AssemblyOriginatorKeyFile>
1112
</PropertyGroup>
1213

1314
<ItemGroup>

extensions/Oryx.SystemTextJson/Oryx.SystemTextJson.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<Company>Cognite AS</Company>
1010
<Copyright>Cognite AS</Copyright>
1111
<PackageLicenseFile>LICENSE</PackageLicenseFile>
12+
<AssemblyOriginatorKeyFile>$(SolutionDir)/strong_name.snk</AssemblyOriginatorKeyFile>
1213
</PropertyGroup>
1314
<ItemGroup>
1415
<Compile Include="JsonPushStreamContent.fs" />

extensions/Oryx.ThothJsonNet/Oryx.ThothJsonNet.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<Company>Cognite AS</Company>
99
<Copyright>Cognite AS</Copyright>
1010
<PackageLicenseFile>LICENSE</PackageLicenseFile>
11+
<AssemblyOriginatorKeyFile>$(SolutionDir)/strong_name.snk</AssemblyOriginatorKeyFile>
1112
</PropertyGroup>
1213

1314
<ItemGroup>

src/Oryx.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<Company>Cognite AS</Company>
99
<Copyright>Cognite AS</Copyright>
1010
<PackageLicenseFile>LICENSE</PackageLicenseFile>
11+
<AssemblyOriginatorKeyFile>$(SolutionDir)/strong_name.snk</AssemblyOriginatorKeyFile>
1112
</PropertyGroup>
1213

1314
<ItemGroup>

strong_name.snk

596 Bytes
Binary file not shown.

version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5.4.1

0 commit comments

Comments
 (0)