Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FSSDK-9486] Cherry-pick Last-Modified patch to a release #357

Merged
merged 6 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 39 additions & 73 deletions .github/workflows/csharp.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
---
name: Csharp CI with .NET
name: Continuous Integration

on:
push:
branches: [3.11.2]
branches: [ release-3.11.3 ]
pull_request:
branches: [3.11.2]

env:
RELEASE_BRANCH: "3.11.2"
WINDOWS_2019_SN_PATH: C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\sn.exe
branches: [ release-3.11.3 ]

jobs:
lint_code_base:
lintCodebase:
runs-on: ubuntu-latest
name: Lint Codebase
steps:
Expand All @@ -21,32 +16,17 @@ jobs:
with:
# Full git history is needed to get a proper list of changed files
fetch-depth: 0
- name: Lint codebase
- name: Run Super-Linter
uses: github/super-linter@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: master
VALIDATE_CSHARP: true

integration_tests:
name: Run Integration Tests
uses: optimizely/csharp-sdk/.github/workflows/integration_test.yml@master
secrets:
CI_USER_TOKEN: ${{ secrets.CI_USER_TOKEN }}
TRAVIS_COM_TOKEN: ${{ secrets.TRAVIS_COM_TOKEN }}

fullstack_production_suite:
name: Run Optimizely Feature Experimentation Compatibility Suite
uses: optimizely/csharp-sdk/.github/workflows/integration_test.yml@master
with:
FULLSTACK_TEST_REPO: ProdTesting
secrets:
CI_USER_TOKEN: ${{ secrets.CI_USER_TOKEN }}
TRAVIS_COM_TOKEN: ${{ secrets.TRAVIS_COM_TOKEN }}

unit_test:
name: Build and Run Unit Tests
netFrameworksAndUnitTest:
name: Build Framework & Run Unit Tests
needs: [ lintCodebase ]
runs-on: windows-2019 # required version for Framework 4.0
env:
REPO_SLUG: ${{ github.repository }}
Expand All @@ -63,33 +43,18 @@ jobs:
- name: Setup NuGet
uses: NuGet/setup-nuget@v1
- name: Restore NuGet packages
run: nuget restore ./OptimizelySDK.Travis.sln
- name: Build solution
run: msbuild /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=$(pwd)/keypair.snk /p:Configuration=Release ./OptimizelySDK.Travis.sln
- name: Install NUnit Console
run: nuget install NUnit.Console -Version 3.15.2 -DirectDownload -OutputDirectory .
- name: Run NUnit tests
# https://docs.nunit.org/articles/nunit/running-tests/Console-Command-Line.html
run: ./NUnit.ConsoleRunner.3.15.2\tools\nunit3-console.exe /timeout 10000 /process Separate ./OptimizelySDK.Tests/bin/Release/OptimizelySDK.Tests.dll
- name: Find and sign all DLLs
id: unit_tests
run: |
Get-ChildItem -Recurse -Exclude '.*Tests.*' -Include 'OptimizelySDK*.dll' |
Where-Object { $_.DirectoryName -match '\\bin\\Release' } |
Foreach-Object { & $env:WINDOWS_2019_SN_PATH -R $_.FullName ./keypair.snk }
- name: Install AWS CLI, deploy to S3 on successful tests & for release
if: steps.unit_tests.outcome == 'success' && env.CURRENT_BRANCH == env.RELEASE_BRANCH && env.EVENT_TYPE == 'push'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.OFTA_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.OFTA_SECRET }}
AWS_DEFAULT_REGION: ${{ secrets.OFTA_REGION }}
run: nuget restore ./OptimizelySDK.NETFramework.sln
- name: Build & strongly name assemblies
run: msbuild /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=$(pwd)/keypair.snk /p:Configuration=Release ./OptimizelySDK.NETFramework.sln
- name: Install & Run NUnit tests
run: |
Install-Module -Name AWS.Tools.Installer -Force;
Install-AWSToolsModule AWS.Tools.S3 -Force -CleanUp;
Get-ChildItem -Recurse -Exclude '.*Tests.*' -include 'OptimizelySDK*.dll' | Where-Object { $_.DirectoryName -match '\\bin\\Release' } | Foreach-Object { aws s3 cp $_.FullName s3://optly-fs-travisci-artifacts/${{ env.REPO_SLUG }}/${{ env.BUILD_NUMBER }}/${{ env.RUN_NUMBER }}/${{ env.ATTEMPT_NUM }}/$($_.Name)-unsigned }
nuget install NUnit.Console -Version 3.15.2 -DirectDownload -OutputDirectory .
# https://docs.nunit.org/articles/nunit/running-tests/Console-Command-Line.html
./NUnit.ConsoleRunner.3.15.2\tools\nunit3-console.exe /timeout 10000 /process Separate ./OptimizelySDK.Tests/bin/Release/OptimizelySDK.Tests.dll

netStandard16:
name: Build For .NET Standard 1.6
name: Build Standard 1.6
needs: [ netFrameworksAndUnitTest ]
runs-on: windows-2022
env:
REPO_SLUG: ${{ github.repository }}
Expand All @@ -107,20 +72,12 @@ jobs:
dotnet-version: 3.1.x
- name: Restore dependencies
run: dotnet restore OptimizelySDK.NetStandard16/OptimizelySDK.NetStandard16.csproj
- name: Build and sign Standard 1.6 project
id: netStandard16_build
- name: Build & strongly name assemblies
run: dotnet build OptimizelySDK.NetStandard16/OptimizelySDK.NetStandard16.csproj /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=D:\a\csharp-sdk\csharp-sdk\keypair.snk -c Release
- name: Check on success
if: steps.netStandard16_build.outcome == 'success' && env.CURRENT_BRANCH == env.RELEASE_BRANCH && env.EVENT_TYPE == 'push'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.OFTA_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.OFTA_SECRET }}
AWS_DEFAULT_REGION: ${{ secrets.OFTA_REGION }}
run: |
(aws s3 cp ./OptimizelySDK.NetStandard16/bin/Release/netstandard1.6/OptimizelySDK.NetStandard16.dll s3://optly-fs-travisci-artifacts/${{ env.REPO_SLUG }}/${{ env.BUILD_NUMBER }}/${{ env.RUN_NUMBER }}/${{ env.ATTEMPT_NUM }}/OptimizelySDK.NetStandard16.dll-unsigned)

netStandard20:
name: Build For .NET Standard 2.0
name: Build Standard 2.0
needs: [ netFrameworksAndUnitTest ]
runs-on: windows-2022
env:
REPO_SLUG: ${{ github.repository }}
Expand All @@ -138,14 +95,23 @@ jobs:
dotnet-version: 3.1.x
- name: Restore dependencies
run: dotnet restore OptimizelySDK.NetStandard20/OptimizelySDK.NetStandard20.csproj
- name: Build and sign Standard 2.0 project
id: netStandard20_build
- name: Build & strongly name assemblies
run: dotnet build OptimizelySDK.NetStandard20/OptimizelySDK.NetStandard20.csproj /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=D:\a\csharp-sdk\csharp-sdk\keypair.snk -c Release
- name: Check on success
if: steps.netStandard20_build.outcome == 'success' && env.CURRENT_BRANCH == env.RELEASE_BRANCH && env.EVENT_TYPE == 'push'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.OFTA_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.OFTA_SECRET }}
AWS_DEFAULT_REGION: ${{ secrets.OFTA_REGION }}
run: |
(aws s3 cp ./OptimizelySDK.NetStandard20/bin/Release/netstandard2.0/OptimizelySDK.NetStandard20.dll s3://optly-fs-travisci-artifacts/${{ env.REPO_SLUG }}/${{ env.BUILD_NUMBER }}/${{ env.RUN_NUMBER }}/${{ env.ATTEMPT_NUM }}/OptimizelySDK.NetStandard20.dll-unsigned)

integration_tests:
name: Run Integration Tests
needs: [ netFrameworksAndUnitTest, netStandard16, netStandard20 ]
uses: optimizely/csharp-sdk/.github/workflows/integration_test.yml@master
secrets:
CI_USER_TOKEN: ${{ secrets.CI_USER_TOKEN }}
TRAVIS_COM_TOKEN: ${{ secrets.TRAVIS_COM_TOKEN }}

fullstack_production_suite:
name: Run Performance Tests
needs: [ netFrameworksAndUnitTest, netStandard16, netStandard20 ]
uses: optimizely/csharp-sdk/.github/workflows/integration_test.yml@master
with:
FULLSTACK_TEST_REPO: ProdTesting
secrets:
CI_USER_TOKEN: ${{ secrets.CI_USER_TOKEN }}
TRAVIS_COM_TOKEN: ${{ secrets.TRAVIS_COM_TOKEN }}
202 changes: 202 additions & 0 deletions .github/workflows/csharp_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
name: Publish Release To NuGet

on:
release:
types: [ published ] # Trigger on published pre-releases and releases

jobs:
variables:
name: Set Variables
runs-on: ubuntu-latest
env:
# ⚠️ IMPORTANT: tag should always start with integer & will be used verbatim to string end
TAG: ${{ github.event.release.tag_name }}
steps:
- name: Set semantic version variable
id: set_version
run: |
TAG=${{ env.TAG }}
SEMANTIC_VERSION=$(echo "${TAG}" | grep -Po "(?<=^|[^0-9])([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?(-[a-zA-Z]+[0-9]*)?)")
if [ -z "${SEMANTIC_VERSION}" ]; then
echo "Tag did not start with a semantic version number (e.g., #.#.#; #.#.#.#; #.#.#.#-beta)"
exit 1
fi
echo "semantic_version=${SEMANTIC_VERSION}" >> $GITHUB_OUTPUT
- name: Output tag & semantic version
id: outputs
run: |
echo ${{ env.TAG }}
echo ${{ steps.set_version.outputs.semantic_version }}
outputs:
tag: ${{ env.TAG }}
semanticVersion: ${{ steps.set_version.outputs.semantic_version }}

buildFrameworkVersions:
name: Build Framework versions
needs: [ variables ]
runs-on: windows-2019 # required version for Framework 4.0
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ needs.variables.outputs.tag }}
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1
- name: Setup NuGet
uses: NuGet/setup-nuget@v1
- name: Restore NuGet packages
run: nuget restore ./OptimizelySDK.NETFramework.sln
- name: Build and strongly name assemblies
run: msbuild /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=$(pwd)/keypair.snk /p:Configuration=Release ./OptimizelySDK.NETFramework.sln
- name: Upload Framework artifacts
uses: actions/upload-artifact@v2
with:
name: nuget-files
if-no-files-found: error
path: ./**/bin/Release/**/Optimizely*.dll

buildStandard16:
name: Build Standard 1.6 version
needs: [ variables ]
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ needs.variables.outputs.tag }}
- name: Setup .NET
uses: actions/setup-dotnet@v2
- name: Restore dependencies
run: dotnet restore OptimizelySDK.NetStandard16/OptimizelySDK.NetStandard16.csproj
- name: Build and strongly name assemblies
run: dotnet build OptimizelySDK.NetStandard16/OptimizelySDK.NetStandard16.csproj /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=$(pwd)/keypair.snk -c Release
- name: Upload Standard 1.6 artifact
uses: actions/upload-artifact@v2
with:
name: nuget-files
if-no-files-found: error
path: ./**/bin/Release/**/Optimizely*.dll

buildStandard20:
name: Build Standard 2.0 version
needs: [ variables ]
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ needs.variables.outputs.tag }}
- name: Setup .NET
uses: actions/setup-dotnet@v2
- name: Restore dependencies
run: dotnet restore OptimizelySDK.NetStandard20/OptimizelySDK.NetStandard20.csproj
- name: Build and strongly name Standard 2.0 project
run: dotnet build OptimizelySDK.NetStandard20/OptimizelySDK.NetStandard20.csproj /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=$(pwd)/keypair.snk -c Release
- name: Build and strongly name assemblies
uses: actions/upload-artifact@v2
with:
name: nuget-files
if-no-files-found: error
path: ./**/bin/Release/**/Optimizely*.dll

pack:
name: Sign & pack NuGet package
needs: [ variables, buildFrameworkVersions, buildStandard16, buildStandard20 ]
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.variables.outputs.semanticVersion }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ needs.variables.outputs.tag }}
- name: Install mono
run: |
sudo apt update
sudo apt install -y mono-devel
- name: Download NuGet files
uses: actions/download-artifact@v2
with:
name: nuget-files
path: ./nuget-files
- name: Organize files
run: |
pushd ./nuget-files
# Move all dlls to the root directory
find . -type f -name "*.dll" -exec mv {} . \;
popd
# Create directories
mkdir -p nuget/lib/net35/ nuget/lib/net40/ nuget/lib/net45/ nuget/lib/netstandard1.6/ nuget/lib/netstandard2.0/
pushd ./nuget
# Move files to directories
mv ../nuget-files/OptimizelySDK.Net35.dll lib/net35/
mv ../nuget-files/OptimizelySDK.Net40.dll lib/net40/
mv ../nuget-files/OptimizelySDK.dll lib/net45/
mv ../nuget-files/OptimizelySDK.NetStandard16.dll lib/netstandard1.6/
mv ../nuget-files/OptimizelySDK.NetStandard20.dll lib/netstandard2.0/
popd
- name: Setup signing prerequisites
env:
CERTIFICATE_P12: ${{ secrets.CERTIFICATE_P12 }}
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
run: |
pushd ./nuget
echo $CERTIFICATE_P12 | base64 --decode > authenticode.pfx
openssl pkcs12 -in authenticode.pfx -nocerts -nodes -legacy -out key.pem -password env:CERTIFICATE_PASSWORD
openssl rsa -in key.pem -outform PVK -pvk-none -out authenticode.pvk
openssl pkcs12 -in authenticode.pfx -nokeys -nodes -legacy -out cert.pem -password env:CERTIFICATE_PASSWORD
openssl crl2pkcs7 -nocrl -certfile cert.pem -outform DER -out authenticode.spc
popd
- name: Sign the DLLs
run: |
pushd ./nuget
find . -type f -name "*.dll" -print0 | while IFS= read -r -d '' file; do
echo "Signing ${file}"
signcode \
-spc ./authenticode.spc \
-v ./authenticode.pvk \
-a sha1 -$ commercial \
-n "Optimizely, Inc" \
-i "https://www.optimizely.com/" \
-t "http://timestamp.digicert.com" \
-tr 10 \
${file}
rm ${file}.bak
done
rm *.spc *.pem *.pvk *.pfx
popd
- name: Create nuspec
# Uses env.VERSION in OptimizelySDK.nuspec.template
run: |
chmod +x ./OptimizelySDK.nuspec.template
./OptimizelySDK.nuspec.template
- name: Pack NuGet package
run: |
pushd ./nuget
nuget pack OptimizelySDK.nuspec
popd
- name: Upload nupkg artifact
uses: actions/upload-artifact@v2
with:
name: nuget-package
if-no-files-found: error
path: ./nuget/Optimizely.SDK.${{ env.VERSION }}.nupkg

publish:
name: Publish package to NuGet
needs: [ variables, pack ]
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.variables.outputs.semanticVersion }}
steps:
- name: Download NuGet files
uses: actions/download-artifact@v2
with:
name: nuget-package
path: ./nuget
- name: Setup .NET
uses: actions/setup-dotnet@v3
- name: Publish NuGet package
# Unset secrets.NUGET_API_KEY to simulate dry run
run: |
dotnet nuget push ./nuget/Optimizely.SDK.${{ env.VERSION }}.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
File renamed without changes.
Loading
Loading