Skip to content

Commit 66d45f2

Browse files
fix: handle tags without 'v' prefix in deploy workflow
The release tag '2.0.0' (no 'v') caused all deploy conditions (startsWith 'refs/tags/v') to evaluate false, skipping Pack, Upload Artifacts, and the entire deploy job. - Change all conditions to startsWith(github.ref, 'refs/tags/') - Replace hardcoded substring(11) with regex to strip 'refs/tags/v?' prefix, correctly handling both 'v2.0.0' and '2.0.0' tag formats
1 parent 79e5f64 commit 66d45f2

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525
- name: Set Version
2626
run: |
2727
echo "${{ github.ref }}"
28-
if ("${{ github.ref }}".startsWith("refs/tags/v")) {
29-
$tagVersion = "${{ github.ref }}".substring(11)
28+
if ("${{ github.ref }}".startsWith("refs/tags/")) {
29+
$tagVersion = ("${{ github.ref }}" -replace "^refs/tags/v?", "")
3030
echo "buildVersion=$tagVersion.${{ github.run_number }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
3131
echo "nugetVersion=$tagVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
3232
echo "preRelease=false" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
@@ -39,17 +39,17 @@ jobs:
3939
- name: Test
4040
run: dotnet test --no-build --configuration Release --verbosity normal
4141
- name: Pack
42-
if: startsWith(github.ref, 'refs/tags/v')
42+
if: startsWith(github.ref, 'refs/tags/')
4343
run: dotnet pack -p:PackageVersion=${{ env.nugetVersion }} --configuration Release -o ${{env.DOTNET_ROOT}}/IntelliTect.MultitoolPack --no-build
4444
- name: Upload Artifacts
45-
if: startsWith(github.ref, 'refs/tags/v')
45+
if: startsWith(github.ref, 'refs/tags/')
4646
uses: actions/upload-artifact@v6
4747
with:
4848
name: NuGet
4949
path: ${{env.DOTNET_ROOT}}/IntelliTect.MultitoolPack
5050

5151
deploy:
52-
if: startsWith(github.ref, 'refs/tags/v')
52+
if: startsWith(github.ref, 'refs/tags/')
5353
runs-on: ubuntu-latest
5454
needs: build-and-test
5555
environment:
@@ -65,7 +65,7 @@ jobs:
6565
- name: Get tag version
6666
id: tag-version
6767
run: |
68-
$tagVersion = "${{ github.ref }}".substring(11)
68+
$tagVersion = ("${{ github.ref }}" -replace "^refs/tags/v?", "")
6969
echo "TAG_VERSION=$tagVersion" >> $env:GITHUB_OUTPUT
7070
- name: NuGet login
7171
uses: NuGet/login@v1

0 commit comments

Comments
 (0)