Skip to content

Commit dc6665b

Browse files
committed
Introducing brew.lock
0 parents  commit dc6665b

28 files changed

Lines changed: 4645 additions & 0 deletions

.github/brewlock.png

389 KB
Loading

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
ci:
13+
runs-on: macos-14 # Apple Silicon
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: oven-sh/setup-bun@v2
19+
with:
20+
bun-version: "1.3.6"
21+
22+
- name: Install dependencies
23+
run: bun install
24+
25+
- name: Lint
26+
run: bun run lint
27+
28+
- name: Typecheck
29+
run: bun run typecheck
30+
31+
- name: Test
32+
run: bun test
33+
34+
- name: Build
35+
run: bun run build

.github/workflows/release.yml

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
name: Release
2+
3+
on:
4+
workflow_run:
5+
workflows: [CI]
6+
types:
7+
- completed
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
check-version:
16+
runs-on: ubuntu-latest
17+
if: github.event.workflow_run.conclusion == 'success'
18+
outputs:
19+
version_changed: ${{ steps.check.outputs.changed }}
20+
version: ${{ steps.check.outputs.version }}
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 2
26+
27+
- name: Check if version changed
28+
id: check
29+
run: |
30+
# Get current version
31+
CURRENT_VERSION=$(jq -r '.version' package.json)
32+
echo "Current version: $CURRENT_VERSION"
33+
34+
# Get previous version
35+
git show HEAD~1:package.json > /tmp/prev-package.json 2>/dev/null || echo '{"version":"0.0.0"}' > /tmp/prev-package.json
36+
PREV_VERSION=$(jq -r '.version' /tmp/prev-package.json)
37+
echo "Previous version: $PREV_VERSION"
38+
39+
# Check if version changed
40+
if [ "$CURRENT_VERSION" != "$PREV_VERSION" ]; then
41+
echo "Version changed from $PREV_VERSION to $CURRENT_VERSION"
42+
echo "changed=true" >> $GITHUB_OUTPUT
43+
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
44+
else
45+
echo "Version unchanged"
46+
echo "changed=false" >> $GITHUB_OUTPUT
47+
fi
48+
49+
build:
50+
needs: check-version
51+
if: needs.check-version.outputs.version_changed == 'true'
52+
runs-on: macos-14 # Apple Silicon
53+
54+
steps:
55+
- uses: actions/checkout@v4
56+
57+
- uses: oven-sh/setup-bun@v2
58+
with:
59+
bun-version: "1.3.6"
60+
61+
- name: Install dependencies
62+
run: bun install
63+
64+
- name: Build binary and create tarball
65+
run: bun scripts/release.ts --tarball
66+
67+
- name: Upload artifact
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: brewlock-darwin-arm64
71+
path: brewlock-darwin-arm64.tar.gz
72+
73+
release:
74+
needs: [check-version, build]
75+
runs-on: ubuntu-latest
76+
env:
77+
VERSION: ${{ needs.check-version.outputs.version }}
78+
79+
steps:
80+
- uses: actions/checkout@v4
81+
82+
- name: Download all artifacts
83+
uses: actions/download-artifact@v4
84+
with:
85+
path: artifacts
86+
87+
- name: Display structure of downloaded files
88+
run: ls -la artifacts/*/
89+
90+
- name: Generate checksums
91+
run: |
92+
cd artifacts
93+
for dir in */; do
94+
for file in "$dir"*.tar.gz; do
95+
sha256sum "$file" >> checksums.txt
96+
done
97+
done
98+
cat checksums.txt
99+
100+
- name: Create tag
101+
run: |
102+
git config user.name "github-actions[bot]"
103+
git config user.email "github-actions[bot]@users.noreply.github.com"
104+
git tag -a "v$VERSION" -m "Release v$VERSION"
105+
git push origin "v$VERSION"
106+
107+
- name: Create Release
108+
uses: softprops/action-gh-release@v2
109+
with:
110+
tag_name: v${{ env.VERSION }}
111+
files: |
112+
artifacts/**/*.tar.gz
113+
artifacts/checksums.txt
114+
generate_release_notes: true
115+
env:
116+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117+
118+
update-formula:
119+
needs: [check-version, release]
120+
runs-on: ubuntu-latest
121+
env:
122+
VERSION: ${{ needs.check-version.outputs.version }}
123+
124+
steps:
125+
- uses: actions/checkout@v4
126+
with:
127+
ref: main
128+
129+
- name: Download all artifacts
130+
uses: actions/download-artifact@v4
131+
with:
132+
path: artifacts
133+
134+
- name: Calculate SHA256 and update formula
135+
run: |
136+
SHA256=$(sha256sum artifacts/brewlock-darwin-arm64/brewlock-darwin-arm64.tar.gz | cut -d' ' -f1)
137+
138+
echo "SHA256: $SHA256"
139+
echo "Version: $VERSION"
140+
141+
# Update the formula file
142+
sed -i "s/version \".*\"/version \"$VERSION\"/" Formula/brewlock.rb
143+
sed -i "s|releases/download/v[^/]*/|releases/download/v${VERSION}/|g" Formula/brewlock.rb
144+
sed -i "s/PLACEHOLDER_SHA256/$SHA256/" Formula/brewlock.rb
145+
# Replace existing 64-char hex SHA256 hashes
146+
sed -i 's/sha256 "[a-f0-9]\{64\}"/sha256 "'"$SHA256"'"/' Formula/brewlock.rb
147+
148+
cat Formula/brewlock.rb
149+
150+
- name: Commit updated formula
151+
uses: stefanzweifel/git-auto-commit-action@v5
152+
with:
153+
commit_message: "chore: update formula for v${{ env.VERSION }}"
154+
file_pattern: Formula/brewlock.rb
155+
branch: main

.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# dependencies (bun install)
2+
node_modules
3+
4+
# output
5+
out
6+
dist
7+
*.tgz
8+
9+
# code coverage
10+
coverage
11+
*.lcov
12+
13+
# logs
14+
logs
15+
_.log
16+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
17+
18+
# dotenv environment variable files
19+
.env
20+
.env.development.local
21+
.env.test.local
22+
.env.production.local
23+
.env.local
24+
25+
# caches
26+
.eslintcache
27+
.cache
28+
*.tsbuildinfo
29+
30+
# IDEs
31+
.idea
32+
.cursor
33+
34+
# Finder (MacOS) folder config
35+
.DS_Store

.vscode/extensions.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": [
3+
"biomejs.biome",
4+
"oven.bun-vscode",
5+
"mylesmurphy.prettify-ts",
6+
"yoavbls.pretty-ts-errors"
7+
]
8+
}

.vscode/settings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"editor.codeActionsOnSave": {
3+
"source.fixAll.biome": "explicit",
4+
"source.organizeImports.biome": "explicit",
5+
"source.removeUnusedImports": "explicit"
6+
},
7+
"editor.defaultFormatter": "biomejs.biome",
8+
"editor.formatOnSave": true,
9+
"typescript.enablePromptUseWorkspaceTsdk": true
10+
}

Formula/brewlock.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# typed: false
2+
# frozen_string_literal: true
3+
4+
class Brewlock < Formula
5+
desc "The missing lock file for Homebrew"
6+
homepage "https://github.com/ShipWorthyAI/brewlock"
7+
version "0.1.0"
8+
license "MIT"
9+
10+
depends_on arch: :arm64
11+
depends_on :macos
12+
13+
url "https://github.com/ShipWorthyAI/brewlock/releases/download/v0.1.0/brewlock-darwin-arm64.tar.gz"
14+
sha256 "PLACEHOLDER_SHA256"
15+
16+
def install
17+
bin.install "brewlock"
18+
end
19+
20+
def caveats
21+
<<~EOS
22+
To use brewlock as a transparent wrapper for Homebrew, add this alias
23+
to your shell configuration:
24+
25+
For zsh (add to ~/.zshrc):
26+
alias brew='brewlock'
27+
28+
For bash (add to ~/.bashrc):
29+
alias brew='brewlock'
30+
31+
For fish (add to ~/.config/fish/config.fish):
32+
alias brew 'brewlock'
33+
EOS
34+
end
35+
36+
test do
37+
assert_match "brewlock - the missing lock file for Homebrew", shell_output("#{bin}/brewlock help")
38+
end
39+
end

0 commit comments

Comments
 (0)