Skip to content

Commit

Permalink
inner-releases-as-latest option (#9)
Browse files Browse the repository at this point in the history
Fix #8
  • Loading branch information
yoanm authored Aug 26, 2024
1 parent f6271f0 commit c651fb1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand Down
18 changes: 13 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Check warning on line 147 in action.yml

View workflow job for this annotation

GitHub Actions / Static tests

147:121 [line-length] line too long (164 > 120 characters)

Check warning on line 147 in action.yml

View workflow job for this annotation

GitHub Actions / Static tests

147:121 [line-length] line too long (164 > 120 characters)

Check warning on line 147 in action.yml

View workflow job for this annotation

GitHub Actions / Static tests

147:121 [line-length] line too long (164 > 120 characters)

Check warning on line 147 in action.yml

View workflow job for this annotation

GitHub Actions / Static tests

147:121 [line-length] line too long (164 > 120 characters)
PARAMS+=' --latest'
fi
if ! [[ "${MINOR_RELEASE_EXISTS}" -eq 0 ]]; then
Expand Down

0 comments on commit c651fb1

Please sign in to comment.