Build, Pack and Push #1
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
on: | |
workflow_dispatch: | |
push: | |
name: Build, Pack and Push | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Get current date | |
id: date | |
run: echo "::set-output name=value::$(date +'%Y.%-m.%-d')" | |
- name: Load variables | |
env: | |
CONFIGURATION: ${{(github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') && 'Release' || 'Debug' }} | |
NUGET_PASS: ${{ secrets.NUGET_ORG_TOKEN }} | |
REPOSITORY_NAME: ${{ github.event.repository.name }} | |
REPOSITORY_URI: ${{ format('{0}/{1}', github.server_url, github.repository) }} | |
run: | | |
echo "CONFIGURATION="$(echo $CONFIGURATION)"" >> $GITHUB_ENV | |
echo "NUGET_PASS="$(echo $NUGET_PASS)"" >> $GITHUB_ENV | |
echo "REPOSITORY_NAME="$(echo $REPOSITORY_NAME)"" >> $GITHUB_ENV | |
echo "REPOSITORY_URI="$(echo $REPOSITORY_URI)"" >> $GITHUB_ENV | |
- name: Load Version | |
env: | |
VERSION: ${{ format('{0}.{1}{2}', steps.date.outputs.value, github.run_number, (env.CONFIGURATION != 'Release') && '-wip' || '') }} | |
run: | | |
echo "VERSION="$(echo $VERSION)"" >> $GITHUB_ENV | |
- name: Install dotnet format | |
run: dotnet tool install -g dotnet-format | |
- name: Restore | |
run: dotnet restore | |
- name: Build | |
run: dotnet build -c $CONFIGURATION --no-restore | |
- name: Check format | |
run: dotnet format --verify-no-changes | |
- name: Pack | |
run: dotnet pack --output $RUNNER_TEMP --include-symbols --include-source --no-build -p:RepositoryUrl=$REPOSITORY_URI -p:PackageProjectUrl=$REPOSITORY_URI -p:Authors=SammyROCK -p:PackageLicenseExpression=MIT -p:RepositoryType=git -p:PackageVersion=$VERSION -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg -p:PublishRepositoryUrl=true -p:EmbedUntrackedSources=true | |
- name: Push | |
run: dotnet nuget push $RUNNER_TEMP/$REPOSITORY_NAME.$VERSION.nupkg --source https://api.nuget.org/v3/index.json --api-key $NUGET_PASS |