Skip to content

Bump actions/checkout from 3 to 4 #28

Bump actions/checkout from 3 to 4

Bump actions/checkout from 3 to 4 #28

Workflow file for this run

name: push nuget
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
- 'dependabot/**'
env:
base_version_number: "2.0.1"
build_configuration: "Release"
jobs:
build:
runs-on: windows-latest
timeout-minutes: 10
outputs:
version: ${{ steps.set-version.outputs.VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Setup msbuild
uses: microsoft/setup-msbuild@v1.0.2
- name: Set version number
id: set-version
shell: pwsh
run: |
$version = "${{ env.base_version_number }}.${{ github.run_number }}${{ github.run_attempt }}"
Write-Output "Setting version to $version"
"VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"VERSION=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Build Solution
shell: pwsh
run: dotnet build --configuration ${{ env.build_configuration }} /p:Version=${{ env.VERSION }}
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: library
path: ${{ github.workspace }}/SteamStorefrontAPI/bin/${{ env.configuration }}
- name: Execute unit tests
run: dotnet test --configuration ${{ env.build_configuration }} --no-build --verbosity normal --logger "trx;LogFileName=TestResults.trx"
- name: Publish Unit Test Results
uses: dorny/test-reporter@v1
with:
name: Unit Test Results
path: Tests/**/TestResults.trx
reporter: dotnet-trx
- name: Pack nuget
shell: pwsh
run: |
dotnet pack SteamStorefrontAPI --configuration ${{ env.build_configuration }} --no-build --output "${{ github.workspace }}/publish" /p:PackageVersion=${{ env.VERSION }}
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: nuget
path: ${{ github.workspace }}/publish
deploy:
if: ${{ github.event_name != 'pull_request' && github.ref_name == 'main' }}
environment: 'nuget'
runs-on: windows-latest
needs: build
steps:
- name: Get artifacts
uses: actions/download-artifact@v3
with:
name: nuget
path: ${{ github.workspace }}/publish
- name: Tag commit
uses: actions/github-script@v5
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ needs.build.outputs.version }}',
sha: context.sha
})
- name: Push to NuGet
shell: pwsh
run: |
Set-Location -Path '${{ github.workspace }}/publish'
dotnet nuget push "*.nupkg" --api-key ${{ secrets.nuget_api_key }} --source https://api.nuget.org/v3/index.json