Skip to content

Commit 90af0c4

Browse files
committed
fix(ci): create packages with correct pre-release versions
- Move package creation after semantic-release to use correct version from git tags - Skip project file version updates for pre-release branches - Skip git commits for pre-release branches (only create tags and GitHub releases) - Use -p:PackageVersion parameter to set correct version during pack This should create v1.0.0-pre.3 packages with the correct pre-release version.
1 parent d7a60f4 commit 90af0c4

File tree

2 files changed

+55
-5
lines changed

2 files changed

+55
-5
lines changed

.github/workflows/semantic-release.yml

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,30 @@ jobs:
8686
- name: Build and package .NET projects
8787
run: |
8888
echo "🔨 Building .NET projects..."
89+
90+
# Determine if this is a pre-release branch
91+
BRANCH_NAME=${GITHUB_REF#refs/heads/}
92+
if [[ $BRANCH_NAME == release/* ]]; then
93+
echo "📦 Pre-release branch detected: $BRANCH_NAME"
94+
# For pre-release, we'll set version after semantic-release determines it
95+
IS_PRERELEASE=true
96+
else
97+
echo "🚀 Main branch detected: $BRANCH_NAME"
98+
IS_PRERELEASE=false
99+
fi
100+
89101
# Build only the main CLI project and templates, skip tests for now
90102
dotnet restore pks-cli/src/pks-cli.csproj
91103
dotnet build pks-cli/src/pks-cli.csproj --configuration Release
92-
dotnet pack pks-cli/src/pks-cli.csproj --configuration Release --output ./packages --no-build
93104
94105
# Build and pack template projects
95106
find pks-cli/templates -name "*.csproj" -type f | while read -r template; do
96107
echo "Building template: $template"
97108
dotnet build "$template" --configuration Release
98-
dotnet pack "$template" --configuration Release --output ./packages --no-build
99109
done
100110
111+
echo "Build completed, packages will be created after semantic-release determines version"
112+
101113
- name: Run semantic-release
102114
id: semantic
103115
env:
@@ -106,6 +118,43 @@ jobs:
106118
echo "🚀 Running semantic release..."
107119
npx semantic-release
108120
121+
- name: Create packages with correct version
122+
if: success()
123+
run: |
124+
# Get the latest tag (which semantic-release just created)
125+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
126+
127+
if [ -n "$LATEST_TAG" ]; then
128+
# Remove 'v' prefix to get the version
129+
VERSION=${LATEST_TAG#v}
130+
echo "📦 Creating packages with version: $VERSION"
131+
132+
# Create packages directory
133+
mkdir -p packages
134+
135+
# Pack CLI project with the correct version
136+
dotnet pack pks-cli/src/pks-cli.csproj \
137+
--configuration Release \
138+
--output ./packages \
139+
--no-build \
140+
-p:PackageVersion=$VERSION
141+
142+
# Pack template projects with the correct version
143+
find pks-cli/templates -name "*.csproj" -type f | while read -r template; do
144+
echo "Packing template: $template with version $VERSION"
145+
dotnet pack "$template" \
146+
--configuration Release \
147+
--output ./packages \
148+
--no-build \
149+
-p:PackageVersion=$VERSION
150+
done
151+
152+
echo "✅ Packages created successfully with version $VERSION"
153+
ls -la packages/
154+
else
155+
echo "❌ No release tag found, skipping package creation"
156+
fi
157+
109158
- name: Upload packages to release
110159
if: success()
111160
env:

.releaserc.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,19 @@
153153
[
154154
"@semantic-release/exec",
155155
{
156-
"prepareCmd": "echo '${nextRelease.version}' > .version && ./scripts/update-version.sh ${nextRelease.version}"
156+
"prepareCmd": "echo '${nextRelease.version}' > .version && if [[ '${nextRelease.channel}' == '' ]]; then ./scripts/update-version.sh ${nextRelease.version}; else echo 'Skipping version update for pre-release ${nextRelease.version}'; fi"
157157
}
158158
],
159159
[
160160
"@semantic-release/git",
161161
{
162162
"assets": [
163163
"CHANGELOG.md",
164-
"src/**/*.csproj",
164+
"src/**/*.csproj",
165165
"templates/**/*.csproj"
166166
],
167-
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
167+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
168+
"successCmd": "if [[ '${nextRelease.channel}' != '' ]]; then echo 'Skipping git commit for pre-release'; exit 1; fi"
168169
}
169170
],
170171
[

0 commit comments

Comments
 (0)