From c651fb15bf62fcbb0b2ea4f692cf6cddb7882c98 Mon Sep 17 00:00:00 2001 From: yoanm <4410697+yoanm@users.noreply.github.com> Date: Mon, 26 Aug 2024 19:04:35 +0200 Subject: [PATCH] inner-releases-as-latest option (#9) Fix #8 --- README.md | 11 +++++++++++ action.yml | 18 +++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a32aba2..5596cd4 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,17 @@ Then continue creating `vX.Y.Z` releases as usual, related existing `vX` and `vX > [!IMPORTANT] > Will work only on pre-existing releases ! +- `inner-releases-as-latest`: Default to `auto`. + + Whether to set inner releases as latest. + + > [!IMPORTANT] + > Requires `update-inner-releases` at `true` ! + + - `auto`: Will be set only if releases linked to provided `tag` is the latest + - `true`: Set them as latest whatever if provided `tag` release is the latest or not + - `false`: Do not set them as latest + - `git-email`: Default to `github-actions[bot]@users.noreply.github.com`. _Git user email is required when creating tag with a message._ diff --git a/action.yml b/action.yml index 2dc98e3..09a04ed 100644 --- a/action.yml +++ b/action.yml @@ -13,11 +13,18 @@ inputs: default: ${{ github.event.release.tag_name }} update-inner-releases: description: | - Whether to also update releases name linked to `vX` and `vX.Y` tags and set them as latest if provided tag - release is currently the latest release. + Whether to also update releases name linked to `vX` and `vX.Y` tags. Will work only on pre-existing releases ! required: false default: 'false' + inner-releases-as-latest: + description: | + Whether to set inner releases as latest. Requires `update-inner-releases` at `true` ! + - `auto`: Will be set only if releases linked to provided `tag` is the latest + - `true`: Set as latest whatever provided `tag` releases is the latest or not + - `false`: Do not set them as latest + required: false + default: 'auto' git-email: description: The email for the GIT user creating the tags required: false @@ -126,17 +133,18 @@ runs: FULL_TAG: ${{ inputs.tag }} MINOR_TAG: ${{ steps.generate-tags.outputs.minor }} MAJOR_TAG: ${{ steps.generate-tags.outputs.major }} + LATEST_MODE: ${{ inputs.inner-releases-as-latest }} working-directory: ${{ inputs.working-directory }} run: | # Update inner releases - MINOR_RELEASE_EXISTS=$( (gh release view "${MINOR_TAG}" --json id -q .id | wc -l | tr -d '[:space:]') || echo 0); - MAJOR_RELEASE_EXISTS=$( (gh release view "${MAJOR_TAG}" --json id -q .id | wc -l | tr -d '[:space:]') || echo 0); + MINOR_RELEASE_EXISTS=$( (gh release view "${MINOR_TAG}" --json id -q .id | wc -l |tr -d '[:space:]') || echo 0); + MAJOR_RELEASE_EXISTS=$( (gh release view "${MAJOR_TAG}" --json id -q .id | wc -l |tr -d '[:space:]') || echo 0); if [[ "${MINOR_RELEASE_EXISTS}${MAJOR_RELEASE_EXISTS}" -eq 0 ]]; then echo '::warning::No inner release to update !' exit 0 fi PARAMS="--title ${FULL_TAG}" - if [[ "`gh repo view --json latestRelease -q .latestRelease.tagName`" = "${FULL_TAG}" ]]; then + if [[ "${LATEST_MODE}" = "true" || ( "${LATEST_MODE}" = "auto" && "`gh repo view --json latestRelease -q .latestRelease.tagName`" = "${FULL_TAG}" ) ]]; then PARAMS+=' --latest' fi if ! [[ "${MINOR_RELEASE_EXISTS}" -eq 0 ]]; then