Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request #69 from NoxOrg/feature/automate-version
Browse files Browse the repository at this point in the history
automate update csproj properties with SemVer - version
  • Loading branch information
jan-schutte authored Jun 29, 2023
2 parents 6b4e7c3 + 1aa2884 commit b9a13f0
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 8 deletions.
63 changes: 60 additions & 3 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,72 @@ jobs:
dotnet-version: ['6.0.x']
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install GitVersion # https://github.com/GitTools/actions/blob/main/docs/examples/github/gitversion/setup/usage-examples.md
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.x'

- name: Determine Version
id: gitversion # id to later be referenced
uses: gittools/actions/gitversion/execute@v0
with:
useConfigFile: true
additionalArguments: '/updateprojectfiles'

- name: Display GitVersion outputs (step output)
run: |
echo "Major: ${{ steps.gitversion.outputs.major }}"
echo "Minor: ${{ steps.gitversion.outputs.minor }}"
echo "Patch: ${{ steps.gitversion.outputs.patch }}"
echo "PreReleaseTag: ${{ steps.gitversion.outputs.preReleaseTag }}"
echo "PreReleaseTagWithDash: ${{ steps.gitversion.outputs.preReleaseTagWithDash }}"
echo "PreReleaseLabel: ${{ steps.gitversion.outputs.preReleaseLabel }}"
echo "PreReleaseNumber: ${{ steps.gitversion.outputs.preReleaseNumber }}"
echo "WeightedPreReleaseNumber: ${{ steps.gitversion.outputs.weightedPreReleaseNumber }}"
echo "BuildMetaData: ${{ steps.gitversion.outputs.buildMetaData }}"
echo "BuildMetaDataPadded: ${{ steps.gitversion.outputs.buildMetaDataPadded }}"
echo "FullBuildMetaData: ${{ steps.gitversion.outputs.fullBuildMetaData }}"
echo "MajorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}"
echo "SemVer: ${{ steps.gitversion.outputs.semVer }}"
echo "LegacySemVer: ${{ steps.gitversion.outputs.legacySemVer }}"
echo "LegacySemVerPadded: ${{ steps.gitversion.outputs.legacySemVerPadded }}"
echo "AssemblySemVer: ${{ steps.gitversion.outputs.assemblySemVer }}"
echo "AssemblySemFileVer: ${{ steps.gitversion.outputs.assemblySemFileVer }}"
echo "FullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}"
echo "InformationalVersion: ${{ steps.gitversion.outputs.informationalVersion }}"
echo "BranchName: ${{ steps.gitversion.outputs.branchName }}"
echo "EscapedBranchName: ${{ steps.gitversion.outputs.escapedBranchName }}"
echo "Sha: ${{ steps.gitversion.outputs.sha }}"
echo "ShortSha: ${{ steps.gitversion.outputs.shortSha }}"
echo "NuGetVersionV2: ${{ steps.gitversion.outputs.nuGetVersionV2 }}"
echo "NuGetVersion: ${{ steps.gitversion.outputs.nuGetVersion }}"
echo "NuGetPreReleaseTagV2: ${{ steps.gitversion.outputs.nuGetPreReleaseTagV2 }}"
echo "NuGetPreReleaseTag: ${{ steps.gitversion.outputs.nuGetPreReleaseTag }}"
echo "VersionSourceSha: ${{ steps.gitversion.outputs.versionSourceSha }}"
echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.commitsSinceVersionSource }}"
echo "CommitsSinceVersionSourcePadded: ${{ steps.gitversion.outputs.commitsSinceVersionSourcePadded }}"
echo "UncommittedChanges: ${{ steps.gitversion.outputs.uncommittedChanges }}"
echo "CommitDate: ${{ steps.gitversion.outputs.commitDate }}"
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}

additionalArguments: '/showConfig'

- name: Build
run: dotnet build ./src/Nox.Types --warnaserror --configuration Release

- name: Pack Nox.Types
run: dotnet pack --no-build ./src/Nox.Types --configuration Release -o ./artifacts
- name: Pack Nox.Types
run: dotnet pack --no-build ./src/Nox.Types --configuration Release -o ./artifacts

- name: Publish Nox.Lib
if: github.ref == 'refs/heads/main'
run: dotnet nuget push ./artifacts/Nox.Types.*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json

- name: Publish Nox.Lib Warning
if: github.ref != 'refs/heads/main'
run: echo "Skipping publishing, not in main branch"
5 changes: 5 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mode: ContinuousDelivery
branches: {}
ignore:
sha: []
merge-message-formats: {}
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,21 @@ public string ToString(IFormatProvider formatProvider)
return $"{Value.Latitude.ToString(formatProvider)} {Value.Longitude.ToString(formatProvider)}";
}
```

## Versioning

We are using [SemVer](https://semver.org/) for versioning our deliverables.

To manage this version we are using [GitVersion](https://github.com/GitTools/GitVersion) tool.

### Using it locally

You can use gitversion locally to test and setup configuration. To do that intall the dotnet tool `dotnet tool install --global GitVersion.Tool --version 5.*`

run `dotnet-gitversion` to see the current variables of git version

run `dotnet-gitversion /updateprojectfiles` to update csproject files

## Release

Just Create a release in GitHub, tag it properly, and that is all. In the future we want to automate this process.
1 change: 1 addition & 0 deletions src/Nox.Types.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nox.Types.EntityFramework",
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{4E819E2B-6E88-47DA-AA56-1194B9921B31}"
ProjectSection(SolutionItems) = preProject
..\GitVersion.yml = ..\GitVersion.yml
..\README.md = ..\README.md
EndProjectSection
EndProject
Expand Down
7 changes: 2 additions & 5 deletions src/Nox.Types/Nox.Types.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Copyright>Copyright (c) Andre Sharpe 2022</Copyright>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<AssemblyVersion>1.0.8.0</AssemblyVersion>
<FileVersion>1.0.8.0</FileVersion>
<PackageVersion>1.0.8</PackageVersion>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/NoxOrg/Nox</PackageProjectUrl>
<RepositoryUrl>https://github.com/NoxOrg/Nox.Types.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
Expand All @@ -25,4 +22,4 @@
<ItemGroup>
<None Include="..\..\images\nox.png" Pack="true" PackagePath="" />
</ItemGroup>
</Project>
</Project>

0 comments on commit b9a13f0

Please sign in to comment.