Files
qbtmud/.github/workflows/dotnet.yml
2025-02-07 09:53:01 +00:00

90 lines
2.5 KiB
YAML

name: Build, Test, and Release Blazor WebAssembly App
on:
push:
branches:
- master
pull_request:
branches:
- '**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0 # Fetch the full history for GitVersion
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v3.0.0
with:
versionSpec: '6.0.0'
- name: Determine Version
id: gitversion
run: |
VERSION=$(dotnet gitversion /output json /showvariable FullSemVer)
echo "VERSION=$VERSION" >> $GITHUB_ENV
shell: bash
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Run Tests
run: dotnet test --no-build --configuration Release
- name: Publish (only on master)
if: github.ref == 'refs/heads/master'
run: dotnet publish Lantean.QBTMud/Lantean.QBTMud.csproj -c Release -o output
- name: Prepare Release ZIP
if: github.ref == 'refs/heads/master'
run: |
cd output
mv wwwroot public
zip -r "../qbt-mud-v${{ env.VERSION }}.zip" public
shell: bash
- name: Check if Tag Exists
id: check_tag
run: |
if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then
echo "TAG_EXISTS=true" >> $GITHUB_ENV
else
echo "TAG_EXISTS=false" >> $GITHUB_ENV
fi
- name: Create GitHub Release
if: github.ref == 'refs/heads/master' && env.TAG_EXISTS == 'false'
id: create_release
uses: actions/create-release@v1
with:
tag_name: v${{ env.VERSION }}
release_name: Release v${{ env.VERSION }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Release Asset
if: github.ref == 'refs/heads/master' && env.TAG_EXISTS == 'false'
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: qbt-mud-v${{ env.VERSION }}.zip
asset_name: qbt-mud-v${{ env.VERSION }}.zip
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}