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

Add version suffix and metadata #115

Merged
merged 5 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
47 changes: 34 additions & 13 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# .github/workflows/ci.yml
# .github/workflows/cd.yml
name: '♻️ CD'

on:
Expand Down Expand Up @@ -29,24 +29,45 @@ jobs:
with:
dotnet-version: '8.x'

- name: Extract release version
- 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"
$regex = '^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'
$version = "${{ github.event.release.tag_name }}"

if ($version -match $regex) {
$major = $matches['major']
$minor = $matches['minor']
$patch = $matches['patch']
$prerelease = $matches['prerelease']
$buildmetadata = $matches['buildmetadata']

Write-Output "::set-output name=MAJOR::$major"
Write-Output "::set-output name=MINOR::$minor"
Write-Output "::set-output name=PATCH::$patch"
Write-Output "::set-output name=PRERELEASE::$prerelease"
Write-Output "::set-output name=BUILDMETADATA::$buildmetadata"
} else {
throw "Invalid Semantic Versioning format: $version"
}

- 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 }}
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 }} `
/p:PreReleaseLabel=${{ steps.get-version.outputs.PRERELEASE }} `
/p:BuildMetadata=${{ steps.get-version.outputs.BUILDMETADATA }}

- 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
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 }} `
/p:PreReleaseLabel=${{ steps.get-version.outputs.PRERELEASE }} `
/p:BuildMetadata=${{ steps.get-version.outputs.BUILDMETADATA }}
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,3 @@ jobs:

- name: Run Tests
run: dotnet test --logger "trx;logfilename=TestResults.trx" --no-build --configuration ${{ env.buildConfiguration }} --collect "XPlat Code Coverage;Format=opencover,cobertura"
continue-on-error: false
7 changes: 5 additions & 2 deletions CloudFlare.Client/CloudFlare.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@
<MajorVersion Condition="'$(MajorVersion)' == ''">1</MajorVersion>
<MinorVersion Condition="'$(MinorVersion)' == ''">0</MinorVersion>
<PatchVersion Condition="'$(PatchVersion)' == ''">0</PatchVersion>
<AssemblyVersion>$(MajorVersion).0.0.0</AssemblyVersion>
<PreReleaseSuffix Condition="'$(PreReleaseLabel)' != ''">-$(PreReleaseLabel)</PreReleaseSuffix>
<BuildMetadataSuffix Condition="'$(BuildMetadata)' != ''">+$(BuildMetadata)</BuildMetadataSuffix>

<AssemblyVersion>$(MajorVersion).$(MinorVersion).0.0</AssemblyVersion>
<InformationalVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion).0</InformationalVersion>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<FileVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion)</FileVersion>
<PackageVersion>$(FileVersion)</PackageVersion>
<PackageVersion>$(FileVersion)$(PreReleaseSuffix)$(BuildMetadataSuffix)</PackageVersion>
</PropertyGroup>
<PropertyGroup>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
Expand Down
Loading