Merge pull request #193 from fintermobilityas/dependabot/github_actio… #557
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: mongomigrations.core | |
on: push | |
env: | |
GITVERSION_VERSION: 5.12.0 | |
DOTNET_SDK_VERSION: 9.0.100-rc.2.24474.11 | |
DOTNET_CLI_TELEMETRY_OPTOUT: 1 | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
jobs: | |
setup: | |
name: Setup | |
runs-on: ubuntu-latest | |
outputs: | |
BUILD_VERSION: ${{ steps.set-version.outputs.BUILD_VERSION }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Add dotnet tools to environment path | |
shell: pwsh | |
run: echo "${HOME}/.dotnet/tools" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
- id: set-version | |
name: Setup GitVersion and set build version | |
shell: pwsh | |
run: | | |
dotnet tool update GitVersion.Tool --global --version ${{ env.GITVERSION_VERSION }} | |
$BUILD_VERSION = (dotnet gitversion /showVariable NugetVersionv2) | out-string | |
echo "BUILD_VERSION=$BUILD_VERSION" >> $env:GITHUB_OUTPUT | |
build: | |
name: Build | |
runs-on: ${{ matrix.os }} | |
needs: [setup] | |
env: | |
BUILD_VERSION: ${{ needs.setup.outputs.BUILD_VERSION }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
mongodb-version: ['8.0.1'] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- if: matrix.os == 'ubuntu-latest' | |
name: Setup mongodb v${{ matrix.mongodb-version }} | |
uses: supercharge/[email protected] | |
with: | |
mongodb-version: ${{ matrix.mongodb-version }} | |
- name: Setup dotnet ${{ env.DOTNET_SDK_VERSION }} | |
uses: actions/[email protected] | |
with: | |
dotnet-version: '${{ env.DOTNET_SDK_VERSION }}' | |
- name: Build & Run Tests | |
shell: pwsh | |
run: | | |
pwsh -command ".\${{ env.GITHUB_WORKSPACE }}\build.ps1" -Version ${{ env.BUILD_VERSION }} -RunTests | |
publish: | |
if: success() && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master') | |
runs-on: ubuntu-latest | |
name: Publish nuget package | |
needs: [setup, build] | |
env: | |
BUILD_VERSION: ${{ needs.setup.outputs.BUILD_VERSION }} | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup dotnet ${{ env.DOTNET_SDK_VERSION }} | |
uses: actions/[email protected] | |
with: | |
dotnet-version: '${{ env.DOTNET_SDK_VERSION }}' | |
- name: Nupkg | |
shell: pwsh | |
run: | | |
pwsh -command ".\${{ env.GITHUB_WORKSPACE }}\build.ps1" -Version ${{ env.BUILD_VERSION }} -Nupkg | |
- name: Push nuget packages | |
shell: pwsh | |
run: | | |
$nupkgs = Get-ChildItem ".\${{ env.GITHUB_WORKSPACE }}\nupkgs" -Filter *.nupkg | Select-Object -ExpandProperty FullName | |
$nupkgs | ForEach-Object { | |
dotnet nuget push $_ --source nuget.org --api-key ${{ secrets.NUGET_THIS_REPO_API_KEY }} | |
if($LASTEXITCODE -ne 0) { | |
Write-Error "Error uploading nupkg: $_. Exit code: $LASTEXITCODE" | |
} | |
} | |
- name: Create github release tag | |
if: success() && github.ref == 'refs/heads/master' | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ env.BUILD_VERSION }} | |
release_name: Release v${{ env.BUILD_VERSION }} | |
draft: true | |
prerelease: false |