Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c5f7b86d4 | |||
| c4d8815d6d | |||
| d74e042823 |
43
action.yml
43
action.yml
@@ -22,7 +22,8 @@ inputs:
|
|||||||
default: "Major"
|
default: "Major"
|
||||||
token:
|
token:
|
||||||
description: 'A Gitea PAT'
|
description: 'A Gitea PAT'
|
||||||
required: true
|
default: "${{ secrets.CI_TOKEN }}"
|
||||||
|
required: false
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
@@ -37,32 +38,16 @@ runs:
|
|||||||
log_info $(red)ERROR$(reset_color) This can only be ran on the dev branch
|
log_info $(red)ERROR$(reset_color) This can only be ran on the dev branch
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
- name: Getting version
|
||||||
|
uses: https://gitea.skydust.fr/actions/get-version@v1
|
||||||
|
with:
|
||||||
|
semver: "${{ inputs.semver }}"
|
||||||
- name: Get new version
|
- name: Get new version
|
||||||
run: |
|
run: |
|
||||||
last_version="$(git describe --tags --abbrev=0 --match "v*" 2> /dev/null || echo "")"
|
if ! [[ "${NEW_VERSION}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
|
||||||
if [[ -z "$last_version" ]]; then
|
log_info "$(red)ERROR$(reset_color) The version $(yellow)${NEW_VERSION}$(reset_color) is not valid for a release"
|
||||||
last_version="v0.0.0"
|
exit 1
|
||||||
fi
|
fi
|
||||||
last_version="${last_version:1}"
|
|
||||||
log_info "Last version: ${last_version}"
|
|
||||||
|
|
||||||
# Split the version into components
|
|
||||||
IFS='.' read -r major minor patch <<< "${last_version%%-*}"
|
|
||||||
|
|
||||||
# Increment the appropriate part of the version
|
|
||||||
case "${{ inputs.semver }}" in
|
|
||||||
"Major"*) NEW_VERSION="$((major + 1)).0.0"
|
|
||||||
;;
|
|
||||||
"Minor"*) NEW_VERSION="$major.$((minor + 1)).0"
|
|
||||||
;;
|
|
||||||
"Patch"*) NEW_VERSION="$major.$minor.$((patch + 1))"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
log_info "Requested ${{ inputs.semver }} update"
|
|
||||||
log_info "New version: ${NEW_VERSION}"
|
|
||||||
|
|
||||||
echo NEW_VERSION=${NEW_VERSION} >> $GITEA_ENV
|
|
||||||
- name: Setting up release git account
|
- name: Setting up release git account
|
||||||
run: |
|
run: |
|
||||||
git config user.email "release@example.com"
|
git config user.email "release@example.com"
|
||||||
@@ -78,14 +63,18 @@ runs:
|
|||||||
git config --local --unset http.https://${GITHUB_SERVER_URL#https://}/.extraheader
|
git config --local --unset http.https://${GITHUB_SERVER_URL#https://}/.extraheader
|
||||||
- name: Pushing new version
|
- name: Pushing new version
|
||||||
run: |
|
run: |
|
||||||
|
if [[ -n "${{ inputs.semver }}" ]]; then
|
||||||
|
SEMVER_UPDATE="${{ inputs.semver }}"
|
||||||
|
fi
|
||||||
|
|
||||||
log_info "Pushing new tag"
|
log_info "Pushing new tag"
|
||||||
git fetch
|
git fetch
|
||||||
git tag -a "v${NEW_VERSION}" -m "Release version ${NEW_VERSION}"
|
git tag -a "v${NEW_VERSION}" -m "Release version ${NEW_VERSION}"
|
||||||
git push origin "v${NEW_VERSION}"
|
git push origin "v${NEW_VERSION}"
|
||||||
|
|
||||||
if { [[ "${{ inputs.new_branch_on }}" == "Major"* ]] &&
|
if { [[ "${{ inputs.new_branch_on }}" == "Minor"* ]] &&
|
||||||
{ [[ "${{ inputs.semver }}" == "Major"* ]] || [[ "${{ inputs.semver }}" == "Minor"* ]]; }; } ||
|
{ [[ "${SEMVER_UPDATE}" == "Major"* ]] || [[ "${SEMVER_UPDATE}" == "Minor"* ]]; }; } ||
|
||||||
{ [[ "${{ inputs.new_branch_on }}" == "Minor"* ]] && [[ "${{ inputs.semver }}" == "Minor"* ]]; }; then
|
{ [[ "${{ inputs.new_branch_on }}" == "Major"* ]] && [[ "${SEMVER_UPDATE}" == "Major"* ]]; }; then
|
||||||
|
|
||||||
log_info "${{ inputs.new_branch_on }} version, creating release branch for backports"
|
log_info "${{ inputs.new_branch_on }} version, creating release branch for backports"
|
||||||
git branch "release/v${NEW_VERSION}"
|
git branch "release/v${NEW_VERSION}"
|
||||||
|
|||||||
Reference in New Issue
Block a user