Set multiple version types
This commit is contained in:
@@ -25,29 +25,58 @@ runs:
|
||||
git fetch --tags
|
||||
|
||||
- name: Calculate Version
|
||||
id: calculate
|
||||
shell: bash
|
||||
run: |
|
||||
DATE=$(date +'%Y.%m.%d')
|
||||
TAG_COUNT=$(git tag -l "${DATE}.*" | wc -l)
|
||||
# Regular date with leading zeros
|
||||
DATE_LEADING=$(date +'%Y.%m.%d')
|
||||
|
||||
if [ "$TAG_COUNT" -eq 0 ]; then
|
||||
# Year, month and day without leading zeros for alternate formats
|
||||
YEAR=$(date +'%Y')
|
||||
MONTH_NL=$(date +%-m)
|
||||
DAY_NL=$(date +%-d)
|
||||
|
||||
TAG_COUNT=$(git tag -l "${DATE_LEADING}.*" | wc -l)
|
||||
|
||||
if [ "${TAG_COUNT}" -eq 0 ]; then
|
||||
BUILD_NUMBER=0
|
||||
else
|
||||
BUILD_NUMBER=$(($TAG_COUNT + 1))
|
||||
BUILD_NUMBER=$((${TAG_COUNT} + 1))
|
||||
fi
|
||||
|
||||
VERSION_SUFFIX="${{ inputs.version_suffix }}"
|
||||
SUFFIX_SEPARATOR="${{ inputs.suffix_separator }}"
|
||||
|
||||
# Regular (keeps leading zeros in date)
|
||||
if [ -n "$VERSION_SUFFIX" ]; then
|
||||
BUILD_VERSION="${DATE}.${BUILD_NUMBER}${SUFFIX_SEPARATOR}${VERSION_SUFFIX}"
|
||||
BUILD_VERSION="${DATE_LEADING}.${BUILD_NUMBER}${SUFFIX_SEPARATOR}${VERSION_SUFFIX}"
|
||||
else
|
||||
BUILD_VERSION="${DATE}.${BUILD_NUMBER}"
|
||||
BUILD_VERSION="${DATE_LEADING}.${BUILD_NUMBER}"
|
||||
fi
|
||||
|
||||
# Dotnet variant: year.month.day.build (no leading zeros for month/day)
|
||||
DOTNET_DATE="${YEAR}.${MONTH_NL}.${DAY_NL}"
|
||||
if [ -n "$VERSION_SUFFIX" ]; then
|
||||
DOTNET_VERSION="${DOTNET_DATE}.${BUILD_NUMBER}${SUFFIX_SEPARATOR}${VERSION_SUFFIX}"
|
||||
else
|
||||
DOTNET_VERSION="${DOTNET_DATE}.${BUILD_NUMBER}"
|
||||
fi
|
||||
|
||||
# NPM variant: year.month.(day concatenated with build) e.g. 2026.2.221 for day=22 build=1
|
||||
NPM_DAY_BUILD="${DAY_NL}${BUILD_NUMBER}"
|
||||
if [ -n "$VERSION_SUFFIX" ]; then
|
||||
NPM_VERSION="${YEAR}.${MONTH_NL}.${NPM_DAY_BUILD}${SUFFIX_SEPARATOR}${VERSION_SUFFIX}"
|
||||
else
|
||||
NPM_VERSION="${YEAR}.${MONTH_NL}.${NPM_DAY_BUILD}"
|
||||
fi
|
||||
|
||||
# Write the versions as artifacts for backward compatibility and accessibility
|
||||
echo "$BUILD_VERSION" > version.txt
|
||||
echo "$DOTNET_VERSION" > dotnet-version.txt
|
||||
echo "$NPM_VERSION" > npm-version.txt
|
||||
|
||||
# Export regular version to environment (backwards-compatible)
|
||||
echo "VERSION=$BUILD_VERSION" >> $GITHUB_ENV
|
||||
echo "Generated version: $BUILD_VERSION"
|
||||
|
||||
- name: Create Git Tag
|
||||
shell: bash
|
||||
@@ -63,3 +92,15 @@ runs:
|
||||
with:
|
||||
name: version
|
||||
path: version.txt
|
||||
|
||||
- name: Upload Dotnet Version Artifact
|
||||
uses: https://github.com/actions/upload-artifact@v3
|
||||
with:
|
||||
name: dotnet-version
|
||||
path: dotnet-version.txt
|
||||
|
||||
- name: Upload NPM Version Artifact
|
||||
uses: https://github.com/actions/upload-artifact@v3
|
||||
with:
|
||||
name: npm-version
|
||||
path: npm-version.txt
|
||||
|
||||
Reference in New Issue
Block a user