Skip to content

Commit

Permalink
Introduce assembly/product/package versioning (#114)
Browse files Browse the repository at this point in the history
* set versions

* cd

---------

Co-authored-by: zingz0r <zingz0r@tothnet.hu>
  • Loading branch information
zingz0r and zingz0r authored Dec 23, 2024
1 parent 7e8e5f9 commit 7ccc93b
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 6 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# .github/workflows/ci.yml
name: '♻️ CD'

on:
release:
types:
- created

env:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'

jobs:
pipeline:
name: Publish
runs-on: windows-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Set up .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'

- name: Extract release version
id: get-version
run: |
VERSION=${{ github.event.release.tag_name }}
MAJOR=$(echo "$VERSION" | cut -d. -f1)
MINOR=$(echo "$VERSION" | cut -d. -f2)
PATCH=$(echo "$VERSION" | cut -d. -f3)
echo "::set-output name=MAJOR::$MAJOR"
echo "::set-output name=MINOR::$MINOR"
echo "::set-output name=PATCH::$PATCH"
- name: Build
run: dotnet build --configuration ${{ env.buildConfiguration }} /p:MajorVersion=${{ steps.get-version.outputs.MAJOR }} /p:MinorVersion=${{ steps.get-version.outputs.MINOR }} /p:PatchVersion=${{ steps.get-version.outputs.PATCH }}

- name: Run Tests
run: dotnet test --no-build --configuration ${{ env.buildConfiguration }}
continue-on-error: false

- name: Pack
run: dotnet pack --no-build --configuration ${{ env.buildConfiguration }} .\CloudFlare.Client.sln /p:MajorVersion=${{ steps.get-version.outputs.MAJOR }} /p:MinorVersion=${{ steps.get-version.outputs.MINOR }} /p:PatchVersion=${{ steps.get-version.outputs.PATCH }}
continue-on-error: false
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
dotnet-version: '8.x'

- name: Build
run: dotnet build -restore --configuration ${{ env.buildConfiguration }}
run: dotnet build --configuration ${{ env.buildConfiguration }}

- name: Run Tests
run: dotnet test --logger "trx;logfilename=TestResults.trx" --no-build --configuration ${{ env.buildConfiguration }} --collect "XPlat Code Coverage;Format=opencover,cobertura"
Expand Down
18 changes: 13 additions & 5 deletions CloudFlare.Client/CloudFlare.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<CheckEolTargetFramework>false</CheckEolTargetFramework>
</PropertyGroup>
<PropertyGroup>
<IsPackable>true</IsPackable>
<Authors>Tamás Tóth</Authors>
<Company>TothNET</Company>
<Description>.NET library for communication with the Cloudflare service API.</Description>
Expand All @@ -27,9 +28,16 @@
<NeutralLanguage>en</NeutralLanguage>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<Version>1.0.0</Version>
</PropertyGroup>
<PropertyGroup>
<MajorVersion Condition="'$(MajorVersion)' == ''">1</MajorVersion>
<MinorVersion Condition="'$(MinorVersion)' == ''">0</MinorVersion>
<PatchVersion Condition="'$(PatchVersion)' == ''">0</PatchVersion>
<AssemblyVersion>$(MajorVersion).0.0.0</AssemblyVersion>
<InformationalVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion).0</InformationalVersion>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<FileVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion)</FileVersion>
<PackageVersion>$(FileVersion)</PackageVersion>
</PropertyGroup>
<PropertyGroup>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
Expand All @@ -50,7 +58,7 @@
</AssemblyAttribute>
</ItemGroup>
<ItemGroup>
<None Include="..\LICENSE" Pack="True" />
<None Include="..\CloudFlare.Client\Resources\nuget_logo.png" Pack="False" />
<None Include="..\LICENSE" Pack="True" PackagePath="" />
<None Include="..\CloudFlare.Client\Resources\nuget_logo.png" Pack="True" PackagePath="" />
</ItemGroup>
</Project>

0 comments on commit 7ccc93b

Please sign in to comment.