Skip to content

Commit 8aea2bc

Browse files
committed
task: added retry to workflow [skip ci]
1 parent 78b7f04 commit 8aea2bc

1 file changed

Lines changed: 33 additions & 4 deletions

File tree

.github/workflows/publish-nuget.yml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@ name: Publish NuGet Packages
33
on:
44
release:
55
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
tag_name:
9+
description: Release tag to publish, e.g. v4.0.0
10+
required: true
11+
type: string
612

713
permissions:
814
contents: read
915

1016
concurrency:
11-
group: publish-nuget-${{ github.event.release.tag_name }}
17+
group: publish-nuget-${{ github.event.release.tag_name || github.event.inputs.tag_name }}
1218
cancel-in-progress: false
1319

1420
env:
@@ -22,9 +28,31 @@ jobs:
2228
runs-on: ubuntu-latest
2329

2430
steps:
31+
- name: Resolve release tag
32+
id: release
33+
shell: bash
34+
env:
35+
RELEASE_TAG: ${{ github.event.release.tag_name || github.event.inputs.tag_name }}
36+
run: |
37+
set -euo pipefail
38+
39+
if [[ -z "$RELEASE_TAG" ]]; then
40+
echo "::error::Release tag could not be resolved."
41+
exit 1
42+
fi
43+
44+
if [[ ! "$RELEASE_TAG" =~ ^[vV][0-9]+(\.[0-9]+){2}([-.+][0-9A-Za-z.-]+)?$ ]]; then
45+
echo "::error::Release tag '$RELEASE_TAG' must look like v4.0.0."
46+
exit 1
47+
fi
48+
49+
echo "tag=$RELEASE_TAG" >> "$GITHUB_OUTPUT"
50+
echo "Publishing release tag: $RELEASE_TAG"
51+
2552
- name: Checkout repository
2653
uses: actions/checkout@v6
2754
with:
55+
ref: ${{ steps.release.outputs.tag }}
2856
fetch-depth: 0
2957
persist-credentials: false
3058

@@ -56,7 +84,7 @@ jobs:
5684
- name: Validate release tag version
5785
shell: bash
5886
env:
59-
RELEASE_TAG: ${{ github.event.release.tag_name }}
87+
RELEASE_TAG: ${{ steps.release.outputs.tag }}
6088
PACKAGE_VERSION: ${{ steps.gitversion.outputs.majorMinorPatch }}
6189
run: |
6290
set -euo pipefail
@@ -154,9 +182,10 @@ jobs:
154182
done
155183
156184
mapfile -t packages < <(find "$NUGET_OUTPUT" -maxdepth 1 -type f \( -name "*.nupkg" -o -name "*.snupkg" \) -printf "%f\n" | sort)
185+
expected_artifact_count=$(( ${#expected_ids[@]} * 2 ))
157186
158-
if [[ "${#packages[@]}" -ne 4 ]]; then
159-
echo "::error::Expected 4 NuGet package artifacts, but found ${#packages[@]}."
187+
if [[ "${#packages[@]}" -ne "$expected_artifact_count" ]]; then
188+
echo "::error::Expected $expected_artifact_count NuGet package artifacts, but found ${#packages[@]}."
160189
printf '%s\n' "${packages[@]}"
161190
exit 1
162191
fi

0 commit comments

Comments
 (0)