Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
run: |
scripts/update-stack-formula.sh 0.3.0
version=$(ruby -rjson -e 'puts JSON.parse(File.read("metadata/stack-release.json")).fetch("version")')
scripts/update-stack-formula.sh "$version"
git diff --exit-code -- Formula/stack.rb metadata/stack-release.json

- name: Check repository diff
Expand Down
25 changes: 17 additions & 8 deletions Formula/stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,35 @@ class Stack < Formula
depends_on arch: :arm64

on_arm do
url "https://github.com/stack-sh/cli/releases/download/v0.3.0/stack-v0.3.0-aarch64-apple-darwin.tar.gz"
sha256 "10df35058c9e8438b331b69392f6b9840cbae3a5278105b0118c3942f62fc356"
url "https://github.com/stack-sh/cli/releases/download/v0.4.0/stack-v0.4.0-aarch64-apple-darwin.tar.gz"
sha256 "dd43cf3d966a3dc28de3ac8752b6a98f19e4cb7cf6b04652ab73a013800cb015"
end

# Let Homebrew load the formula before reporting the ARM64 requirement.
on_intel do
url "https://github.com/stack-sh/cli/releases/download/v0.3.0/stack-v0.3.0-x86_64-apple-darwin.tar.gz"
sha256 "23d8eea13ff2663e059b7ec91cbc8d6bca8825380766e87f1718c2dea217a49f"
url "https://github.com/stack-sh/cli/releases/download/v0.4.0/stack-v0.4.0-x86_64-apple-darwin.tar.gz"
sha256 "48a72328fcf6d160a123a766d9701108f8ee9f633001581dab533b93dddf0827"
end
end

on_linux do
on_arm do
url "https://github.com/stack-sh/cli/releases/download/v0.3.0/stack-v0.3.0-aarch64-unknown-linux-gnu.tar.gz"
sha256 "2bed2ba5ff4a727646cedb4ec77ac875e09fc3ede996a963022d9a97ccdbf7ac"
url "https://github.com/stack-sh/cli/releases/download/v0.4.0/stack-v0.4.0-aarch64-unknown-linux-gnu.tar.gz"
sha256 "a0d76bfa9ed9e767fcd06dbeb7140234db865440210c7c3abf6c3db4f6983a6e"
end

on_intel do
url "https://github.com/stack-sh/cli/releases/download/v0.3.0/stack-v0.3.0-x86_64-unknown-linux-gnu.tar.gz"
sha256 "6c9ab21d96fc6fb0a12a6ff4f7f56103d8dd8513ac85c8d30ab6e072c5c6a7d9"
url "https://github.com/stack-sh/cli/releases/download/v0.4.0/stack-v0.4.0-x86_64-unknown-linux-gnu.tar.gz"
sha256 "89d8a34c0da5f67932edff2641fe0a0527afbd120cfd5133cb38cdeffca55319"
end
end

def install
bin.install "stack"
bash_completion.install "share/bash-completion/completions/stack"
zsh_completion.install "share/zsh/site-functions/_stack"
fish_completion.install "share/fish/vendor_completions.d/stack.fish"
man1.install "share/man/man1/stack.1"
doc.install "LICENSE", "NOTICE", "THIRD_PARTY_LICENSES.md"
end

Expand All @@ -49,5 +53,10 @@ def install

assert_path_exists testpath/"diagram.svg"
assert_match "<svg", (testpath/"diagram.svg").read
assert_equal shell_output("#{bin}/stack completions bash"), (bash_completion/"stack").read
assert_equal shell_output("#{bin}/stack completions zsh"), (zsh_completion/"_stack").read
assert_equal shell_output("#{bin}/stack completions fish"), (fish_completion/"stack.fish").read
assert_equal shell_output("#{bin}/stack manpage"), (man1/"stack.1").read
assert_match ".TH STACK 1", (man1/"stack.1").read
end
end
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The formula installs the exact archives published by the Stack CLI GitHub Releas
| x86_64 Linux with SSSE3 on a current Homebrew Tier 1 host | Supported | `x86_64-unknown-linux-gnu` |
| Intel macOS | Unsupported by this formula | — |

Stack CLI 0.3.0 does not publish shell completion files. Completion generation and package integration will be added in a future CLI release instead of being duplicated in this tap.
Stack CLI 0.4.0 archives include shell integration generated by the same binary. The formula installs bash completion to Homebrew's `bash_completion` path, zsh completion to `zsh_completion`, fish completion to `fish_completion`, and `stack.1` to `man1`. It does not edit shell startup files; follow Homebrew's normal completion setup for your shell.

## Upgrade and uninstall

Expand All @@ -39,6 +39,6 @@ Upgrade and uninstall only change files managed in the Homebrew Cellar. Stack co

## Verification and maintenance

The formula test runs `stack --version`, `init`, `check`, and `render`. CI additionally verifies the three supported host mappings, formula syntax and style, upstream GitHub attestations, upgrade behavior, uninstall behavior, and preservation of configuration and icon data.
The formula test runs `stack --version`, `init`, `check`, and `render`, and compares every installed completion and manual file with fresh output from the binary. CI additionally verifies the three supported host mappings, formula syntax and style, upstream GitHub attestations, upgrade behavior, uninstall behavior, managed-file removal, and preservation of configuration and icon data.

See [Maintaining the formula](./docs/maintaining.md) for the fail-closed update and recovery procedure. Security reports should follow [SECURITY.md](./SECURITY.md).
2 changes: 1 addition & 1 deletion docs/maintaining.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
scripts/update-stack-formula.sh MAJOR.MINOR.PATCH
```

The updater downloads the release manifest, checksum inventory, all four CLI archives, and their provenance and SBOM bundles. Three archives are installable on supported Homebrew hosts; the Intel macOS archive lets Homebrew load the formula before reporting the ARM64 requirement. The updater rejects draft or prerelease versions, manifest drift, missing or duplicate checksum entries, digest mismatch, an unexpected signer workflow or source ref, and self-hosted build provenance. It writes `metadata/stack-release.json` and the generated formula only after all checks pass.
The updater downloads the release manifest, checksum inventory, all four CLI archives, and their provenance and SBOM bundles. Three archives are installable on supported Homebrew hosts; the Intel macOS archive lets Homebrew load the formula before reporting the ARM64 requirement. The updater rejects draft or prerelease versions, manifest drift, missing or duplicate checksum entries, digest mismatch, an unexpected signer workflow or source ref, and self-hosted build provenance. It writes `metadata/stack-release.json` and the generated formula only after all checks pass. The lifecycle matrix then proves the archived bash, zsh, and fish completion files and `stack.1` are installed through Homebrew's managed paths and exactly match the binary generators.
4. Review the generated formula and run the source test:

```sh
Expand Down
12 changes: 6 additions & 6 deletions metadata/stack-release.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"schemaVersion": 1,
"repository": "stack-sh/cli",
"version": "0.3.0",
"sourceCommit": "cb1ec1fdd91fc90ed8b2e2cb76f798a6f88df294",
"version": "0.4.0",
"sourceCommit": "7f4066884f7902d4c582d45184f3a9019fe59bf7",
"targets": {
"aarch64-apple-darwin": "10df35058c9e8438b331b69392f6b9840cbae3a5278105b0118c3942f62fc356",
"aarch64-unknown-linux-gnu": "2bed2ba5ff4a727646cedb4ec77ac875e09fc3ede996a963022d9a97ccdbf7ac",
"x86_64-apple-darwin": "23d8eea13ff2663e059b7ec91cbc8d6bca8825380766e87f1718c2dea217a49f",
"x86_64-unknown-linux-gnu": "6c9ab21d96fc6fb0a12a6ff4f7f56103d8dd8513ac85c8d30ab6e072c5c6a7d9"
"aarch64-apple-darwin": "dd43cf3d966a3dc28de3ac8752b6a98f19e4cb7cf6b04652ab73a013800cb015",
"aarch64-unknown-linux-gnu": "a0d76bfa9ed9e767fcd06dbeb7140234db865440210c7c3abf6c3db4f6983a6e",
"x86_64-apple-darwin": "48a72328fcf6d160a123a766d9701108f8ee9f633001581dab533b93dddf0827",
"x86_64-unknown-linux-gnu": "89d8a34c0da5f67932edff2641fe0a0527afbd120cfd5133cb38cdeffca55319"
}
}
9 changes: 9 additions & 0 deletions scripts/render-stack-formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ class Stack < Formula

def install
bin.install "stack"
bash_completion.install "share/bash-completion/completions/stack"
zsh_completion.install "share/zsh/site-functions/_stack"
fish_completion.install "share/fish/vendor_completions.d/stack.fish"
man1.install "share/man/man1/stack.1"
doc.install "LICENSE", "NOTICE", "THIRD_PARTY_LICENSES.md"
end

Expand All @@ -89,6 +93,11 @@ def install

assert_path_exists testpath/"diagram.svg"
assert_match "<svg", (testpath/"diagram.svg").read
assert_equal shell_output("\#{bin}/stack completions bash"), (bash_completion/"stack").read
assert_equal shell_output("\#{bin}/stack completions zsh"), (zsh_completion/"_stack").read
assert_equal shell_output("\#{bin}/stack completions fish"), (fish_completion/"stack.fish").read
assert_equal shell_output("\#{bin}/stack manpage"), (man1/"stack.1").read
assert_match ".TH STACK 1", (man1/"stack.1").read
end
end
FORMULA
28 changes: 24 additions & 4 deletions scripts/test-formula-lifecycle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ fi

tap_name="$1"
formula="${tap_name}/stack"
formula_file="$(brew --repository "${tap_name}")/Formula/stack.rb"
tap_repository="$(brew --repository "${tap_name}")"
formula_file="${tap_repository}/Formula/stack.rb"
expected_version="$(ruby -rjson -e 'puts JSON.parse(File.read(ARGV.fetch(0))).fetch("version")' "${tap_repository}/metadata/stack-release.json")"
brew_prefix="$(brew --prefix)"
temporary_directory="$(mktemp -d)"
formula_backup="${temporary_directory}/stack.rb"
Expand All @@ -36,19 +38,37 @@ brew uninstall --force stack >/dev/null 2>&1 || true
brew install "${formula}"
brew test "${formula}"
installed_version="$("${brew_prefix}/bin/stack" --version)"
[[ "${installed_version}" == "stack 0.3.0" ]]
[[ "${installed_version}" == "stack ${expected_version}" ]]
managed_files=(
"${brew_prefix}/etc/bash_completion.d/stack"
"${brew_prefix}/share/zsh/site-functions/_stack"
"${brew_prefix}/share/fish/vendor_completions.d/stack.fish"
"${brew_prefix}/share/man/man1/stack.1"
)
for managed_file in "${managed_files[@]}"
do
[[ -s "${managed_file}" ]]
done
"${brew_prefix}/bin/stack" completions bash | cmp "${brew_prefix}/etc/bash_completion.d/stack" -
"${brew_prefix}/bin/stack" completions zsh | cmp "${brew_prefix}/share/zsh/site-functions/_stack" -
"${brew_prefix}/bin/stack" completions fish | cmp "${brew_prefix}/share/fish/vendor_completions.d/stack.fish" -
"${brew_prefix}/bin/stack" manpage | cmp "${brew_prefix}/share/man/man1/stack.1" -

cp "${formula_file}" "${formula_backup}"
# The Ruby expression must remain literal shell input.
# shellcheck disable=SC2016
ruby -0pi -e '$_.sub!(%{ license "Apache-2.0"\n}, %{ license "Apache-2.0"\n revision 1\n})' "${formula_file}"
brew upgrade "${formula}"
brew list --versions stack | grep -F '0.3.0_1' >/dev/null
brew list --versions stack | grep -F "${expected_version}_1" >/dev/null
upgraded_version="$("${brew_prefix}/bin/stack" --version)"
[[ "${upgraded_version}" == "stack 0.3.0" ]]
[[ "${upgraded_version}" == "stack ${expected_version}" ]]

brew uninstall "${formula}"
[[ ! -e "${brew_prefix}/bin/stack" ]]
for managed_file in "${managed_files[@]}"
do
[[ ! -e "${managed_file}" ]]
done
config_after="$(shasum -a 256 "${XDG_CONFIG_HOME}/stack/config.yaml" | awk '{print $1}')"
icon_after="$(shasum -a 256 "${XDG_CONFIG_HOME}/stack/icons/test-provider/marker.txt" | awk '{print $1}')"
[[ "${config_after}" == "${config_before}" ]]
Expand Down
Loading