Compare commits
2 Commits
dc4aeb1e51
...
cb52dd909d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb52dd909d | ||
|
|
acca6adacc |
@@ -36,37 +36,53 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Resolve release version
|
||||
id: resolve-version
|
||||
env:
|
||||
REQUESTED_TAG: ${{ inputs.tag }}
|
||||
- name: Fetch and detect release tag
|
||||
id: detect-tag
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
requested_tag="$(printf '%s' "${REQUESTED_TAG:-}" | sed 's/^[[:space:]]\+//; s/[[:space:]]\+$//')"
|
||||
# Fetch all tags from origin to ensure we have the latest
|
||||
git fetch origin --tags --force --quiet 2>/dev/null || true
|
||||
|
||||
# Try to find the most recent tag (in case it was just created by prepare-release)
|
||||
latest_tag="$(git describe --tags --abbrev=0 2>/dev/null || echo '')"
|
||||
|
||||
if [[ -n "$latest_tag" ]]; then
|
||||
echo "detected_tag=$latest_tag" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Resolve release version
|
||||
id: resolve-version
|
||||
env:
|
||||
INPUT_TAG: ${{ inputs.tag }}
|
||||
DETECTED_TAG: ${{ steps.detect-tag.outputs.detected_tag }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
# Try to use explicit input first
|
||||
requested_tag="$(printf '%s' "${INPUT_TAG}" | sed 's/^[[:space:]]\+//; s/[[:space:]]\+$//')"
|
||||
|
||||
# Fall back to detected tag if input is empty
|
||||
if [[ -z "$requested_tag" && -n "${DETECTED_TAG}" ]]; then
|
||||
requested_tag="$DETECTED_TAG"
|
||||
fi
|
||||
|
||||
# Try GITHUB_REF if still empty
|
||||
if [[ -z "$requested_tag" && "$GITHUB_REF" == refs/tags/* ]]; then
|
||||
requested_tag="${GITHUB_REF#refs/tags/}"
|
||||
fi
|
||||
|
||||
if [[ -n "$requested_tag" ]]; then
|
||||
# Explicit tag was provided via input or workflow_call
|
||||
# Normalize to v-prefixed format
|
||||
normalized="${requested_tag#v}"
|
||||
tag="v${normalized}"
|
||||
elif [[ "$GITHUB_REF" == refs/tags/* ]]; then
|
||||
# Running from a tag push
|
||||
tag="${GITHUB_REF#refs/tags/}"
|
||||
normalized="${tag#v}"
|
||||
else
|
||||
# Try to find tags at HEAD (fetch latest first in case called from prepare-release)
|
||||
git fetch origin --tags --quiet 2>/dev/null || true
|
||||
|
||||
if tag_at_head="$(git describe --exact-match --tags HEAD 2>/dev/null)" && [[ -n "$tag_at_head" ]]; then
|
||||
# Current HEAD is at a tag
|
||||
tag="$tag_at_head"
|
||||
normalized="${tag#v}"
|
||||
else
|
||||
echo "A release tag is required when the workflow is not running from a tag push" >&2
|
||||
echo "Provide a tag via the 'tag' input or ensure HEAD is at a tagged commit." >&2
|
||||
echo "Error: Could not resolve release version" >&2
|
||||
echo " - inputs.tag: '$INPUT_TAG'" >&2
|
||||
echo " - detected_tag: '${DETECTED_TAG}'" >&2
|
||||
echo " - GITHUB_REF: '$GITHUB_REF'" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
|
||||
echo "version=${normalized}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
@@ -35,7 +35,7 @@ A `### Breaking` section is used in addition to Keep a Changelog's standard sect
|
||||
|
||||
### Fixed
|
||||
|
||||
- Made `do-release` version resolution support empty version input when called from `prepare-release` via `workflow_call` by fetching latest tags from origin before attempting to resolve from HEAD tags, allowing version discovery even if tags were just pushed and not yet local.
|
||||
- Made `do-release` version resolution resilient to `workflow_call` input passing issues by adding a separate tag detection step that fetches and discovers the latest tag from origin as a fallback when `inputs.tag` is empty, enabling proper operation even when Gitea's workflow_call doesn't pass inputs through correctly.
|
||||
- Fixed version resolution in `do-release` workflow by moving version calculation before checkout, resolving from inputs/git tags, and always passing explicit version to `publish` action.
|
||||
- Made `publish` action version resolution more robust with clearer error messages when version input is missing and workflow is not running from a tag push.
|
||||
- Fixed `do-release` workflow to always checkout the resolved release tag, eliminating conditional checkout logic that could skip the checkout when called from `prepare-release` workflow.
|
||||
|
||||
Reference in New Issue
Block a user