Skip to content

Commit

Permalink
Update date version task to match newest Platform Engineering code
Browse files Browse the repository at this point in the history
  • Loading branch information
WouterDeKort committed Oct 10, 2024
1 parent 7c54adc commit f8b8875
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions .github/actions/date_version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,25 @@ outputs:
runs:
using: composite
steps:
- name: Generate Version
id: generate-version
shell: pwsh
run: |
# modulo the build number to ensure we don't overflow the max patch value allowed by nuget
$buildNumber = $env:GITHUB_RUN_NUMBER%65535
$version = "$(Get-Date -Format "yyyy.M.d").$buildNumber"
- name: Generate Version
id: generate-version
shell: bash
run: |
set -euo pipefail
github_run_number=${{ github.run_number }}
github_ref=${{ github.ref }}
build_number=$(($github_run_number % 65535))
# add the -pr suffix when this is running on a PR branch
$github_ref = "${{ github.ref }}"
if ($github_ref.StartsWith("refs/pull"))
{
$version = "${version}-pr"
}
date=$(date +%Y.%-m.%-d)
echo "version=$version" >> $env:GITHUB_OUTPUT
echo "generated version: $version"
version="${date}.${build_number}"
is_pr=0
echo $github_ref | grep "^refs\/pull\/" && is_pr=1
if [ $is_pr -eq 1 ]
then
version="${version}-pr"
fi
echo "Version: $version"
echo "version=$version" >> $GITHUB_OUTPUT

0 comments on commit f8b8875

Please sign in to comment.