Skip to content

Commit 3c44279

Browse files
committed
fix: Fill tag name from inputs or env var
1 parent 1e6921c commit 3c44279

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

.github/workflows/release.yml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ on:
99
tag:
1010
description: 'Tag to mirror (e.g. v1.2.3)'
1111
required: true
12-
default: ${{ github.ref_name }}
1312

1413
permissions:
1514
contents: write
@@ -29,24 +28,35 @@ jobs:
2928
run: |
3029
set -euo pipefail
3130
32-
echo "Fetching GitLab release for tag: ${{ inputs.tag }}"
33-
if ! curl --silent --show-error --location --fail --output release.json "${GITLAB_PROJECT_API_URL}/${{ inputs.tag }}"; then
34-
echo "ERROR: Failed to fetch GitLab release for tag <${{ inputs.tag }}>."
31+
TAG_NAME="${{ inputs.tag }}"
32+
if test -z "$TAG_NAME"; then
33+
TAG_NAME="${GITHUB_REF_NAME}"
34+
fi
35+
if [[ $TAG_NAME =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
36+
echo "Using tag: $TAG_NAME"
37+
else
38+
echo "ERROR: Invalid tag name '$TAG_NAME'. Expected format: vX.Y.Z"
39+
exit 1
40+
fi
41+
42+
echo "Fetching GitLab release for tag: $TAG_NAME"
43+
if ! curl --silent --show-error --location --fail --output release.json "${GITLAB_PROJECT_API_URL}/${TAG_NAME}"; then
44+
echo "ERROR: Failed to fetch GitLab release for tag <$TAG_NAME>."
3545
exit 1
3646
fi
3747
3848
title="$(jq -r '.name // .tag_name' release.json)"
3949
notes_file=release_notes.md
4050
{
41-
echo "Mirrored from GitLab: ${GITLAB_RELEASE_URL}/${{ inputs.tag }}"
51+
echo "Mirrored from GitLab: ${GITLAB_RELEASE_URL}/${TAG_NAME}"
4252
echo
4353
jq -r '.description // ""' release.json
4454
} >"${notes_file}"
4555
46-
if gh release view "${{ inputs.tag }}" >/dev/null 2>&1; then
47-
echo "Updating existing GitHub release ${{ inputs.tag }}"
48-
gh release edit "${{ inputs.tag }}" --title "${title}" --notes-file "${notes_file}"
56+
if gh release view "${TAG_NAME}" >/dev/null 2>&1; then
57+
echo "Updating existing GitHub release ${TAG_NAME}"
58+
gh release edit "${TAG_NAME}" --title "${title}" --notes-file "${notes_file}"
4959
else
50-
echo "Creating GitHub release ${{ inputs.tag }}"
51-
gh release create "${{ inputs.tag }}" --title "${title}" --notes-file "${notes_file}"
60+
echo "Creating GitHub release ${TAG_NAME}"
61+
gh release create "${TAG_NAME}" --title "${title}" --notes-file "${notes_file}"
5262
fi

0 commit comments

Comments
 (0)