-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-brew-sqlk.sh
More file actions
64 lines (50 loc) · 1.92 KB
/
Copy pathcreate-brew-sqlk.sh
File metadata and controls
64 lines (50 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# # Get project metadata from Cargo.toml
PROJECT_NAME=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].name')
VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
DESC=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].description')
HOMEPAGE=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].repository')
# Build the release binary
cargo build --release -p "${PROJECT_NAME}"
# Navigate to the release folder
cd target/release
# Create the compressed tarball
tar -czf "${PROJECT_NAME}-mac.tar.gz" "${PROJECT_NAME}"
# Calculate the SHA256 hash of the tarball
HASH=$(shasum -a 256 "${PROJECT_NAME}-mac.tar.gz" | awk '{print $1}')
# Create the GitHub Release and attach the tarball
gh release create "v${VERSION}" \
--title "Release v${VERSION}" \
--notes "${DESC}" \
"./${PROJECT_NAME}-mac.tar.gz"
# Go back to the project root
cd ../..
# ---------------------------------------------
# Now, update the Homebrew tap repository
# ---------------------------------------------
# Clone your Homebrew tap repo (if it doesn't already exist)
git clone https://github.com/sethrollinsbah/homebrew-sqlk
# Navigate into the tap repo
cd homebrew-sqlk
# Remove the old formula file (if it exists)
rm -f "${PROJECT_NAME}.rb"
PROJECT_CLASS_NAME=$(echo "$PROJECT_NAME" | awk '{print toupper(substr($0,1,1))substr($0,2)}')
# Create the new Homebrew formula file with dynamic values
cat << EOF > ${PROJECT_NAME}.rb
class ${PROJECT_CLASS_NAME} < Formula
desc "${DESC}"
homepage "${HOMEPAGE}"
url "https://github.com/sethrollinsbah/sqlk/releases/download/v${VERSION}/${PROJECT_NAME}-mac.tar.gz"
sha256 "${HASH}"
version "${VERSION}"
def install
bin.install "${PROJECT_NAME}"
end
end
EOF
# Stage, commit, and push the new formula file
git add .
git commit -m "chore(formula): automated update to v${VERSION}"
git push
cd ..
rm -rf ./homebrew-sqlk