Skip to content

Commit a7f9c5c

Browse files
committed
fix: improve release creation with better error handling and file list building
1 parent 0f9356e commit a7f9c5c

1 file changed

Lines changed: 24 additions & 14 deletions

File tree

.github/workflows/build-cli.yml

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
- name: Create or Update Release
6464
if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main'
6565
run: |
66-
set -e # Exit on error
66+
set -ex # Exit on error, print commands
6767
6868
VERSION="${{ steps.version.outputs.version }}"
6969
TAG="v${VERSION}"
@@ -84,14 +84,14 @@ jobs:
8484
# Copy all binary files from dist subdirectories
8585
echo "=== Searching for binary files ==="
8686
# The binaries are in dist/{platform}/bin/opencode or dist/{platform}/bin/opencode.exe
87-
find packages/opencode/dist/ -type f -name "opencode" -o -name "opencode.exe" 2>/dev/null | while read -r file; do
87+
find packages/opencode/dist/ -type f \( -name "opencode" -o -name "opencode.exe" \) 2>/dev/null | while read -r file; do
8888
echo "Found: $file"
8989
# Copy with platform-specific name
9090
platform=$(echo "$file" | sed 's|packages/opencode/dist/||' | sed 's|/bin/opencode.*||')
9191
if [[ "$file" == *".exe" ]]; then
92-
cp "$file" "/tmp/release-assets/opencode-${platform}.exe" 2>/dev/null || echo "Failed to copy: $file"
92+
cp -v "$file" "/tmp/release-assets/opencode-${platform}.exe" || echo "Failed to copy: $file"
9393
else
94-
cp "$file" "/tmp/release-assets/opencode-${platform}" 2>/dev/null || echo "Failed to copy: $file"
94+
cp -v "$file" "/tmp/release-assets/opencode-${platform}" || echo "Failed to copy: $file"
9595
fi
9696
done
9797
@@ -119,20 +119,25 @@ jobs:
119119
120120
# Check if release exists
121121
echo "=== Checking if release exists ==="
122-
set +e
123-
gh release view "$TAG" --repo ${{ github.repository }} 2>&1
124-
RELEASE_EXISTS=$?
125-
set -e
126-
127-
if [ $RELEASE_EXISTS -ne 0 ]; then
122+
if ! gh release view "$TAG" --repo ${{ github.repository }} 2>&1; then
128123
echo "Release $TAG does not exist, creating..."
129-
# Create release with all assets - use explicit file list
124+
125+
# Build file list for release
126+
FILE_LIST=""
127+
for f in /tmp/release-assets/*; do
128+
if [ -f "$f" ]; then
129+
FILE_LIST="$FILE_LIST $f"
130+
fi
131+
done
132+
echo "Files to upload: $FILE_LIST"
133+
134+
# Create release with all assets
130135
gh release create "$TAG" \
131136
--repo ${{ github.repository }} \
132137
--title "OpenCode CLI $TAG" \
133138
--prerelease \
134139
--generate-notes \
135-
$(ls -1 /tmp/release-assets/ | sed "s|^|/tmp/release-assets/|" | tr '\n' ' ')
140+
$FILE_LIST
136141
else
137142
echo "Release $TAG already exists, uploading assets..."
138143
# Upload assets to existing release
@@ -144,8 +149,13 @@ jobs:
144149
done
145150
fi
146151
147-
echo "=== Release $TAG completed ==="
148-
gh release view "$TAG" --repo ${{ github.repository }} 2>&1 || echo "Failed to view release"
152+
echo "=== Verifying release was created ==="
153+
gh release view "$TAG" --repo ${{ github.repository }} 2>&1 || {
154+
echo "ERROR: Release was not created!"
155+
exit 1
156+
}
157+
158+
echo "=== Release $TAG completed successfully ==="
149159
env:
150160
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
151161

0 commit comments

Comments
 (0)