Tag and publish to NuGet #11
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: Tag and publish to NuGet | |
on: | |
workflow_dispatch: | |
inputs: | |
major: | |
description: 'Major version' | |
required: true | |
default: '1' | |
minor: | |
description: 'Minor version' | |
required: true | |
default: '0' | |
patch: | |
description: 'Patch version' | |
required: true | |
default: '0' | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '8.0.x' | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build solution | |
run: dotnet build --configuration Release --no-restore | |
- name: Run tests | |
run: dotnet test --configuration Release --no-build --verbosity normal | |
- name: Get the latest tag | |
id: get_tag | |
run: echo "::set-output name=TAG::$(git describe --tags --abbrev=0)" | |
- name: Create new tag | |
id: create_tag | |
run: | | |
MAJOR=${{ github.event.inputs.major }} | |
MINOR=${{ github.event.inputs.minor }} | |
PATCH=${{ github.event.inputs.patch }} | |
NEW_TAG="${MAJOR}.${MINOR}.${PATCH}" | |
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV | |
git tag $NEW_TAG | |
git push origin $NEW_TAG | |
env: | |
GITHUB_TOKEN: ${{ secrets.ASUREBUS_PAT }} | |
- name: Pack ASureBus.Abstractions | |
run: dotnet pack ASureBus.Abstractions/ASureBus.Abstractions.csproj --configuration Release --output ./artifacts /p:PackageVersion=${{ env.NEW_TAG }} | |
- name: Pack ASureBus | |
run: dotnet pack ASureBus/ASureBus.csproj --configuration Release --output ./artifacts /p:PackageVersion=${{ env.NEW_TAG }} | |
- name: Push ASureBus.Abstractions to NuGet | |
env: | |
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
run: dotnet nuget push ./artifacts/ASureBus.Abstractions.*.nupkg --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json --skip-duplicate | |
- name: Push ASureBus to NuGet | |
env: | |
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
run: dotnet nuget push ./artifacts/ASureBus.*.nupkg --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json --skip-duplicate |