Skip to content

Commit e1cb906

Browse files
committed
fix(ci): normalize tag input in release workflow
The manual workflow_dispatch failed when tag was entered without the "v" prefix (e.g. "0.1.1" instead of "v0.1.1"). Add a resolve step that normalizes the tag consistently and pass it as a job output to downstream jobs. Signed-off-by: Mohammod Al Amin Ashik <maa.ashik00@gmail.com>
1 parent 083f687 commit e1cb906

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

.github/workflows/release.yml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,31 @@ jobs:
199199
runs-on: ubuntu-latest
200200
permissions:
201201
contents: write
202+
outputs:
203+
tag: ${{ steps.resolve.outputs.tag }}
202204
steps:
205+
# Normalize the tag: ensure it starts with "v" whether the user
206+
# typed "0.1.1" or "v0.1.1" in the workflow_dispatch input.
207+
- name: Resolve tag
208+
id: resolve
209+
run: |
210+
RAW="${{ inputs.tag || needs.release-please.outputs.tag_name }}"
211+
TAG="${RAW#v}" # strip leading v if present
212+
TAG="v${TAG}" # re-add it consistently
213+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
214+
203215
- name: Validate existing release has assets
204216
if: inputs.tag != ''
205217
env:
206218
GH_TOKEN: ${{ github.token }}
207219
run: |
208-
ASSET_COUNT=$(gh release view "${{ inputs.tag }}" \
220+
TAG="${{ steps.resolve.outputs.tag }}"
221+
ASSET_COUNT=$(gh release view "$TAG" \
209222
--repo "${{ github.repository }}" \
210223
--json assets --jq '.assets | length')
211-
echo "Release ${{ inputs.tag }} has $ASSET_COUNT asset(s)"
224+
echo "Release $TAG has $ASSET_COUNT asset(s)"
212225
if [ "$ASSET_COUNT" -eq 0 ]; then
213-
echo "::error::Release ${{ inputs.tag }} has no assets to sign"
226+
echo "::error::Release $TAG has no assets to sign"
214227
exit 1
215228
fi
216229
@@ -221,7 +234,7 @@ jobs:
221234
env:
222235
GH_TOKEN: ${{ github.token }}
223236
run: |
224-
TAG="${{ inputs.tag || needs.release-please.outputs.tag_name }}"
237+
TAG="${{ steps.resolve.outputs.tag }}"
225238
REPO="${{ github.repository }}"
226239
mkdir -p artifacts sigs
227240
@@ -246,7 +259,7 @@ jobs:
246259
env:
247260
GH_TOKEN: ${{ github.token }}
248261
run: |
249-
gh release edit "${{ inputs.tag || needs.release-please.outputs.tag_name }}" \
262+
gh release edit "${{ steps.resolve.outputs.tag }}" \
250263
--draft=false \
251264
--repo "${{ github.repository }}"
252265
@@ -266,7 +279,7 @@ jobs:
266279
env:
267280
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
268281
run: |
269-
TAG="${{ inputs.tag || needs.release-please.outputs.tag_name }}"
282+
TAG="${{ needs.publish-release.outputs.tag || needs.release-please.outputs.tag_name }}"
270283
VERSION="${TAG#v}"
271284
BASE_URL="https://github.com/${{ github.repository }}/releases/download/v${VERSION}"
272285
@@ -363,7 +376,7 @@ jobs:
363376
env:
364377
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
365378
run: |
366-
TAG="${{ inputs.tag || needs.release-please.outputs.tag_name }}"
379+
TAG="${{ needs.publish-release.outputs.tag || needs.release-please.outputs.tag_name }}"
367380
mkdir -p artifacts
368381
# Download all .deb files from the release
369382
gh release download "$TAG" --pattern "*.deb" --dir artifacts

0 commit comments

Comments
 (0)