Skip to content

Test build

Test build #39

Workflow file for this run

name: Build and Publish
on:
push:
pull_request:
branches:
- master
defaults:
run:
working-directory: src/Haukcode.sACN
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get main version
id: version
uses: notiz-dev/github-action-json-property@release
with:
path: version.json
prop_path: 'version'
- name: Get branch name from branch
run: echo "BRANCH_NAME=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }' | sed "s/[[:space:]_]/-/g")" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/heads/')
- name: Get branch name from PR
run: echo "BRANCH_NAME=PR-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/pull/')
- run: echo Version ${BRANCH_NAME}
- run: echo "PACKAGE_VERSION=${{steps.version.outputs.prop}}.${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
if: github.ref == 'refs/heads/master'
- run: echo "PACKAGE_VERSION=${{steps.version.outputs.prop}}.${GITHUB_RUN_NUMBER}-${BRANCH_NAME}-${GITHUB_SHA::8}" >> $GITHUB_ENV
if: github.ref != 'refs/heads/master'
- run: echo Version is ${PACKAGE_VERSION}
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 9.0.100
- name: Install dependencies
run: dotnet restore /p:Configuration=Release
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
- name: Build
run: dotnet build --configuration Release --no-restore /p:Version="${PACKAGE_VERSION}"
- name: Test
run: dotnet test --no-restore --verbosity normal
## Publish and Tag
- name: Publish NuGet
run: dotnet nuget push bin/Release/*.nupkg --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }}
- name: Tag
run: |
git tag "v${PACKAGE_VERSION}"
git push origin "v${PACKAGE_VERSION}"
if: github.ref == 'refs/heads/master'