name: Build run-name: Build ${{ github.event.repository.name }} for ${{ github.actor }} on: [ push, pull_request ] env: HUSKY: 0 TERM: xterm DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true DOTNET_CONSOLE_ANSI_COLOR: true DOTNET_CLI_TELEMETRY_OPTOUT: true jobs: Build: runs-on: [ ubuntu-latest ] steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: 9.0.x cache: true cache-dependency-path: Directory.Packages.props - name: Restore run: dotnet restore PkmnLib.NET.slnx --nologo --verbosity quiet - name: Determine version run: | if [[ "$GITHUB_REF" == refs/tags/v* ]]; then VERSION="${GITHUB_REF_NAME#v}" else VERSION="0.1.0-ci.${GITHUB_RUN_NUMBER}" fi echo "VERSION=$VERSION" >> "$GITHUB_ENV" - name: Build run: dotnet build PkmnLib.NET.slnx -c Release --nologo --verbosity quiet -p:NoWarn=CS1591 -p:Version=$VERSION - name: Test run: dotnet test -c Release --nologo --no-restore --no-build -- --disable-logo - name: Pack if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) run: dotnet pack PkmnLib.NET.slnx -c Release --nologo --no-restore --no-build -p:Version=$VERSION -o ./packages # Needs a personal access token with write:package scope: Gitea's automatic Actions token # only ever gets read access to the package registry, so pushing with it returns 401. - name: Publish to Gitea NuGet feed if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) run: > dotnet nuget push "./packages/*.nupkg" --source "${{ github.server_url }}/api/packages/${{ github.repository_owner }}/nuget/index.json" --api-key "${{ secrets.PACKAGES_TOKEN }}" --skip-duplicate