Skip to content

dev

dev #8

Workflow file for this run

name: Publish
on:
push:
branches:
- "v*.*.*"
- "v*.*.*-*"
permissions:
contents: read
packages: write
defaults:
run:
shell: bash
jobs:
nuget:
name: NuGet
environment: nuget
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x.x
- name: Write strong name key file
run: |
set +x # Disable command echoing for security
# Base64 decode the strong name key and save to keys directory
echo "$STRONG_NAME_KEY" | base64 -d > keys/NatsDistributedCache.2025-05-12.snk
chmod 600 keys/NatsDistributedCache.2025-05-12.snk
# Verify strong-naming against public key
if ! sn -v keys/NatsDistributedCache.2025-05-12.snk keys/NatsDistributedCache.2025-05-12.pub; then
echo "Strong-naming verification failed!"
exit 1
fi
env:
STRONG_NAME_KEY: ${{secrets.STRONG_NAME_KEY}}
- name: Pack
run: dotnet pack -c Release -p:version=${GITHUB_REF#refs/*/v} -o ./publish
- name: Verify strong name
run: |
# Extract the NuGet package to access the assembly
mkdir -p ./extract
unzip -o ./publish/*.nupkg -d ./extract
# Find and verify the assembly is strong-named
ASSEMBLY=$(find ./extract/lib -name "NatsDistributedCache.dll" | head -1)
if [ -z "$ASSEMBLY" ]; then
echo "Assembly not found in the package"
exit 1
fi
# Verify strong-naming of the assembly against public key
if ! sn -vf "$ASSEMBLY"; then
echo "Assembly is not strong-named or signature is invalid!"
exit 1
fi
echo "Assembly is properly strong-named"
- name: Publish to NuGet.org
run: dotnet nuget push ./publish/*.nupkg --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json --skip-duplicate
env:
NUGET_API_KEY: ${{secrets.NUGET_API_KEY}}