Skip to content

Commit a2e570d

Browse files
committed
fix(ci): Support version input with or without v prefix
- Accept both v1.0.0-preview and 1.0.0-preview formats - Automatically remove v prefix for NuGet version - Ensure git tag always has v prefix - Add version preparation step to normalize inputs Usage examples: - Input: v1.0.2-preview → NuGet: 1.0.2-preview, Tag: v1.0.2-preview - Input: 1.0.2-preview → NuGet: 1.0.2-preview, Tag: v1.0.2-preview
1 parent 76887c4 commit a2e570d

1 file changed

Lines changed: 25 additions & 13 deletions

File tree

.github/workflows/main.yml

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
workflow_dispatch:
88
inputs:
99
version:
10-
description: 'Release version to create (without v prefix, e.g., 1.0.0-preview.2)'
10+
description: 'Release version to create (e.g., v1.0.0-preview or 1.0.0-preview)'
1111
required: true
1212

1313
jobs:
@@ -27,6 +27,18 @@ jobs:
2727
- name: Install UPX
2828
run: brew install upx
2929

30+
- name: Prepare version strings
31+
if: ${{ github.event.inputs.version != '' }}
32+
id: version
33+
run: |
34+
VERSION="${{ github.event.inputs.version }}"
35+
# Remove 'v' prefix if present
36+
VERSION_NO_V="${VERSION#v}"
37+
echo "nuget_version=${VERSION_NO_V}" >> $GITHUB_OUTPUT
38+
echo "git_tag=v${VERSION_NO_V}" >> $GITHUB_OUTPUT
39+
echo "NuGet Version: ${VERSION_NO_V}"
40+
echo "Git Tag: v${VERSION_NO_V}"
41+
3042
- name: Build Package (CI)
3143
if: ${{ github.event.inputs.version == '' }}
3244
run: |
@@ -40,19 +52,19 @@ jobs:
4052
4153
- name: Build Package (CD)
4254
if: ${{ github.event.inputs.version != '' }}
43-
run: dotnet build -t:Pack src/PublishAotCompressed.macOS.nuproj -p:Version=${{ github.event.inputs.version }}
55+
run: dotnet build -t:Pack src/PublishAotCompressed.macOS.nuproj -p:Version=${{ steps.version.outputs.nuget_version }}
4456

4557
- name: Archive NuGet Package
4658
if: ${{ github.event.inputs.version != '' }}
4759
uses: actions/upload-artifact@v4
4860
with:
49-
name: PublishAotCompressed.macOS.${{ github.event.inputs.version }}.nupkg
50-
path: src/bin/Debug/PublishAotCompressed.macOS.${{ github.event.inputs.version }}.nupkg
61+
name: PublishAotCompressed.macOS.${{ steps.version.outputs.nuget_version }}.nupkg
62+
path: src/bin/Debug/PublishAotCompressed.macOS.${{ steps.version.outputs.nuget_version }}.nupkg
5163

5264
- name: Publish to NuGet.org
5365
if: ${{ github.event.inputs.version != '' }}
5466
run: |
55-
dotnet nuget push src/bin/Debug/PublishAotCompressed.macOS.${{ github.event.inputs.version }}.nupkg \
67+
dotnet nuget push src/bin/Debug/PublishAotCompressed.macOS.${{ steps.version.outputs.nuget_version }}.nupkg \
5668
--api-key ${{ secrets.NUGET_API_KEY }} \
5769
--source https://api.nuget.org/v3/index.json \
5870
--skip-duplicate
@@ -62,23 +74,23 @@ jobs:
6274
run: |
6375
git config user.name github-actions
6476
git config user.email github-actions@github.com
65-
git tag v${{ github.event.inputs.version }}
66-
git push origin v${{ github.event.inputs.version }}
77+
git tag ${{ steps.version.outputs.git_tag }}
78+
git push origin ${{ steps.version.outputs.git_tag }}
6779
6880
- name: Create GitHub Release
6981
if: ${{ github.event.inputs.version != '' }}
7082
uses: softprops/action-gh-release@v1
7183
with:
72-
tag_name: v${{ github.event.inputs.version }}
73-
name: v${{ github.event.inputs.version }}
84+
tag_name: ${{ steps.version.outputs.git_tag }}
85+
name: ${{ steps.version.outputs.git_tag }}
7486
body: |
75-
## PublishAotCompressed.macOS v${{ github.event.inputs.version }}
87+
## PublishAotCompressed.macOS ${{ steps.version.outputs.git_tag }}
7688
7789
Automatic UPX compression for .NET Native AOT cross-compilation from macOS.
7890
7991
### Installation
8092
```xml
81-
<PackageReference Include="PublishAotCompressed.macOS" Version="${{ github.event.inputs.version }}" />
93+
<PackageReference Include="PublishAotCompressed.macOS" Version="${{ steps.version.outputs.nuget_version }}" />
8294
```
8395
8496
### Quick Start
@@ -87,7 +99,7 @@ jobs:
8799
```
88100
89101
See [README.md](https://github.com/interface95/PublishAotCompressed.macOS/blob/master/README.md) for details.
90-
files: src/bin/Debug/PublishAotCompressed.macOS.${{ github.event.inputs.version }}.nupkg
91-
prerelease: ${{ contains(github.event.inputs.version, 'preview') || contains(github.event.inputs.version, 'alpha') || contains(github.event.inputs.version, 'beta') }}
102+
files: src/bin/Debug/PublishAotCompressed.macOS.${{ steps.version.outputs.nuget_version }}.nupkg
103+
prerelease: ${{ contains(steps.version.outputs.nuget_version, 'preview') || contains(steps.version.outputs.nuget_version, 'alpha') || contains(steps.version.outputs.nuget_version, 'beta') }}
92104
env:
93105
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)