Skip to content

Commit 2b8c8b8

Browse files
committed
fix(build): resolve SemVer packaging and CI/CD workflow issues
- Fix versioning bug preventing package deployment by switching from build metadata format (2.0.0+date.sha) to pre-release format (2.0.0-nightly.date.sha) for NuGet filename compatibility - Eliminate duplicate CI/CD runs by removing feature/* branches from push triggers and implementing PR-driven deployments for feature branches - Update GitHub Actions workflow branch name detection using conditional expressions for both push and pull_request events - Ensure proper SemVer 2.0 compliance where feature branch packages (2.0.0-source-generator-*) rank higher than nightly builds (2.0.0-nightly.*) due to lexicographic ordering - Maintain backward compatibility with existing versioning strategy while enabling reliable automated package publishing Affects packages: - LocalStack.Client - LocalStack.Client.Extensions
1 parent ec8c53a commit 2b8c8b8

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

.github/workflows/ci-cd.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77
- LICENSE
88
branches:
99
- "master"
10-
- "feature/*"
1110
pull_request:
1211
paths-ignore:
1312
- "**.md"
@@ -124,8 +123,8 @@ jobs:
124123
needs: build-and-test
125124
if: |
126125
github.repository == 'localstack-dotnet/localstack-dotnet-client' &&
127-
github.event_name == 'push' &&
128-
(github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/feature/'))
126+
((github.event_name == 'push' && github.ref == 'refs/heads/master') ||
127+
(github.event_name == 'pull_request' && startsWith(github.head_ref, 'feature/')))
129128
env:
130129
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
131130

@@ -186,7 +185,7 @@ jobs:
186185
--package-source github \
187186
--package-id LocalStack.Client \
188187
--use-directory-props-version true \
189-
--branch-name ${{ github.ref_name }} \
188+
--branch-name ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }} \
190189
--package-secret ${{ secrets.GITHUB_TOKEN }}
191190
192191
- name: "Prepare Extensions Project"
@@ -204,13 +203,13 @@ jobs:
204203
--package-source github \
205204
--package-id LocalStack.Client.Extensions \
206205
--use-directory-props-version true \
207-
--branch-name ${{ github.ref_name }} \
206+
--branch-name ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }} \
208207
--package-secret ${{ secrets.GITHUB_TOKEN }}
209208
210209
- name: "Upload Package Artifacts"
211210
uses: actions/upload-artifact@v4
212211
with:
213-
name: "packages-${{ github.ref_name }}-${{ github.run_number }}"
212+
name: "packages-${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}-${{ github.run_number }}"
214213
path: |
215214
artifacts/*.nupkg
216215
artifacts/*.snupkg
@@ -221,7 +220,7 @@ jobs:
221220
echo "📦 Generating build summary..."
222221
./build.sh --target workflow-summary \
223222
--use-directory-props-version true \
224-
--branch-name ${{ github.ref_name }}
223+
--branch-name ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}
225224
226225
- name: "Cleanup Configuration"
227226
if: always()

build/LocalStack.Build/BuildContext.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,16 +281,16 @@ private string GetDynamicVersionFromProps(string versionPropertyName)
281281
string commitSha = GetGitCommitSha();
282282
string safeBranchName = BranchName.Replace('/', '-').Replace('_', '-');
283283

284-
// Simplified NuGet-compliant version format
284+
// SemVer-compliant pre-release versioning
285285
if (BranchName == "master")
286286
{
287-
// Nightly off main — use build metadata
288-
return $"{baseVersion}+{buildDate}.{commitSha}";
287+
// Master nightlies: 2.0.0-nightly.20250725.sha
288+
return $"{baseVersion}-nightly.{buildDate}.{commitSha}";
289289
}
290290
else
291291
{
292-
// Feature branch / preview line
293-
return $"{baseVersion}.{safeBranchName}.{buildDate}.{commitSha}";
292+
// Feature branches: 2.0.0-feature-name.20250725.sha
293+
return $"{baseVersion}-{safeBranchName}.{buildDate}.{commitSha}";
294294
}
295295
}
296296

0 commit comments

Comments
 (0)