31 lines
1.0 KiB
YAML
31 lines
1.0 KiB
YAML
name: Retrieve version
|
|
description: Uses the tags and git commit to find a unique version and sets it as NEW_VERSION
|
|
author: Skydust
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Get commit version
|
|
run: |
|
|
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
|
NEW_VERSION="${GITHUB_REF##refs/tags/}"
|
|
echo "This is a tag push: $(yellow)${NEW_VERSION}"
|
|
else
|
|
echo "This is a branch push: $(yellow)${GITHUB_REF##refs/heads/}"
|
|
|
|
last_version="$(git describe --tags --match "v*" --abbrev=0 || echo "")"
|
|
if [[ -z "$last_version" ]]; then
|
|
last_version="v0.0.0"
|
|
fi
|
|
|
|
calculatedSha="$(git rev-parse --short ${{ github.sha }})"
|
|
NEW_VERSION="${last_version}-${calculatedSha}"
|
|
fi
|
|
|
|
# Removing the v
|
|
NEW_VERSION="${NEW_VERSION:1}"
|
|
|
|
log_info "New version: $(yellow)${NEW_VERSION}"
|
|
log_info "Exported version in env var $(yellow)NEW_VERSION"
|
|
echo "NEW_VERSION=${NEW_VERSION}" >> $GITEA_ENV
|