Skip to content

Commit 80020df

Browse files
committed
fix release workflow
1 parent d08bd03 commit 80020df

File tree

2 files changed

+87
-12
lines changed

2 files changed

+87
-12
lines changed

.github/workflows/release.yml

Lines changed: 71 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,34 +75,44 @@ jobs:
7575
- name: Prepare package
7676
shell: bash
7777
run: |
78+
# Exit immediately if a command exits with a non-zero status.
79+
set -e
80+
7881
PACKAGE_NAME="lstr-${{ matrix.asset_name_suffix }}"
7982
STAGING_DIR="staging"
8083
8184
mkdir "$STAGING_DIR"
8285
86+
# Determine the binary path and name based on OS
8387
if [[ "${{ runner.os }}" == "Windows" ]]; then
84-
cp "target/${{ matrix.target }}/release/lstr.exe" "$STAGING_DIR/"
88+
SOURCE_BINARY_PATH="target/${{ matrix.target }}/release/lstr.exe"
8589
else
86-
cp "target/${{ matrix.target }}/release/lstr" "$STAGING_DIR/"
90+
SOURCE_BINARY_PATH="target/${{ matrix.target }}/release/lstr"
91+
fi
92+
93+
# --- ADDED VERIFICATION ---
94+
echo "Verifying binary exists at: ${SOURCE_BINARY_PATH}"
95+
if [ ! -f "$SOURCE_BINARY_PATH" ]; then
96+
echo "::error::Binary not found!"
97+
exit 1
8798
fi
99+
100+
cp "$SOURCE_BINARY_PATH" "$STAGING_DIR/"
88101
102+
# We should also add a LICENSE file to the repository root
103+
# For now, I'll make this step non-fatal
89104
cp README.md "$STAGING_DIR/"
90-
cp LICENSE "$STAGING_DIR/"
105+
cp LICENSE "$STAGING_DIR/" || echo "LICENSE file not found, skipping."
91106
92107
echo "--- Contents of staging directory ---"
93108
ls -R "$STAGING_DIR"
94109
95110
if [[ "${{ runner.os }}" == "Windows" ]]; then
96111
7z a "$PACKAGE_NAME" "./$STAGING_DIR/*"
97112
else
98-
# Corrected tar command: Create archive in the current directory
99113
tar -czf "$PACKAGE_NAME" -C "$STAGING_DIR" .
100114
fi
101115
102-
echo "--- Contents of workspace after archiving ---"
103-
ls -R .
104-
echo "ASSET will be set to: $PACKAGE_NAME"
105-
106116
echo "ASSET=$PACKAGE_NAME" >> $GITHUB_ENV
107117
108118
- name: Upload Release Asset
@@ -113,4 +123,56 @@ jobs:
113123
upload_url: ${{ needs.create-release.outputs.upload_url }}
114124
asset_path: ${{ env.ASSET }}
115125
asset_name: ${{ env.ASSET }}
116-
asset_content_type: application/octet-stream
126+
asset_content_type: application/octet-stream
127+
128+
update-homebrew-tap:
129+
name: Update Homebrew Tap
130+
needs: build-and-upload
131+
runs-on: ubuntu-latest
132+
steps:
133+
- name: Checkout lstr repo (for release assets)
134+
uses: actions/checkout@v4
135+
136+
- name: Download macOS release assets
137+
run: |
138+
gh release download ${{ github.ref_name }} --pattern 'lstr-macos-*.tar.gz'
139+
env:
140+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
141+
142+
- name: Calculate Checksums
143+
id: checksums
144+
run: |
145+
echo "sha256_x86_64=$(shasum -a 256 lstr-macos-x86_64.tar.gz | awk '{print $1}')" >> $GITHUB_OUTPUT
146+
echo "sha256_arm64=$(shasum -a 256 lstr-macos-arm64.tar.gz | awk '{print $1}')" >> $GITHUB_OUTPUT
147+
148+
- name: Checkout homebrew-lstr repo
149+
uses: actions/checkout@v4
150+
with:
151+
repository: bgreenwell/homebrew-lstr
152+
path: homebrew-lstr
153+
token: ${{ secrets.PAT_FOR_HOMEBREW_TAP }}
154+
155+
- name: Update Homebrew Formula
156+
run: |
157+
# The version number is derived from the git tag (e.g., v0.2.1 -> 0.2.1)
158+
VERSION="${{ github.ref_name }}"
159+
VERSION=${VERSION#v}
160+
161+
# Use sed to update the formula file
162+
sed -i "s/version \".*\"/version \"${VERSION}\"/" homebrew-lstr/Formula/lstr.rb
163+
sed -i "s|url \".*/lstr-macos-x86_64.tar.gz\"|url \"https://github.com/bgreenwell/lstr/releases/download/${{ github.ref_name }}/lstr-macos-x86_64.tar.gz\"|" homebrew-lstr/Formula/lstr.rb
164+
sed -i "s/sha256 \".*\" # x86_64/sha256 \"${{ steps.checksums.outputs.sha256_x86_64 }}\" # x86_64/" homebrew-lstr/Formula/lstr.rb
165+
sed -i "s|url \".*/lstr-macos-arm64.tar.gz\"|url \"https://github.com/bgreenwell/lstr/releases/download/${{ github.ref_name }}/lstr-macos-arm64.tar.gz\"|" homebrew-lstr/Formula/lstr.rb
166+
sed -i "s/sha256 \".*\" # arm64/sha256 \"${{ steps.checksums.outputs.sha256_arm64 }}\" # arm64/" homebrew-lstr/Formula/lstr.rb
167+
168+
echo "--- Updated lstr.rb ---"
169+
cat homebrew-lstr/Formula/lstr.rb
170+
171+
- name: Commit and Push Changes
172+
run: |
173+
cd homebrew-lstr
174+
git config --global user.name "github-actions[bot]"
175+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
176+
git add Formula/lstr.rb
177+
git commit -m "Update lstr to ${{ github.ref_name }}" || echo "No changes to commit"
178+
git push

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,29 @@ A fast, minimalist directory tree viewer, written in Rust. Inspired by the comma
3030

3131
## Installation
3232

33-
You need the Rust toolchain installed on your system to build `lstr`. Or use `nix develop` command to create development environment.
33+
### With Homebrew (macOS)
34+
35+
The easiest way to install `lstr` on macOS is with Homebrew.
36+
37+
```bash
38+
# First, tap our repository
39+
brew tap bgreenwell/lstr
40+
41+
# Now, install lstr
42+
brew install lstr
43+
```
44+
45+
### From source (all platforms)
46+
47+
You need the Rust toolchain installed on your system to build `lstr`.
3448

3549
1. **Clone the repository:**
3650
```bash
37-
git clone https://github.com/bgreenwell/lstr.git
51+
git clone [https://github.com/bgreenwell/lstr.git](https://github.com/bgreenwell/lstr.git)
3852
cd lstr
3953
```
4054
2. **Build and install using Cargo:**
4155
```bash
42-
# This compiles in release mode and copies the binary to ~/.cargo/bin
4356
cargo install --path .
4457
```
4558

0 commit comments

Comments
 (0)