Skip to content

Commit 3bfc1ce

Browse files
committed
release: codesign macOS and generate Homebrew bottles
1 parent af8e198 commit 3bfc1ce

File tree

1 file changed

+79
-3
lines changed

1 file changed

+79
-3
lines changed

.github/workflows/release.yml

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ jobs:
7070
- name: Build release binary
7171
run: cargo build --release --target ${{ matrix.target }} --verbose
7272

73+
- name: Code sign macOS binary
74+
if: startsWith(matrix.os, 'macos')
75+
run: |
76+
codesign --force --sign - target/${{ matrix.target }}/release/sshdb
77+
7378
- name: Prepare release asset (Windows)
7479
if: matrix.os == 'windows-latest'
7580
shell: pwsh
@@ -146,30 +151,101 @@ jobs:
146151
TAR_URL="https://github.com/ruphy/sshdb/archive/refs/tags/v${VERSION}.tar.gz"
147152
SHA256=$(curl -L "$TAR_URL" | shasum -a 256 | awk '{print $1}')
148153
154+
# Calculate checksums for bottle files
155+
MACOS_X86_64_TAR="artifacts/sshdb-macos-x86_64/sshdb-macos-x86_64.tar.gz"
156+
MACOS_ARM64_TAR="artifacts/sshdb-macos-aarch64/sshdb-macos-aarch64.tar.gz"
157+
LINUX_X86_64_TAR="artifacts/sshdb-linux-x86_64/sshdb-linux-x86_64.tar.gz"
158+
159+
MACOS_X86_64_SHA=""
160+
MACOS_ARM64_SHA=""
161+
LINUX_X86_64_SHA=""
162+
163+
if [ -f "${MACOS_X86_64_TAR}" ]; then
164+
MACOS_X86_64_SHA=$(shasum -a 256 "${MACOS_X86_64_TAR}" | awk '{print $1}')
165+
fi
166+
if [ -f "${MACOS_ARM64_TAR}" ]; then
167+
MACOS_ARM64_SHA=$(shasum -a 256 "${MACOS_ARM64_TAR}" | awk '{print $1}')
168+
fi
169+
if [ -f "${LINUX_X86_64_TAR}" ]; then
170+
LINUX_X86_64_SHA=$(shasum -a 256 "${LINUX_X86_64_TAR}" | awk '{print $1}')
171+
fi
172+
149173
TAP_DIR=$(mktemp -d)
150174
git config --global user.name "sshdb-release-bot"
151175
git config --global user.email "[email protected]"
152176
git clone "https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/ruphy/homebrew-sshdb" "${TAP_DIR}"
153177
mkdir -p "${TAP_DIR}/Formula"
154178
155-
cat > "${TAP_DIR}/Formula/sshdb.rb" <<EOF
179+
# Generate formula with bottle block
180+
{
181+
cat <<EOFRUBY
156182
class Sshdb < Formula
157183
desc "Keyboard-first SSH library and launcher TUI"
158184
homepage "https://github.com/ruphy/sshdb"
159185
url "${TAR_URL}"
160186
sha256 "${SHA256}"
161187
license "GPL-3.0-or-later"
162188
depends_on "rust" => :build
189+
EOFRUBY
163190
191+
if [ -n "${MACOS_X86_64_SHA}" ] || [ -n "${MACOS_ARM64_SHA}" ] || [ -n "${LINUX_X86_64_SHA}" ]; then
192+
cat <<EOFRUBY
193+
bottle do
194+
root_url "https://github.com/ruphy/sshdb/releases/download/v${VERSION}"
195+
EOFRUBY
196+
if [ -n "${MACOS_ARM64_SHA}" ]; then
197+
cat <<EOFRUBY
198+
sha256 cellar: :any_skip_relocation, arm64_sonoma: "${MACOS_ARM64_SHA}"
199+
sha256 cellar: :any_skip_relocation, arm64_ventura: "${MACOS_ARM64_SHA}"
200+
sha256 cellar: :any_skip_relocation, arm64_monterey: "${MACOS_ARM64_SHA}"
201+
EOFRUBY
202+
fi
203+
if [ -n "${MACOS_X86_64_SHA}" ]; then
204+
cat <<EOFRUBY
205+
sha256 cellar: :any_skip_relocation, x86_64_sonoma: "${MACOS_X86_64_SHA}"
206+
sha256 cellar: :any_skip_relocation, x86_64_ventura: "${MACOS_X86_64_SHA}"
207+
sha256 cellar: :any_skip_relocation, x86_64_monterey: "${MACOS_X86_64_SHA}"
208+
EOFRUBY
209+
fi
210+
if [ -n "${LINUX_X86_64_SHA}" ]; then
211+
cat <<EOFRUBY
212+
sha256 cellar: :any_skip_relocation, x86_64_linux: "${LINUX_X86_64_SHA}"
213+
EOFRUBY
214+
fi
215+
cat <<EOFRUBY
216+
end
217+
EOFRUBY
218+
fi
219+
220+
cat <<EOFRUBY
164221
def install
165-
system "cargo", "install", *std_cargo_args
222+
if OS.mac?
223+
if Hardware::CPU.arm?
224+
bin_path = "sshdb-macos-aarch64.tar.gz"
225+
else
226+
bin_path = "sshdb-macos-x86_64.tar.gz"
227+
end
228+
elsif OS.linux?
229+
bin_path = "sshdb-linux-x86_64.tar.gz"
230+
end
231+
232+
if bin_path
233+
bin_url = "https://github.com/ruphy/sshdb/releases/download/v\#{version}/\#{bin_path}"
234+
system "curl", "-L", "-o", bin_path, bin_url
235+
system "tar", "xzf", bin_path
236+
bin.install "sshdb"
237+
rm bin_path
238+
else
239+
system "cargo", "install", *std_cargo_args
240+
end
166241
end
167242
168243
test do
169244
system "#{bin}/sshdb", "--help"
170245
end
171246
end
172-
EOF
247+
EOFRUBY
248+
} > "${TAP_DIR}/Formula/sshdb.rb"
173249
174250
cd "${TAP_DIR}"
175251
git add Formula/sshdb.rb

0 commit comments

Comments
 (0)