Skip to content

Commit

Permalink
Merge pull request #14 from bodo-run/better-release-process
Browse files Browse the repository at this point in the history
feat: implement tag-based release workflow
  • Loading branch information
mohsen1 authored Jan 19, 2025
2 parents 45ade0a + 57bdcaf commit 34a471c
Show file tree
Hide file tree
Showing 10 changed files with 437 additions and 6 deletions.
146 changes: 146 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: Release
on:
push:
tags:
- "v*"

permissions:
contents: write
packages: write

jobs:
build:
strategy:
matrix:
include:
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
- target: x86_64-pc-windows-gnu
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- name: Clean existing tags
run: rm -rf .git/refs/tags/

- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Install cross-compilation tools (Linux)
if: runner.os == 'Linux' && contains(matrix.target, 'aarch64')
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build
run: |
cargo build --release --target ${{ matrix.target }}
mkdir -p "yek-${{ matrix.target }}"
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
cp "target/${{ matrix.target }}/release/yek.exe" "yek-${{ matrix.target }}/"
7z a "yek-${{ matrix.target }}.tar" "yek-${{ matrix.target }}"
7z a "yek-${{ matrix.target }}.tar.gz" "yek-${{ matrix.target }}.tar"
rm "yek-${{ matrix.target }}.tar"
else
cp "target/${{ matrix.target }}/release/yek" "yek-${{ matrix.target }}/"
tar -czf "yek-${{ matrix.target }}.tar.gz" "yek-${{ matrix.target }}"
fi
shell: bash

- name: Compute SHA256
id: sha
run: |
if [[ "${{ runner.os }}" == "Windows" ]]; then
echo "sha256=$(certutil -hashfile yek-${{ matrix.target }}.tar.gz SHA256 | grep -v 'hash' | tr -d ' \r\n')" >> $GITHUB_OUTPUT
else
echo "sha256=$(shasum -a 256 yek-${{ matrix.target }}.tar.gz | awk '{print $1}')" >> $GITHUB_OUTPUT
fi
shell: bash

- name: Create SHA file
run: echo "${{ steps.sha.outputs.sha256 }}" > sha-${{ matrix.target }}.txt
shell: bash

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: yek-${{ matrix.target }}
path: yek-${{ matrix.target }}.tar.gz

- name: Upload SHA
uses: actions/upload-artifact@v3
with:
name: sha-${{ matrix.target }}
path: sha-${{ matrix.target }}.txt

release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Clean existing tags
run: rm -rf .git/refs/tags/

- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Download artifacts
uses: actions/download-artifact@v3

- name: Move artifacts to root
run: |
mv */yek-*.tar.gz ./
- name: Update Formula
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Get version from tag
VERSION=${GITHUB_REF#refs/tags/v}
# Update version in Formula
sed -i "s/^ version \".*\"/ version \"${VERSION}\"/" Formula/yek.rb
# Update each SHA256
for sha_file in sha-*/sha-*.txt; do
target=$(echo $sha_file | cut -d/ -f1 | sed 's/sha-//')
sha=$(cat $sha_file)
sed -i "/url \".*yek-${target}.tar.gz\"/{n;s/sha256 \".*\"/sha256 \"${sha}\"/;}" Formula/yek.rb
done
# Configure git with token-based auth
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
# Commit and push changes
git add Formula/yek.rb
git commit -m 'chore: update formula for release ${VERSION}'
git push origin HEAD:main
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: yek-*.tar.gz
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Cleanup tags
run: |
git fetch --prune --prune-tags
git tag -l | xargs -r git tag -d
git fetch --tags
79 changes: 79 additions & 0 deletions .github/workflows/test-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,16 @@ jobs:
target: x86_64-apple-darwin
runs-on: ${{ matrix.os }}
steps:
- name: Clean existing tags
shell: bash
run: |
if [ -d ".git/refs/tags" ]; then
rm -rf .git/refs/tags/
fi
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get install script
id: get_linux_install_script
Expand Down Expand Up @@ -105,7 +114,16 @@ jobs:
name: Test Windows Installation
runs-on: windows-latest
steps:
- name: Clean existing tags
shell: bash
run: |
if [ -d ".git/refs/tags" ]; then
rm -rf .git/refs/tags/
fi
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get install script
id: get_windows_install_script
Expand Down Expand Up @@ -191,3 +209,64 @@ jobs:
Get-ChildItem repo-serialized -ErrorAction SilentlyContinue
exit 1
}
test-brew-install:
name: Test Homebrew Installation
runs-on: macos-latest
steps:
- name: Clean existing tags
shell: bash
run: |
if [ -d ".git/refs/tags" ]; then
rm -rf .git/refs/tags/
fi
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get brew install commands
id: get_brew_install
shell: bash
run: |
script=$(awk '/<!-- HOMEBREW_INSTALLATION_BEGIN -->/{p=1;next}/<!-- HOMEBREW_INSTALLATION_END -->/{p=0}p' README.md | grep -v '^```')
# Ensure script is not empty
if [ -z "$script" ]; then
echo "Error: Could not extract Homebrew installation commands from README.md"
exit 1
fi
# Escape multiline output
script="${script//'%'/'%25'}"
script="${script//$'\n'/'%0A'}"
script="${script//$'\r'/'%0D'}"
echo "script=$script" >> $GITHUB_OUTPUT
- name: Install via Homebrew
run: ${{ steps.get_brew_install.outputs.script }}

- name: Verify installation
run: |
# Ensure yek is in PATH
which yek || {
echo "Error: yek not found in PATH"
echo "PATH: $PATH"
exit 1
}
# Test version output
yek --version || {
echo "Error: yek --version failed"
exit 1
}
# Create test file
echo "test content" > test.txt
# Test basic functionality
yek test.txt || {
echo "Error: yek failed to process test file"
exit 1
}
# Verify output exists
test -f repo-serialized/chunk-0.txt || {
echo "Error: Output file not found"
ls -la repo-serialized/ || true
exit 1
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
target/
*.log
*.tmp
*.tar.gz
.DS_Store
yek.toml
repo-serialized/
dist/
dist/
45 changes: 45 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,50 @@
# Changelog

## [0.7.4] - 2025-01-19

### Features


### Bug Fixes

- fix: include all files in release commit

### Other Changes

- chore: update Cargo.lock and gitignore


## [0.7.3] - 2025-01-19

### Features

- feat: implement tag-based release workflow

### Bug Fixes

- fix: improve version parsing and changelog handling
- fix: cross-platform SHA256 computation and artifact handling
- fix: pr feedback

### Other Changes

- test: use HTML comments for installation script extraction
- refactor: improve Makefile cross-platform support and remove redundant target
- ci: remove automatic script path updating


## [0.7.2] - 2025-01-19

### Features

- feat: implement tag-based release workflow

### Bug Fixes

### Other Changes

- ci: remove automatic script path updating

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "yek"
version = "0.7.0"
version = "0.7.4"
edition = "2021"

[dependencies]
Expand Down
4 changes: 2 additions & 2 deletions Formula/yek.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class Yek < Formula
desc "A tool to chunk and serialize repository content for LLM consumption"
homepage "https://github.com/bodo-run/yek"
version "0.5.0"
version "0.7.4"
head "https://github.com/bodo-run/yek.git", branch: "main"

on_macos do
if Hardware::CPU.arm?
url "https://github.com/bodo-run/yek/releases/download/v#{version}/yek-aarch64-apple-darwin.tar.gz"
sha256 "527c86094bd1c4abf3da934c7d4479ab1b5cd722d4570b1bb1bf4253286bd406" # arm64
sha256 "9e01df0cd7ac448c5341c7156d2f97deeeaeb4197f891ebe5f15e9867ef50352" # arm64
else
url "https://github.com/bodo-run/yek/releases/download/v#{version}/yek-x86_64-apple-darwin.tar.gz"
sha256 "34896ad65e8ae7c5e93d90e87f15656b67ed5b7596492863d1da80e548ba7301" # x86_64
Expand Down
26 changes: 25 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.PHONY: all macos linux clean test lint update-formula build-release
.PHONY: all macos linux clean test lint release major build-artifacts

FORMULA_PATH := $(shell pwd)/Formula/yek.rb
CURRENT_PLATFORM := $(shell rustc -vV | grep host: | cut -d' ' -f2)

all: macos

Expand All @@ -20,3 +21,26 @@ test:
lint:
cargo clippy -- -D warnings
cargo fmt --check

build-artifacts:
@echo "Building for $(CURRENT_PLATFORM)..."
cargo build --release
mkdir -p "yek-$(CURRENT_PLATFORM)"
if [ "$(OS)" = "Windows_NT" ]; then \
cp "target/release/yek.exe" "yek-$(CURRENT_PLATFORM)/"; \
else \
cp "target/release/yek" "yek-$(CURRENT_PLATFORM)/"; \
fi
tar -czf "yek-$(CURRENT_PLATFORM).tar.gz" "yek-$(CURRENT_PLATFORM)"
rm -rf "yek-$(CURRENT_PLATFORM)"

release: test lint
@scripts/make-release.sh $(if $(filter major,$(MAKECMDGOALS)),major,patch)

.PHONY: major
major: ;

update-formula:
sed -i.bak "s/version .*/version '$(version)'/" $(FORMULA_PATH) && rm -f $(FORMULA_PATH).bak


4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,15 @@ Running `yek` in this directory will produce a single file and write it to the t

### Via Homebrew (recommended for macOS)

<!-- HOMEBREW_INSTALLATION_BEGIN -->

```bash
brew tap bodo-run/yek https://github.com/bodo-run/yek.git
brew install yek
```

<!-- HOMEBREW_INSTALLATION_END -->

### Via Install Script

For Unix-like systems (macOS, Linux):
Expand Down
Loading

0 comments on commit 34a471c

Please sign in to comment.