Update README.md #29
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: Publish .NET nuget and create release | |
on: | |
push: | |
branches: [ "main" ] | |
jobs: | |
before_publish: | |
runs-on: ubuntu-latest | |
outputs: | |
pr-labels: ${{ steps.pr-labels.outputs.result }} | |
steps: | |
# This is getting all the labels sets on the PR | |
- name: Get PR labels | |
id: pr-labels | |
uses: shioyang/[email protected] | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
labels: '["publish"]' | |
publish: | |
runs-on: ubuntu-latest | |
if: needs.before_publish.outputs.pr-labels == 'true' | |
needs: before_publish | |
steps: | |
# Checkout sources. Depth=0 is for using GitVersion | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 6.x | |
# Install and Setup GitVersion | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/setup@v0 | |
with: | |
versionSpec: '5.x' | |
- name: Use GitVersion | |
# Step id is used as reference for the output values | |
id: gitversion | |
uses: gittools/actions/gitversion/execute@v0 | |
# Restore, build and test the project | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --configuration Release --no-restore | |
- name: Test | |
run: dotnet test --configuration Release --no-build --verbosity normal | |
# Create a nuget Release | |
- name: Pack the NuGet package | |
run: dotnet pack ./LegoDimensions --configuration Release --output ./artifacts | |
- name: Build NFC app | |
run: | | |
dotnet publish ./LegoDimensionsReadNfc -r linux-arm -c Release --output ./artifacts --self-contained true -p:PublishSingleFile=true | |
dotnet publish ./LegoDimensionsReadNfc -r win-x64 -c Release --output ./artifacts --self-contained true -p:PublishSingleFile=true | |
- name: Build Runner app | |
run: | | |
dotnet publish ./LegoDimensionsRunner -r linux-arm -c Release --output ./artifacts --self-contained true -p:PublishSingleFile=true | |
dotnet publish ./LegoDimensionsRunner -r win-x64 -c Release --output ./artifacts --self-contained true -p:PublishSingleFile=true | |
# Publish all NuGet packages to NuGet.org | |
# Use --skip-duplicate to prevent errors if a package with the same version already exists. | |
# If you retry a failed workflow, already published packages will be skipped without error. | |
- name: Publish separate tools to NuGet | |
run: dotnet nuget push ./artifacts/LegoDimensions.${{ steps.gitversion.outputs.MajorMinorPatch }}.nupkg --api-key "${{ secrets.NUGET_TOOLS }}" --source https://api.nuget.org/v3/index.json --skip-duplicate | |
# Create the CHANGELOG for this release | |
# We'll compile it from last the version | |
# to the current commit | |
- name: Build Changelog | |
id: github_release | |
uses: mikepenz/release-changelog-builder-action@v1 | |
with: | |
configuration: "./changelog-config.json" | |
fromTag: ${{ steps.gitversion.outputs.VersionSourceSha }} | |
toTag: ${{ steps.gitversion.outputs.Sha }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Create GitHub release and CHANGELOG for Chocolatey and releases | |
# NOTE: this is where we prepend "v" before the version in the tag/release | |
- name: Create release | |
uses: ncipollo/release-action@v1 | |
with: | |
# no artifacts: "" | |
body: ${{steps.github_release.outputs.changelog}} | |
tag: "v${{ steps.gitversion.outputs.MajorMinorPatch }}" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
artifacts: "**/artifacts/*.nupkg,**/artifacts/LegoDimensionsReadNfc,**/artifacts/LegoDimensionsRunner,**/artifacts/*.exe" |