Skip to content

Commit

Permalink
feat: change date format
Browse files Browse the repository at this point in the history
  • Loading branch information
StephaneBour committed Apr 15, 2020
1 parent cac3e5a commit ed400c1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ Is a pre-release ?. Default `false`.

Create a new release ?. Default `true`.

### `date_format`

Set the date format in posix shell. Default `%Y.%V` (Year.Week - 2020.45).



## Output

### `release`
Expand All @@ -40,11 +46,12 @@ The new release name.

steps:
- uses: actions/checkout@v2
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- name: Calver Release
uses: StephaneBour/actions-calver@master
id: calver
with:
date_format: "%Y-%m-%d"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ inputs:
description: 'Create new release'
required: true
default: 'true'
date_format:
description: 'Format date in posix shell'
required: true
default: '%Y.%V'

outputs:
release:
Expand All @@ -46,3 +50,4 @@ runs:
- ${{ inputs.draft }}
- ${{ inputs.pre }}
- ${{ inputs.release }}
- ${{ inputs.date_format }}
8 changes: 4 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ MESSAGE="${3}"
DRAFT="${4}"
PRE="${5}"
CREATE_RELEASE="${6}"
DATE_FORMAT="${7}"

# Fetch git tags
git fetch --depth=1 origin +refs/tags/*:refs/tags/*

NEXT_RELEASE=$(date '+%Y.%V')
NEXT_RELEASE=$(date "+${DATE_FORMAT}")

LAST_HASH=$(git rev-list --tags --max-count=1)
echo "Last hash : ${LAST_HASH}"

LAST_RELEASE=$(git describe --tags "${LAST_HASH}")
echo "Last release : ${LAST_RELEASE}"

MAJOR_LAST_RELEASE=$(echo "${LAST_RELEASE}" | awk '{ string=substr($0, 1, 7); print string; }' )
MAJOR_LAST_RELEASE=$(echo "${LAST_RELEASE}" | awk -v l=${#NEXT_RELEASE} '{ string=substr($0, 1, l); print string; }' )
echo "Last major release : ${MAJOR_LAST_RELEASE}"

if [ "${MAJOR_LAST_RELEASE}" = "${NEXT_RELEASE}" ]; then
MINOR_LAST_RELEASE=$(echo "${LAST_RELEASE}" | awk '{ string=substr($0, 9); print string; }' )
MINOR_LAST_RELEASE=$(echo "${LAST_RELEASE}" | awk -v l=`expr ${#NEXT_RELEASE} + 2` '{ string=substr($0, l); print string; }' )
NEXT_RELEASE=${MAJOR_LAST_RELEASE}.$((${MINOR_LAST_RELEASE} + 1))
echo "Minor release"
fi
Expand Down

0 comments on commit ed400c1

Please sign in to comment.