Skip to content

Commit 1a1d38b

Browse files
authored
ci: fix invalid github output format (#105)
fix for this error: ``` Run RELEASE_TYPE="snapshot" 🔄 Creating snapshot version Final version: Project version: 2.2.3-SNAPSHOT Error: Unable to process file command 'output' successfully. Error: Invalid format 'Project version: 2.2.3-SNAPSHOT' ```
1 parent 273b4af commit 1a1d38b

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

.github/workflows/release.yml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,25 +80,40 @@ jobs:
8080
8181
- name: Generate Version
8282
id: version
83+
shell: bash
8384
run: |
85+
set -euo pipefail
86+
8487
RELEASE_TYPE="${{ steps.release-context.outputs.release_type }}"
88+
echo "Release type: $RELEASE_TYPE"
8589
8690
if [[ "$RELEASE_TYPE" == "snapshot" ]]; then
8791
echo "🔄 Creating snapshot version"
88-
# Use snapshot mode
89-
VERSION=$(./gradlew -q currentVersion -Prelease.mode=snapshot)
90-
echo "version=$VERSION" >> $GITHUB_OUTPUT
91-
echo "is_snapshot=true" >> $GITHUB_OUTPUT
92+
RAW_VERSION="$(./gradlew -q currentVersion -Prelease.mode=snapshot)"
93+
IS_SNAPSHOT=true
9294
else
9395
echo "🚀 Creating release version"
94-
# Use release mode
95-
VERSION=$(./gradlew -q currentVersion -Prelease.mode=release)
96-
echo "version=$VERSION" >> $GITHUB_OUTPUT
97-
echo "is_snapshot=false" >> $GITHUB_OUTPUT
96+
RAW_VERSION="$(./gradlew -q currentVersion -Prelease.mode=release)"
97+
IS_SNAPSHOT=false
9898
fi
9999
100+
# Extract the actual version if Gradle prints "Project version: X"
101+
VERSION="$(echo "$RAW_VERSION" | sed -E 's/^[Pp]roject version:[[:space:]]*//')"
102+
# Strip CR just in case
103+
VERSION="${VERSION//$'\r'/}"
104+
100105
echo "Final version: $VERSION"
101106
107+
# Escape characters per GitHub docs
108+
SAFE_VERSION="${VERSION//'%'/'%25'}"
109+
SAFE_VERSION="${SAFE_VERSION//$'\n'/'%0A'}"
110+
SAFE_VERSION="${SAFE_VERSION//$'\r'/'%0D'}"
111+
112+
{
113+
echo "version=$SAFE_VERSION"
114+
echo "is_snapshot=$IS_SNAPSHOT"
115+
} >> "$GITHUB_OUTPUT"
116+
102117
- name: Setup Java
103118
uses: actions/setup-java@v4
104119
with:

0 commit comments

Comments
 (0)