Merge pull request #94 from CapitalOnTap/haydn/package-upgrades #123
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
# This workflow will build a .NET project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
name: .NET | |
on: | |
workflow_dispatch: # Allow running the workflow manually from the GitHub UI | |
push: | |
branches: [ "master" ] # Run the workflow when pushing to the main branch | |
pull_request: | |
branches: [ "master" ] | |
release: | |
types: | |
- published # Run the workflow when a new GitHub release is published | |
env: | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
DOTNET_NOLOGO: true | |
NuGetDirectory: ${{ github.workspace }}/nuget | |
TagRelease: ${{ (github.event_name == 'push' || github.event.pull_request.merged == true) && github.ref == 'refs/heads/master' }} | |
jobs: | |
build-and-test: | |
environment: production | |
runs-on: ubuntu-latest | |
outputs: | |
calculatedVersion: ${{ steps.gitversion.outputs.majorMinorPatch }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/setup@v0 | |
with: | |
versionSpec: '5.x' | |
- name: Determine Version | |
id: gitversion | |
uses: gittools/actions/gitversion/execute@v0 | |
with: | |
useConfigFile: true | |
configFilePath: GitVersion.yml | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '6.0.x' | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --no-restore /p:Version='${{ env.GitVersion_NuGetVersion }}' | |
- name: Test | |
run: dotnet test --no-build --verbosity normal | |
env: | |
Marqeta__BaseUrl: ${{ secrets.MARQETA__BASEURL }} | |
Marqeta__UserName: ${{ secrets.MARQETA__USERNAME }} | |
Marqeta__Password: ${{ secrets.MARQETA__PASSWORD }} | |
- name: Create Tag (master only) | |
if: env.TagRelease == 'true' | |
run: git tag ${{ env.GitVersion_SemVer }} | |
- name: Push Tag (master only) | |
if: env.TagRelease == 'true' | |
run: git push origin ${{ env.GitVersion_SemVer }} | |
publish: | |
# Publish only when creating a GitHub Release | |
# https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository | |
# You can update this logic if you want to manage releases differently | |
if: github.event_name == 'release' | |
runs-on: ubuntu-latest | |
needs: [ build-and-test ] | |
environment: production | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '6.0.x' | |
- name: Pack | |
run: dotnet pack --configuration Release /p:Version='${{ needs.build-and-test.outputs.calculatedVersion }}' --include-symbols --output ${{ env.NuGetDirectory }} | |
- name: Push | |
run: dotnet nuget push "${{ env.NuGetDirectory }}/*.nupkg" --api-key "${{ secrets.NUGETAPIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate |