Skip to content

Commit 95bae9b

Browse files
committed
fix: improve CI workflow for Canton release automation and add cleanup steps for temporary files in update.sh
1 parent a839142 commit 95bae9b

File tree

1 file changed

+48
-21
lines changed

1 file changed

+48
-21
lines changed

update.sh

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ else
5757
fi
5858
echo "SHA256: $SHA256"
5959

60+
# Cleanup
61+
rm -f canton-release.tar.gz
62+
6063
# Update formula
6164
echo "Updating Formula/canton.rb..."
6265
# Use different sed syntax for macOS vs Linux
@@ -74,26 +77,49 @@ fi
7477

7578
# Only commit and create release if running in CI (GITHUB_TOKEN is set)
7679
if [ -n "$GITHUB_TOKEN" ]; then
77-
echo "Running in CI, committing changes and creating release..."
78-
79-
# Commit formula changes
80+
echo "Running in CI, checking for changes and creating release..."
81+
82+
# Configure git
8083
git config --local user.email "action@github.com"
8184
git config --local user.name "GitHub Action"
85+
86+
# Add formula changes
8287
git add Formula/canton.rb
83-
git commit -m "feat: update Canton to $LATEST_VERSION
88+
89+
# Check if there are any changes to commit
90+
if git diff --cached --quiet; then
91+
echo "No changes detected in Formula/canton.rb, skipping commit"
92+
else
93+
echo "Changes detected, committing and pushing..."
94+
# Commit formula changes
95+
if ! git commit -m "feat: update Canton to $LATEST_VERSION
8496
8597
Release URL: $LATEST_URL
8698
87-
🤖 Generated with GitHub Actions"
88-
git push
89-
90-
# Create GitHub release and tag
91-
git tag "canton-$LATEST_VERSION"
92-
git push origin "canton-$LATEST_VERSION"
93-
94-
gh release create "canton-$LATEST_VERSION" \
95-
--title "Canton $LATEST_VERSION" \
96-
--notes "Homebrew formula updated to Canton version $LATEST_VERSION.
99+
🤖 Generated with GitHub Actions"; then
100+
echo "Failed to commit changes"
101+
exit 1
102+
fi
103+
104+
if ! git push; then
105+
echo "Failed to push changes"
106+
exit 1
107+
fi
108+
109+
# Create GitHub release and tag
110+
if ! git tag "canton-$LATEST_VERSION"; then
111+
echo "Failed to create tag"
112+
exit 1
113+
fi
114+
115+
if ! git push origin "canton-$LATEST_VERSION"; then
116+
echo "Failed to push tag"
117+
exit 1
118+
fi
119+
120+
if ! gh release create "canton-$LATEST_VERSION" \
121+
--title "Canton $LATEST_VERSION" \
122+
--notes "Homebrew formula updated to Canton version $LATEST_VERSION.
97123
98124
This release tracks the Canton snapshot release from Digital Asset:
99125
- Original Release: $LATEST_URL
@@ -111,17 +137,18 @@ brew install 0xsend/homebrew-canton/canton
111137
\`\`\`
112138
113139
🤖 Auto-generated by GitHub Actions" \
114-
--latest
115-
116-
echo "Successfully created release for Canton $LATEST_VERSION"
140+
--latest; then
141+
echo "Failed to create GitHub release"
142+
exit 1
143+
fi
144+
145+
echo "Successfully created release for Canton $LATEST_VERSION"
146+
fi
117147
else
118148
echo "Running locally, formula updated but not committing"
119149
echo "Updated formula to Canton $LATEST_VERSION"
120150
echo "- URL: $DOWNLOAD_URL"
121151
echo "- SHA256: $SHA256"
122152
fi
123153

124-
# Cleanup
125-
rm -f canton-release.tar.gz
126-
127-
echo "=== Update complete ==="
154+
echo "=== Update complete ==="

0 commit comments

Comments
 (0)