forked from ibrasho-actions/version-number-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
35 lines (33 loc) · 1.03 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
name: Date-based Version
description: Generate a version number
author: Ibrahim AshShohail
inputs:
prefix:
required: false
default: ""
suffix:
required: false
default: ""
major-version:
description: Major version
required: true
default: "0"
outputs:
version:
description: Version number
value: ${{ steps.generator.outputs.version }}
runs:
using: "composite"
steps:
- id: generator
shell: bash
run: |
PREFIX=${{ inputs.prefix }}
SUFFIX=${{ inputs.suffix }}
V_MAJOR=${{ inputs.major-version }}
V_MINOR=$V_MAJOR.$(date +"%y%m%d" | sed -E 's/^0{1,3}//g')
V_PATCH=$V_MINOR.$(date +"%H%M%S" | sed -E 's/^0{1,3}//g')
echo version=$(date +"1.%y%m%d.%H%M%S" | sed -E 's/\.0{1,3}/./g') >> $GITHUB_OUTPUT
echo "version-major=${PREFIX}${V_MAJOR}${SUFFIX}" >> $GITHUB_OUTPUT
echo "version-minor=${PREFIX}${V_MINOR}${SUFFIX}" >> $GITHUB_OUTPUT
echo "version-patch=${PREFIX}${V_PATCH}${SUFFIX}" >> $GITHUB_OUTPUT