Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add auto versioning #6

Merged
merged 25 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e241efe
ci: add auto versioning
Michaelvsk Jun 28, 2022
a50f84e
Merge branch 'main' into build-main
Michaelvsk Jun 28, 2022
3919ff3
ci: fix build script syntax error
Michaelvsk Jun 28, 2022
04aaa9b
Merge branch 'build-main' of github.com:Michaelvsk/GameDb into build-…
Michaelvsk Jun 28, 2022
a5f5754
ci: fix build script typo
Michaelvsk Jun 28, 2022
0a5e073
ci: fix how to read version from project file
Michaelvsk Jun 28, 2022
88f2f3f
ci: fix read version from project file
Michaelvsk Jun 28, 2022
a05578c
ci: set initial project's versions
Michaelvsk Jun 28, 2022
5fe0731
ci: use Version node in csproj files for versioning
Michaelvsk Jun 28, 2022
70433a5
ci: fix csproj format so version extraction works
Michaelvsk Jun 28, 2022
19876d8
ci: fix version number extraction from csproj files
Michaelvsk Jun 28, 2022
2283b1d
ci: fix check for correct version extraction
Michaelvsk Jun 28, 2022
aa38845
ci: fix appending build number to version
Michaelvsk Jun 28, 2022
d4f079a
ci: use linux style path forward slashes
Michaelvsk Jun 28, 2022
804dcd4
ci: .NET MAUI seems not to be fully compilable with
Michaelvsk Jun 29, 2022
50f3779
ci: check passing of version number
Michaelvsk Jun 29, 2022
09a0eb1
ci: fix passing env variable
Michaelvsk Jun 29, 2022
4c3b855
ci: fix passing env var
Michaelvsk Jun 29, 2022
efabf9a
ci: test passing env vars
Michaelvsk Jun 29, 2022
46952da
test
Michaelvsk Jun 29, 2022
4ad2e8b
test
Michaelvsk Jun 29, 2022
07c34da
ci: fix passing version
Michaelvsk Jun 29, 2022
6099b44
ci: fix passing version into sonar cloud
Michaelvsk Jun 29, 2022
36b83a3
ci: fix passing version
Michaelvsk Jun 29, 2022
99bfd9c
ci: add release workflow
Michaelvsk Jun 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .autorc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"plugins": [
"git-tag",
"first-time-contributor",
"released"
],
"owner": "Michaelvsk",
"repo": "GameDb",
"name": "Michael Keller",
"email": "[email protected]",
"onlyPublishWithReleaseLabel": true
}
51 changes: 46 additions & 5 deletions .github/workflows/build-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down
72 changes: 72 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
git config user.name "$GITHUB_ACTOR"

# Tool to compute version based on Github PR labels
- name: Install auto versioning
run: >
npm install -g
[email protected]
@auto-it/[email protected]
@auto-it/[email protected]
@auto-it/[email protected]

# 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}}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,7 @@ MigrationBackup/
.ionide/

# Fody - auto-generated XML schema
FodyWeavers.xsd
FodyWeavers.xsd

# Custom entries
/**/.env
7 changes: 7 additions & 0 deletions GameDb.Core/GameDb.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>0.1.0</Version>
<Company>Michaelvsk</Company>
<Authors>Michael Keller</Authors>
<Product>GameDb</Product>
</PropertyGroup>

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
7 changes: 7 additions & 0 deletions GameDb.Models/GameDb.Models.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>0.1.0</Version>
<Company>Michaelvsk</Company>
<Authors>Michael Keller</Authors>
<Product>GameDb</Product>
</PropertyGroup>

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
145 changes: 76 additions & 69 deletions GameDb/GameDb.csproj
Original file line number Diff line number Diff line change
@@ -1,73 +1,80 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>Michaelvsk.GameDb</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>

<!-- Display name -->
<ApplicationTitle>GameDb</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.gamedb</ApplicationId>
<ApplicationIdGuid>2010D739-372C-4EEF-9F0F-5EE3B384508B</ApplicationIdGuid>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
<AssemblyName>Michaelvsk.$(MSBuildProjectName)</AssemblyName>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\appicon.svg" ForegroundFile="Resources\appiconfg.svg" Color="#512BD4" />

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\appiconfg.svg" Color="#512BD4" BaseSize="128,128" />

<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0-preview4" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GameDb.Core\GameDb.Core.csproj" />
<ProjectReference Include="..\GameDb.Models\GameDb.Models.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Update="GameList.xaml.cs">
<DependentUpon>GameList.xaml</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<MauiXaml Update="Pages\GameDetailPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>
<PropertyGroup>
<Version>0.1.0</Version>
<Company>Michaelvsk</Company>
<Authors>Michael Keller</Authors>
<Product>GameDb</Product>
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>Michaelvsk.GameDb</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>

<!-- Display name -->
<ApplicationTitle>GameDb</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.gamedb</ApplicationId>
<ApplicationIdGuid>2010D739-372C-4EEF-9F0F-5EE3B384508B</ApplicationIdGuid>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
<AssemblyName>Michaelvsk.$(MSBuildProjectName)</AssemblyName>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\appicon.svg" ForegroundFile="Resources\appiconfg.svg" Color="#512BD4" />

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\appiconfg.svg" Color="#512BD4" BaseSize="128,128" />

<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0-preview4" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GameDb.Core\GameDb.Core.csproj" />
<ProjectReference Include="..\GameDb.Models\GameDb.Models.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Update="GameList.xaml.cs">
<DependentUpon>GameList.xaml</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<MauiXaml Update="Pages\GameDetailPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>

</Project>