v3.0.1 #146
Workflow file for this run
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: .NET Core | |
on: | |
push: | |
branches: | |
- "main" | |
- "develop" | |
pull_request: | |
branches: | |
- "*" | |
release: | |
types: | |
- published | |
env: | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
DOTNET_NOLOGO: true | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
# GitHub Packages Feed settings | |
GITHUB_FEED: https://nuget.pkg.github.com/JonasMH/ | |
GITHUB_USER: JonasMH | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Official NuGet Feed settings | |
NUGET_FEED: https://api.nuget.org/v3/index.json | |
NUGET_KEY: ${{ secrets.NUGET_KEY }} | |
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: "8.0.100" | |
cache: true | |
cache-dependency-path: src/ToMqttNet/packages.lock.json | |
- name: Restore | |
run: dotnet restore --locked-mode | |
- name: Build | |
run: dotnet build -c Release --no-restore | |
- name: Test | |
run: dotnet test -c Release | |
- name: Pack | |
run: dotnet pack -o artifacts/packs -v normal -c Release --no-restore HomeAssistantDiscoveryNet.sln | |
deploy: | |
needs: build | |
if: github.event_name == 'release' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: "8.0.100" | |
cache: true | |
cache-dependency-path: src/ToMqttNet/packages.lock.json | |
- name: Create Release NuGet package | |
run: | | |
arrTag=(${GITHUB_REF//\// }) | |
VERSION="${arrTag[2]}" | |
echo Version: $VERSION | |
VERSION="${VERSION//v}" | |
echo Clean Version: $VERSION | |
dotnet pack -o artifacts/packs -v normal -c Release --no-restore -p:PackageVersion=$VERSION HomeAssistantDiscoveryNet.sln | |
- name: Push to GitHub Feed | |
run: | | |
for f in ./artifacts/packs/*.nupkg | |
do | |
curl -vX PUT -u "$GITHUB_USER:$GITHUB_TOKEN" -F package=@$f $GITHUB_FEED | |
done | |
- name: Push to NuGet Feed | |
run: dotnet nuget push ./artifacts/packs/*.nupkg --source $NUGET_FEED --skip-duplicate --api-key $NUGET_KEY |