-
Notifications
You must be signed in to change notification settings - Fork 1
Feat/ci release #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Feat/ci release #23
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "permissions": { | ||
| "allow": [ | ||
| "Bash(gh repo view:*)", | ||
| "Bash(gh release list:*)", | ||
| "Bash(gh release view:*)", | ||
| "WebFetch(domain:raw.githubusercontent.com)", | ||
| "WebFetch(domain:github.com)" | ||
| ], | ||
| "deny": [], | ||
| "ask": [] | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
|
|
||
| HOMEBREW_TAP_REPO="STRRL/homebrew-collective" | ||
| CASK_NAME="transcube" | ||
| TEMP_DIR=$(mktemp -d) | ||
|
|
||
| cleanup() { | ||
| rm -rf "$TEMP_DIR" | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| echo "Updating Homebrew cask for $CASK_NAME..." | ||
| echo "" | ||
|
|
||
| if [[ $# -eq 1 ]]; then | ||
| VERSION="$1" | ||
| else | ||
| GIT_TAG=$(git describe --tags --exact-match 2>/dev/null || echo "") | ||
| if [[ -z "$GIT_TAG" ]]; then | ||
| echo "Error: No version specified and no git tag found." | ||
| echo "Usage: $0 [VERSION]" | ||
| echo "Example: $0 0.1.10" | ||
| exit 1 | ||
| fi | ||
| VERSION="${GIT_TAG#v}" | ||
| fi | ||
|
|
||
| echo "Version: $VERSION" | ||
|
|
||
| DMG_NAME="TransCube-${VERSION}-macOS.dmg" | ||
| DMG_PATH="build/bin/$DMG_NAME" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The script assumes it's run from the repository root. If called from a different directory, the DMG path resolution will fail. Make the path resolution robust: SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
DMG_PATH="$PROJECT_ROOT/build/bin/$DMG_NAME"Agent: 🧠 Logic |
||
|
|
||
| if [[ ! -f "$DMG_PATH" ]]; then | ||
| echo "Error: DMG file not found at $DMG_PATH" | ||
| echo "Please run build-and-release.sh first." | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Calculating SHA256 for $DMG_NAME..." | ||
| SHA256=$(shasum -a 256 "$DMG_PATH" | awk '{print $1}') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing validation for SHA256 calculation. If shasum fails or the DMG is corrupted, the variable could be empty or invalid, leading to an invalid Homebrew cask. Add validation: SHA256=$(shasum -a 256 "$DMG_PATH" | awk '{print $1}')
if [[ -z "$SHA256" || ${#SHA256} -ne 64 ]]; then
echo "Error: Failed to calculate valid SHA256 hash"
exit 1
fiAgent: 🧠 Logic |
||
| echo "SHA256: $SHA256" | ||
| echo "" | ||
|
|
||
| echo "Cloning homebrew-collective repository..." | ||
| cd "$TEMP_DIR" | ||
| git clone "https://github.com/$HOMEBREW_TAP_REPO.git" tap | ||
| cd tap | ||
|
|
||
| CASK_FILE="Casks/${CASK_NAME}.rb" | ||
|
|
||
| if [[ ! -f "$CASK_FILE" ]]; then | ||
| echo "Error: Cask file not found at $CASK_FILE" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Updating $CASK_FILE..." | ||
|
|
||
| sed -i '' "s/version \".*\"/version \"$VERSION\"/" "$CASK_FILE" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Consider detecting the OS and adjusting the sed syntax: if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s/version \".*\"/version \"$VERSION\"/" "$CASK_FILE"
sed -i '' "s/sha256 \".*\"/sha256 \"$SHA256\"/" "$CASK_FILE"
else
sed -i "s/version \".*\"/version \"$VERSION\"/" "$CASK_FILE"
sed -i "s/sha256 \".*\"/sha256 \"$SHA256\"/" "$CASK_FILE"
fiAgent: 🧠 Logic |
||
| sed -i '' "s/sha256 \".*\"/sha256 \"$SHA256\"/" "$CASK_FILE" | ||
|
|
||
| if git diff --quiet "$CASK_FILE"; then | ||
| echo "No changes detected in $CASK_FILE. Version might already be up to date." | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "" | ||
| echo "Changes to be committed:" | ||
| git diff "$CASK_FILE" | ||
| echo "" | ||
|
|
||
| git add "$CASK_FILE" | ||
| git commit -m "chore: update $CASK_NAME to $VERSION" | ||
|
|
||
| echo "Pushing to $HOMEBREW_TAP_REPO..." | ||
| git push origin master | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This push operation will fail without proper Git authentication (SSH keys or credential helper). Additionally, the hardcoded 'master' branch may not exist in the target repository (many have migrated to 'main'). Consider:
DEFAULT_BRANCH=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5)
git push origin "$DEFAULT_BRANCH"
|
||
|
|
||
| echo "" | ||
| echo "Successfully updated Homebrew cask to version $VERSION" | ||
| echo "Users can now run: brew upgrade $CASK_NAME" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
set -econflicts with error handling in build-and-release.sh (lines 100-107). When any command fails, the script exits immediately, preventing proper error context from being passed back to the caller. This makes debugging difficult when something fails mid-execution (e.g., after cloning but before pushing).Consider either:
set -eand adding explicit error checking with descriptive messagesset -eEwith an error trap that logs context before exitingAgent: 🧠 Logic