Skip to content

Commit 129e26a

Browse files
committed
feat: add Homebrew tap support
1 parent 108db57 commit 129e26a

File tree

5 files changed

+130
-10
lines changed

5 files changed

+130
-10
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Everybody should be able to help. Here's how you can make this project more
44
awesome:
55

6-
1. [Fork the repository](https://github.com/ssc/dtk/fork_select);
6+
1. [Fork the repository](https://github.com/ssc-php/dtk/fork_select);
77
2. create your own branch from `main`: `git checkout -b <ticket-id>/<ticket-title>` (or `<type>/<title>` if you have no ticket);
88
3. make your changes and don't forget to:
99
* check that the tests pass;
@@ -120,7 +120,7 @@ Types are the same as for branch naming.
120120
Track the upstream (original) repository:
121121

122122
```console
123-
git remote add upstream https://github.com/ssc/dtk.git
123+
git remote add upstream https://github.com/ssc-php/dtk.git
124124
```
125125

126126
Then, before publishing your changes, get the upstream changes:

README.md

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,22 @@ All commands are configurable to fit any workflow, with support for:
4242

4343
## Getting started
4444

45-
Download the binary for your platform from the [releases page](https://github.com/ssc/dtk/releases):
45+
### Homebrew (macOS and Linux)
46+
47+
```console
48+
brew tap ssc-php/dtk
49+
brew install dtk
50+
```
51+
52+
To upgrade:
53+
54+
```console
55+
brew upgrade dtk
56+
```
57+
58+
### Manual install
59+
60+
Download the binary for your platform from the [releases page](https://github.com/ssc-php/dtk/releases):
4661

4762
| Platform | Binary | Examples |
4863
|----------------|--------------------------|-----------------------------------------|
@@ -55,15 +70,15 @@ Download the binary for your platform from the [releases page](https://github.co
5570
<summary>**🐧 On Linux:**</summary>
5671

5772
```console
58-
curl --proto '=https' --tlsv1.2 -fsSL "https://github.com/ssc/dtk/releases/latest/download/dtk-linux-x86_64" -o /tmp/dtk
73+
curl --proto '=https' --tlsv1.2 -fsSL "https://github.com/ssc-php/dtk/releases/latest/download/dtk-linux-x86_64" -o /tmp/dtk
5974

6075
install -m 755 -D /tmp/dtk ~/.local/bin/dtk
6176
```
6277

6378
Verify the checksum:
6479

6580
```console
66-
curl --proto '=https' --tlsv1.2 -fsSL "https://github.com/ssc/dtk/releases/latest/download/checksums.txt" \
81+
curl --proto '=https' --tlsv1.2 -fsSL "https://github.com/ssc-php/dtk/releases/latest/download/checksums.txt" \
6782
| grep "dtk-linux-x86_64" | awk '{print $1 " /tmp/dtk"}' | sha256sum --check
6883
```
6984

@@ -75,15 +90,15 @@ curl --proto '=https' --tlsv1.2 -fsSL "https://github.com/ssc/dtk/releases/lates
7590
<summary>**🍎 On macOS:**</summary>
7691

7792
```console
78-
curl --proto '=https' --tlsv1.2 -fsSL "https://github.com/ssc/dtk/releases/latest/download/dtk-macos-aarch64" -o /tmp/dtk
93+
curl --proto '=https' --tlsv1.2 -fsSL "https://github.com/ssc-php/dtk/releases/latest/download/dtk-macos-aarch64" -o /tmp/dtk
7994

8095
install -m 755 /tmp/dtk ~/.local/bin/dtk
8196
```
8297

8398
Verify the checksum:
8499

85100
```console
86-
curl --proto '=https' --tlsv1.2 -fsSL "https://github.com/ssc/dtk/releases/latest/download/checksums.txt" \
101+
curl --proto '=https' --tlsv1.2 -fsSL "https://github.com/ssc-php/dtk/releases/latest/download/checksums.txt" \
87102
| grep "dtk-macos-aarch64" | awk '{print $1 " /tmp/dtk"}' | shasum -a 256 --check
88103
```
89104

@@ -97,14 +112,14 @@ curl --proto '=https' --tlsv1.2 -fsSL "https://github.com/ssc/dtk/releases/lates
97112

98113
```powershell
99114
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.local\bin" | Out-Null
100-
Invoke-WebRequest -Uri "https://github.com/ssc/dtk/releases/latest/download/dtk-windows-x86_64.exe" -OutFile "$env:TEMP\dtk.exe"
115+
Invoke-WebRequest -Uri "https://github.com/ssc-php/dtk/releases/latest/download/dtk-windows-x86_64.exe" -OutFile "$env:TEMP\dtk.exe"
101116
```
102117

103118
Verify the checksum:
104119

105120
```powershell
106121
$hash = (Get-FileHash "$env:TEMP\dtk.exe" -Algorithm SHA256).Hash.ToLower()
107-
$expected = (Invoke-WebRequest -Uri "https://github.com/ssc/dtk/releases/latest/download/checksums.txt").Content -split '\r?\n' |
122+
$expected = (Invoke-WebRequest -Uri "https://github.com/ssc-php/dtk/releases/latest/download/checksums.txt").Content -split '\r?\n' |
108123
Where-Object { $_ -match "dtk-windows-x86_64.exe" } | ForEach-Object { ($_ -split '\s+')[0] }
109124
if ($hash -ne $expected) { throw "Checksum mismatch" }
110125
```
@@ -144,7 +159,7 @@ Further documentation can be found in:
144159
You can see the current and past versions using one of the following:
145160

146161
* the `git tag` command
147-
* the [releases page on Github](https://github.com/ssc/dtk/releases)
162+
* the [releases page on Github](https://github.com/ssc-php/dtk/releases)
148163
* the file listing the [changes between versions](CHANGELOG.md)
149164

150165
And finally some meta documentation:

bin/mk-brew-formula.sh

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
# File: bin/mk-brew-formula.sh
4+
# ──────────────────────────────────────────────────────────────────────────────
5+
# Updates the Homebrew formula in ../homebrew-dtk with the current version and
6+
# checksums from build/checksums.txt, then commits and pushes to the tap repo.
7+
#
8+
# Requires ../homebrew-dtk to be a clone of ssc-php/homebrew-dtk.
9+
#
10+
# Running order:
11+
# 1. bump/dtk.sh
12+
# 2. mk-dtk-bin.sh
13+
# 3. mk-changelog.sh
14+
# 4. review and tweak CHANGELOG.md
15+
# 5. mk-release.sh (calls this script automatically)
16+
#
17+
# Usage:
18+
#
19+
# ```shell
20+
# bin/mk-brew-formula.sh
21+
# ```
22+
# ──────────────────────────────────────────────────────────────────────────────
23+
24+
_BIN_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
25+
cd "${_BIN_DIR}/.."
26+
27+
_TAP_DIR="${_BIN_DIR}/../../homebrew-dtk"
28+
29+
if [[ ! -d "${_TAP_DIR}/.git" ]]; then
30+
echo "Error: ${_TAP_DIR} is not a git repository" >&2
31+
exit 1
32+
fi
33+
34+
if [[ ! -f build/checksums.txt ]]; then
35+
echo "Error: missing build/checksums.txt, run bin/mk-dtk-bin.sh first" >&2
36+
exit 1
37+
fi
38+
39+
_VERSION=$(sed -n "s/.*VERSION = '\([^']*\)'.*/\1/p" src/Infrastructure/Symfony/Version.php)
40+
41+
while read -r _sha _bin; do
42+
case "${_bin}" in
43+
*dtk-macos-x86_64) _SHA_MACOS_X86="${_sha}" ;;
44+
*dtk-macos-aarch64) _SHA_MACOS_ARM="${_sha}" ;;
45+
*dtk-linux-x86_64) _SHA_LINUX_X86="${_sha}" ;;
46+
*dtk-linux-aarch64) _SHA_LINUX_ARM="${_sha}" ;;
47+
esac
48+
done < build/checksums.txt
49+
50+
echo ''
51+
echo ' // Updating Homebrew formula...'
52+
53+
# \#{} is Ruby string interpolation; escaped here so bash passes it through literally
54+
cat > "${_TAP_DIR}/Formula/dtk.rb" <<FORMULA
55+
class Dtk < Formula
56+
desc "Kanban, Git and Deployment, in one coherent flow"
57+
homepage "https://github.com/ssc-php/dtk"
58+
license "MIT"
59+
version "${_VERSION}"
60+
61+
on_macos do
62+
on_intel do
63+
url "https://github.com/ssc-php/dtk/releases/download/v\#{version}/dtk-macos-x86_64"
64+
sha256 "${_SHA_MACOS_X86}"
65+
end
66+
67+
on_arm do
68+
url "https://github.com/ssc-php/dtk/releases/download/v\#{version}/dtk-macos-aarch64"
69+
sha256 "${_SHA_MACOS_ARM}"
70+
end
71+
end
72+
73+
on_linux do
74+
on_intel do
75+
url "https://github.com/ssc-php/dtk/releases/download/v\#{version}/dtk-linux-x86_64"
76+
sha256 "${_SHA_LINUX_X86}"
77+
end
78+
79+
on_arm do
80+
url "https://github.com/ssc-php/dtk/releases/download/v\#{version}/dtk-linux-aarch64"
81+
sha256 "${_SHA_LINUX_ARM}"
82+
end
83+
end
84+
85+
def install
86+
bin.install Dir["dtk-*"].first => "dtk"
87+
end
88+
89+
test do
90+
assert_match version.to_s, shell_output("\#{bin}/dtk --version")
91+
end
92+
end
93+
FORMULA
94+
95+
git -C "${_TAP_DIR}" add Formula/dtk.rb
96+
git -C "${_TAP_DIR}" commit -m "chore: release v${_VERSION}"
97+
git -C "${_TAP_DIR}" push
98+
99+
echo ''
100+
echo " [OK] Updated Homebrew formula for v${_VERSION}"
101+
echo ''

bin/mk-release.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ gh release create "${_TAG}" \
108108
build/dtk-windows-x86_64.exe \
109109
build/checksums.txt
110110

111+
echo ' // Updating Homebrew tap...'
112+
"${_BIN_DIR}/mk-brew-formula.sh"
113+
111114
echo ''
112115
echo " [OK] Released ${_TAG}"
113116
echo ''

docs/how-to/002-how-to-release.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ This will:
3232
3. Create an annotated git tag `vX.Y.Z`
3333
4. Push the commit and tag
3434
5. Create a GitHub release with the binaries and `checksums.txt` attached
35+
6. Update the Homebrew formula in `ssc-php/homebrew-dtk` and push it
3536

3637
## Bump PHP version
3738

0 commit comments

Comments
 (0)