mirror of
https://github.com/lantean-code/qbtmud.git
synced 2025-11-06 15:03:17 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e854ad8071 | ||
|
|
d373ec3f6f | ||
|
|
fca17edfd1 |
95
.github/workflows/dotnet.yml
vendored
95
.github/workflows/dotnet.yml
vendored
@@ -4,6 +4,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
workflow_dispatch:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- '**'
|
- '**'
|
||||||
@@ -32,58 +33,112 @@ jobs:
|
|||||||
id: gitversion
|
id: gitversion
|
||||||
run: |
|
run: |
|
||||||
VERSION=$(dotnet gitversion /output json /showvariable FullSemVer)
|
VERSION=$(dotnet gitversion /output json /showvariable FullSemVer)
|
||||||
|
SAFE_VERSION=$(echo "$VERSION" | sed -E 's/[^A-Za-z0-9._+-]+/-/g')
|
||||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||||
|
echo "VERSION_SAFE=$SAFE_VERSION" >> $GITHUB_ENV
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
- name: Set Release Channel
|
||||||
|
id: release_channel
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [ "${GITHUB_REF}" = "refs/heads/master" ]; then
|
||||||
|
echo "channel=stable" >> $GITHUB_OUTPUT
|
||||||
|
echo "prerelease=false" >> $GITHUB_OUTPUT
|
||||||
|
echo "label=Release" >> $GITHUB_OUTPUT
|
||||||
|
elif [ "${GITHUB_REF}" = "refs/heads/develop" ]; then
|
||||||
|
echo "channel=beta" >> $GITHUB_OUTPUT
|
||||||
|
echo "prerelease=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "label=Beta" >> $GITHUB_OUTPUT
|
||||||
|
elif [[ "${GITHUB_REF}" == refs/heads/feature/* ]]; then
|
||||||
|
echo "channel=alpha" >> $GITHUB_OUTPUT
|
||||||
|
echo "prerelease=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "label=Alpha" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "channel=none" >> $GITHUB_OUTPUT
|
||||||
|
echo "prerelease=false" >> $GITHUB_OUTPUT
|
||||||
|
echo "label=" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Restore dependencies
|
- name: Restore dependencies
|
||||||
run: dotnet restore
|
run: dotnet restore
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: dotnet build --configuration Release --no-restore
|
run: dotnet build --configuration Release --no-restore
|
||||||
|
|
||||||
- name: Run Tests
|
- name: Run Tests with Coverage
|
||||||
run: dotnet test --no-build --configuration Release
|
run: dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --results-directory TestResults
|
||||||
|
|
||||||
- name: Publish (only on master)
|
- name: Install ReportGenerator
|
||||||
if: github.ref == 'refs/heads/master'
|
run: dotnet tool install --global dotnet-reportgenerator-globaltool
|
||||||
run: dotnet publish Lantean.QBTMud/Lantean.QBTMud.csproj -c Release -o output
|
|
||||||
|
- name: Generate Coverage Report
|
||||||
|
run: reportgenerator -reports:"TestResults/**/coverage.cobertura.xml" -targetdir:"coverage-report" -reporttypes:"HtmlInline_AzurePipelines;Cobertura"
|
||||||
|
|
||||||
|
- name: Upload Coverage Artifact
|
||||||
|
if: always()
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: coverage-report
|
||||||
|
path: coverage-report
|
||||||
|
|
||||||
|
- name: Publish
|
||||||
|
if: steps.release_channel.outputs.channel != 'none'
|
||||||
|
run: dotnet publish src/Lantean.QBTMud/Lantean.QBTMud.csproj -c Release -o output
|
||||||
|
|
||||||
- name: Prepare Release ZIP
|
- name: Prepare Release ZIP
|
||||||
if: github.ref == 'refs/heads/master'
|
if: steps.release_channel.outputs.channel != 'none'
|
||||||
run: |
|
run: |
|
||||||
cd output
|
cd output
|
||||||
mv wwwroot public
|
mv wwwroot public
|
||||||
zip -r "../qbt-mud-v${{ env.VERSION }}.zip" public
|
zip -r "../qbt-mud-v${{ env.VERSION_SAFE }}.zip" public
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Check if Tag Exists
|
- name: Resolve Release Tag
|
||||||
id: check_tag
|
if: steps.release_channel.outputs.channel != 'none'
|
||||||
|
id: resolve_tag
|
||||||
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then
|
if git rev-parse "${VERSION}" >/dev/null 2>&1; then
|
||||||
echo "TAG_EXISTS=true" >> $GITHUB_ENV
|
echo "tag=${VERSION}" >> $GITHUB_OUTPUT
|
||||||
|
echo "exists=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "Using existing tag '${VERSION}'"
|
||||||
|
elif git rev-parse "v${VERSION}" >/dev/null 2>&1; then
|
||||||
|
echo "tag=v${VERSION}" >> $GITHUB_OUTPUT
|
||||||
|
echo "exists=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "Using existing tag 'v${VERSION}'"
|
||||||
else
|
else
|
||||||
echo "TAG_EXISTS=false" >> $GITHUB_ENV
|
echo "tag=${VERSION}" >> $GITHUB_OUTPUT
|
||||||
|
echo "exists=false" >> $GITHUB_OUTPUT
|
||||||
|
echo "::warning::No matching git tag found for '${VERSION}' or 'v${VERSION}'."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Ensure Release Tag Exists
|
||||||
|
if: steps.release_channel.outputs.channel == 'stable' && steps.resolve_tag.outputs.exists != 'true'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "::error::Expected an existing git tag '${VERSION}' (or 'v${VERSION}') before creating a release."
|
||||||
|
exit 1
|
||||||
|
|
||||||
- name: Create GitHub Release
|
- name: Create GitHub Release
|
||||||
if: github.ref == 'refs/heads/master' && env.TAG_EXISTS == 'false'
|
if: steps.release_channel.outputs.channel != 'none' && (steps.resolve_tag.outputs.exists == 'true' || steps.release_channel.outputs.channel != 'stable')
|
||||||
id: create_release
|
id: create_release
|
||||||
uses: actions/create-release@v1
|
uses: actions/create-release@v1
|
||||||
with:
|
with:
|
||||||
tag_name: v${{ env.VERSION }}
|
tag_name: ${{ steps.resolve_tag.outputs.tag }}
|
||||||
release_name: Release v${{ env.VERSION }}
|
release_name: ${{ steps.release_channel.outputs.label }} ${{ steps.resolve_tag.outputs.tag }}
|
||||||
draft: false
|
draft: ${{ steps.release_channel.outputs.channel != 'alpha' }}
|
||||||
prerelease: false
|
prerelease: ${{ steps.release_channel.outputs.prerelease }}
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Upload Release Asset
|
- name: Upload Release Asset
|
||||||
if: github.ref == 'refs/heads/master' && env.TAG_EXISTS == 'false'
|
if: steps.release_channel.outputs.channel != 'none' && (steps.resolve_tag.outputs.exists == 'true' || steps.release_channel.outputs.channel != 'stable')
|
||||||
uses: actions/upload-release-asset@v1
|
uses: actions/upload-release-asset@v1
|
||||||
with:
|
with:
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
asset_path: qbt-mud-v${{ env.VERSION }}.zip
|
asset_path: qbt-mud-v${{ env.VERSION_SAFE }}.zip
|
||||||
asset_name: qbt-mud-v${{ env.VERSION }}.zip
|
asset_name: qbt-mud-v${{ env.VERSION_SAFE }}.zip
|
||||||
asset_content_type: application/zip
|
asset_content_type: application/zip
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
Reference in New Issue
Block a user