diff --git a/.autorc b/.autorc new file mode 100644 index 0000000..71599c6 --- /dev/null +++ b/.autorc @@ -0,0 +1,12 @@ +{ + "plugins": [ + "git-tag", + "first-time-contributor", + "released" + ], + "owner": "Michaelvsk", + "repo": "GameDb", + "name": "Michael Keller", + "email": "13169777+Michaelvsk@users.noreply.github.com", + "onlyPublishWithReleaseLabel": true +} diff --git a/.github/workflows/build-pr.yaml b/.github/workflows/build-pr.yaml index 297a914..d27a2a7 100644 --- a/.github/workflows/build-pr.yaml +++ b/.github/workflows/build-pr.yaml @@ -11,15 +11,53 @@ jobs: runs-on: windows-latest defaults: run: - shell: powershell + shell: pwsh steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + + # Versioning + - name: Install .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.x + + - name: Versioning project's csproj file + run: | + + $cprojFiles = @( ` + "./GameDb/GameDb.csproj", + "./GameDb.Core/GameDb.Core.csproj", + "./GameDb.Models/GameDb.Models.csproj" + ) + + foreach($proj in $cprojFiles) { + $versionNo = Select-Xml -XPath "/Project/PropertyGroup/Version" -Path $proj | %{$_.node.InnerXML} + + # if fails to extract version number, then let workflow fail + Write-Host "Extracted version is: $versionNo" + if ($versionNo -eq $null) { + Write-Host "::error ::Failed to read version number from project file." + exit 1 + } + + # append build number if requested + if ($env:GITHUB_REF_NAME -ne "main") { + Write-Host "Appending build number to version" + $versionNo="$versionNo.$env:GITHUB_RUN_ID" + } + Write-Host "Using version '$versionNo' for this build artifact" + Add-Content $env:GITHUB_ENV "artifact_version=$versionNo" + } + + + # Prepare SonarCloud - name: Set up JDK 11 uses: actions/setup-java@v1 with: java-version: 1.11 - - uses: actions/checkout@v2 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Cache SonarCloud packages uses: actions/cache@v1 with: @@ -37,8 +75,10 @@ jobs: if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' run: | New-Item -Path .\.sonar\scanner -ItemType Directory - dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner + dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner + + # Build Project - name: Restore project run: | dotnet workload restore @@ -54,6 +94,7 @@ jobs: /o:"github-michaelvsk" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" + /v:="${{ env.artifact_version }}" - name: Build Project run: dotnet build -c Release diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..8da175a --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,72 @@ +name: Release +concurrency: release + +on: + workflow_dispatch: + push: + branches: [ main ] + +jobs: + release: + name: Release + if: false == endsWith(github.event.head_commit.message, '[release]') + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + token: ${{ secrets.GH_ADMIN_TOKEN }} + + - name: Setup GIT + run: | + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + git config user.name "$GITHUB_ACTOR" + + # Tool to compute version based on Github PR labels + - name: Install auto versioning + run: > + npm install -g + auto@10.37.1 + @auto-it/released@10.37.1 + @auto-it/git-tag@10.37.1 + @auto-it/first-time-contributor@10.37.1 + + # dotnet version relies on .NET Core 2.1 (TODO maybe fork dotnet version as .NET 2.1 reached EOL) + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: '2.1.x' + + # Versioning tool for dotnet projects similar to 'npm version' + - name: install DotNetVersioning + run: dotnet tool install --global DotNetVersioning.Tool + + # CLI XPath parser to extract final AssemblyVersion from csproj file + - name: Install xmlstarlet + run: sudo apt-get install -y xmlstarlet + + - id: versioning + name: Versioning + run: | + if VERSION=$(auto version 2>&1); then + echo "Calculated version bump is ${VERSION}" + else + echo "auto version failed. Error: ${VERSION}" + exit 1 + fi + + if [ ! -z "$VERSION" ]; then + dotnet version $VERSION + if VERSION_NO=$(xmlstarlet sel -t -m '/Project/PropertyGroup/AssemblyVersion' -v . < ./AzMoNCon/AzMoNCon.csproj 2>&1); then + echo "Extracted version number is ${VERSION_NO}" + git commit -a -m "chore(release): $VERSION_NO [skip ci]" + auto shipit + else + echo "Extracting version from csproj file failed. Error: ${VERSION_NO}" + exit 1 + fi + else + echo 'Not bumping version, skipping release' + fi + env: + GITHUB_TOKEN: ${{secrets.GH_ADMIN_TOKEN}} diff --git a/.gitignore b/.gitignore index 9491a2f..3f85216 100644 --- a/.gitignore +++ b/.gitignore @@ -360,4 +360,7 @@ MigrationBackup/ .ionide/ # Fody - auto-generated XML schema -FodyWeavers.xsd \ No newline at end of file +FodyWeavers.xsd + +# Custom entries +/**/.env diff --git a/GameDb.Core/GameDb.Core.csproj b/GameDb.Core/GameDb.Core.csproj index 8ee9f11..2afd235 100644 --- a/GameDb.Core/GameDb.Core.csproj +++ b/GameDb.Core/GameDb.Core.csproj @@ -1,5 +1,12 @@ + + 0.1.0 + Michaelvsk + Michael Keller + GameDb + + net6.0 enable diff --git a/GameDb.Models/GameDb.Models.csproj b/GameDb.Models/GameDb.Models.csproj index 47180a2..1b15298 100644 --- a/GameDb.Models/GameDb.Models.csproj +++ b/GameDb.Models/GameDb.Models.csproj @@ -1,5 +1,12 @@  + + 0.1.0 + Michaelvsk + Michael Keller + GameDb + + net6.0 enable diff --git a/GameDb/GameDb.csproj b/GameDb/GameDb.csproj index 2c10fec..a212e04 100644 --- a/GameDb/GameDb.csproj +++ b/GameDb/GameDb.csproj @@ -1,73 +1,80 @@  - - net6.0-android;net6.0-ios;net6.0-maccatalyst - $(TargetFrameworks);net6.0-windows10.0.19041.0 - - - Exe - Michaelvsk.GameDb - true - true - enable - - - GameDb - - - com.companyname.gamedb - 2010D739-372C-4EEF-9F0F-5EE3B384508B - - - 1.0 - 1 - - 14.2 - 14.0 - 21.0 - 10.0.17763.0 - 10.0.17763.0 - 6.5 - Michaelvsk.$(MSBuildProjectName) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - GameList.xaml - - - - - - MSBuild:Compile - - + + 0.1.0 + Michaelvsk + Michael Keller + GameDb + + + + net6.0-android;net6.0-ios;net6.0-maccatalyst + $(TargetFrameworks);net6.0-windows10.0.19041.0 + + + Exe + Michaelvsk.GameDb + true + true + enable + + + GameDb + + + com.companyname.gamedb + 2010D739-372C-4EEF-9F0F-5EE3B384508B + + + 1.0 + 1 + + 14.2 + 14.0 + 21.0 + 10.0.17763.0 + 10.0.17763.0 + 6.5 + Michaelvsk.$(MSBuildProjectName) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + GameList.xaml + + + + + + MSBuild:Compile + +