Skip to content

readme fix (#26)

readme fix (#26) #14

name: Build, test and publish
on:
push:
branches:
- main # or your default branch name
jobs:
build-test-publish:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Write SNK file
shell: pwsh
run: |
$env:SNK_BASE64 -split ' ' -join "`n" | Out-File -Encoding utf8 ./SharpToken/keypair.snk.base64.txt
certutil -decode ./SharpToken/keypair.snk.base64.txt ./SharpToken/keypair.snk
env:
SNK_BASE64: ${{ secrets.SNK_BASE64 }}
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
6.0.407
8.0.x
- name: Calculate Package Version
id: calculate_version
run: |
$version = "1.2.$env:GITHUB_RUN_NUMBER"
echo "Calculated package version: $version"
echo "::set-output name=version::$version"
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore /p:EnableSigning=true
- name: Test
run: dotnet test --no-restore --verbosity normal
- name: Publish NuGet Package
run: dotnet pack --configuration Release --no-build --output ./output /p:Version=${{ steps.calculate_version.outputs.version }}
- name: Push NuGet Package
run: |
$packagePath = "./output/SharpToken.${{ steps.calculate_version.outputs.version }}.nupkg"
dotnet nuget push $packagePath --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
with:
tag_name: ${{ steps.calculate_version.outputs.version }}
release_name: Release ${{ steps.calculate_version.outputs.version }}
body: Release of version ${{ steps.calculate_version.outputs.version }}
draft: false
prerelease: false
- name: Upload NuGet Package as Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "./output/SharpToken.${{ steps.calculate_version.outputs.version }}.nupkg"
asset_name: SharpToken.${{ steps.calculate_version.outputs.version }}.nupkg
asset_content_type: application/zip