-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
1,573 additions
and
237 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Update Version | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version_type: | ||
description: 'Update branch version by:' | ||
type: choice | ||
options: | ||
- major | ||
- minor | ||
- patch | ||
required: true | ||
default: 'patch' | ||
|
||
env: | ||
ALLOW_UPDATES: ${{ startsWith(github.ref, 'refs/heads/develop') || startsWith(github.ref, 'refs/heads/hotfix/') }} | ||
|
||
jobs: | ||
update-version: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version_tag: ${{ env.version_tag }} | ||
previous_version_tag: ${{ env.previous_version_tag }} | ||
|
||
steps: | ||
- name: Check For Valid Updates | ||
if: env.ALLOW_UPDATES == false | ||
run: | | ||
echo "Version updates should only be done on development or hotfix" | ||
exit 1 | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run Update Version | ||
id: set_version | ||
shell: pwsh | ||
run: | | ||
Import-Module ./solution-helper.psm1 -Force | ||
$previousVersion, $newVersion = Update-Version -type ${{ github.event.inputs.version_type }} | ||
echo "version_tag=$newVersion" | Out-File -FilePath $env:GITHUB_ENV -Append | ||
echo "previous_version_tag=$previousVersion" | Out-File -FilePath $env:GITHUB_ENV -Append | ||
- name: Check for Existing Release | ||
run: | | ||
compare_versions() { | ||
echo -e "$1\n$2" | sort -V | tail -n 1 | ||
} | ||
# Fetch the list of releases | ||
releases=$(gh release list --json createdAt,tagName --limit 100) | ||
echo -e "$releases" | ||
# Sort the releases by date and extract the most recent one | ||
latest_release=$(echo "$releases" | jq -r 'sort_by(.createdAt) | reverse | .[0] | .tagName') | ||
echo -e "$latest_release" | ||
greater_version=$(compare_versions $latest_release $version_tag) | ||
if [ "$greater_version" = "$version_tag" ]; then | ||
echo "✅ $version_tag is greater than $latest_release" | ||
elif [ "$greater_version" = "$latest_release" ]; then | ||
echo "⛔ $version_tag is less than $latest_release" | ||
exit 1 | ||
else | ||
echo "⚠️ Versions are equal" | ||
exit 1 | ||
fi | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Update Version Number | ||
run: | | ||
git config --global user.name '${{ github.triggering_actor }}' | ||
git config --global user.email '${{ github.triggering_actor }}@users.noreply.github.com' | ||
git commit -am "Previous version was '${{ env.previous_version_tag }}'. Version now '${{ env.version_tag }}'." | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<!-- | ||
<!-- | ||
Push the target package to nuget | ||
--> | ||
<Target Name="PushPackage" AfterTargets="Pack" | ||
Condition="'$(PushAfterPack)'=='true' AND '$(IsPackable)'=='true'"> | ||
<Exec Command="dotnet nuget push $(SolutionDir)output/$(TargetName).$(PackageVersion).nupkg $(PackageSourceParam) $(PackageApiKeyParam)"></Exec> | ||
</Target> | ||
<Target Name="PushPackage" AfterTargets="Pack" | ||
Condition="'$(PushAfterPack)'=='true' AND '$(IsPackable)'=='true'"> | ||
<Exec Command="dotnet nuget push $(SolutionDir)output/$(TargetName).$(PackageVersion).nupkg $(PackageSourceParam) $(PackageApiKeyParam)"></Exec> | ||
</Target> | ||
|
||
<!-- | ||
<!-- | ||
Set the package version and source before Pack | ||
https://github.com/NuGet/NuGet.Client/blob/4.3.0.4202/src/NuGet.Core/NuGet.Build.Tasks.Pack.Library/Pack.targets | ||
Must run before target "GenerateNuspec" ("Pack") for the version to be applied as expected | ||
--> | ||
<Target Name="SetPackageVersion" BeforeTargets="GenerateNuspec" | ||
Condition="'$(IsPackable)'=='true'"> | ||
<PropertyGroup> | ||
<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix> | ||
<PackageVersion Condition="'$(VersionSuffix)'==''">$(VersionPrefix)</PackageVersion> | ||
<PackageVersion Condition="'$(VersionSuffix)'!=''">$(VersionPrefix)-$(VersionSuffix)</PackageVersion> | ||
</PropertyGroup> | ||
</Target> | ||
<Target Name="SetPackageVersion" BeforeTargets="GenerateNuspec" | ||
Condition="'$(IsPackable)'=='true'"> | ||
<PropertyGroup> | ||
<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix> | ||
<PackageVersion Condition="'$(VersionSuffix)'==''">$(VersionPrefix)</PackageVersion> | ||
<PackageVersion Condition="'$(VersionSuffix)'!=''">$(VersionPrefix)-$(VersionSuffix)</PackageVersion> | ||
</PropertyGroup> | ||
</Target> | ||
|
||
<Target Name="SetPackageSource" BeforeTargets="GenerateNuspec" | ||
Condition="'$(PushAfterPack)'=='true'"> | ||
<PropertyGroup> | ||
<PackageSourceParam Condition="'$(PackageSource)'!=''">--source $(PackageSource)</PackageSourceParam> | ||
</PropertyGroup> | ||
</Target> | ||
<Target Name="SetPackageSource" BeforeTargets="GenerateNuspec" | ||
Condition="'$(PushAfterPack)'=='true'"> | ||
<PropertyGroup> | ||
<PackageSourceParam Condition="'$(PackageSource)'!=''">--source $(PackageSource)</PackageSourceParam> | ||
</PropertyGroup> | ||
</Target> | ||
|
||
<Target Name="SetPackageApiKey" BeforeTargets="GenerateNuspec" | ||
Condition="'$(PushAfterPack)'=='true'"> | ||
<PropertyGroup> | ||
<PackageApiKeyParam Condition="'$(PackageApiKey)'!=''">--api-key $(PackageApiKey)</PackageApiKeyParam> | ||
</PropertyGroup> | ||
</Target> | ||
<Target Name="SetPackageApiKey" BeforeTargets="GenerateNuspec" | ||
Condition="'$(PushAfterPack)'=='true'"> | ||
<PropertyGroup> | ||
<PackageApiKeyParam Condition="'$(PackageApiKey)'!=''">--api-key $(PackageApiKey)</PackageApiKeyParam> | ||
</PropertyGroup> | ||
</Target> | ||
|
||
</Project> |
Oops, something went wrong.