Skip to content

Commit a47a9ac

Browse files
committed
Add automated release workflow
- GitHub Actions workflow for cross-platform builds - Release script for easy version management - Updated README with release instructions - Supports Linux, Windows, and macOS (Intel + Apple Silicon)
1 parent 504a16a commit a47a9ac

File tree

3 files changed

+251
-0
lines changed

3 files changed

+251
-0
lines changed

.github/workflows/release.yml

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
build:
13+
name: Build ${{ matrix.target }}
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
- target: x86_64-unknown-linux-gnu
20+
os: ubuntu-latest
21+
- target: x86_64-pc-windows-msvc
22+
os: windows-latest
23+
- target: x86_64-apple-darwin
24+
os: macos-latest
25+
- target: aarch64-apple-darwin
26+
os: macos-latest
27+
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
32+
- name: Install Rust
33+
uses: dtolnay/rust-toolchain@stable
34+
with:
35+
targets: ${{ matrix.target }}
36+
37+
- name: Install dependencies (Ubuntu)
38+
if: matrix.os == 'ubuntu-latest'
39+
run: |
40+
sudo apt-get update
41+
sudo apt-get install -y libssl-dev pkg-config
42+
43+
- name: Build
44+
run: cargo build --release --target ${{ matrix.target }}
45+
46+
- name: Strip binary (Unix)
47+
if: runner.os != 'Windows'
48+
run: strip target/${{ matrix.target }}/release/gribble
49+
50+
- name: Create archive (Unix)
51+
if: runner.os != 'Windows'
52+
run: |
53+
mkdir -p dist
54+
cp target/${{ matrix.target }}/release/gribble dist/gribble-${{ matrix.target }}
55+
tar -czf dist/gribble-${{ matrix.target }}.tar.gz -C dist gribble-${{ matrix.target }}
56+
57+
- name: Create archive (Windows)
58+
if: runner.os == 'Windows'
59+
run: |
60+
mkdir dist
61+
cp target/${{ matrix.target }}/release/gribble.exe dist/gribble-${{ matrix.target }}.exe
62+
powershell Compress-Archive -Path dist/gribble-${{ matrix.target }}.exe -DestinationPath dist/gribble-${{ matrix.target }}.zip
63+
64+
- name: Upload artifacts
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: gribble-${{ matrix.target }}
68+
path: dist/
69+
retention-days: 1
70+
71+
release:
72+
name: Create Release
73+
runs-on: ubuntu-latest
74+
needs: build
75+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
76+
77+
steps:
78+
- name: Checkout repository
79+
uses: actions/checkout@v4
80+
81+
- name: Download all artifacts
82+
uses: actions/download-artifact@v4
83+
with:
84+
path: artifacts/
85+
86+
- name: Prepare release assets
87+
run: |
88+
mkdir -p release-assets
89+
find artifacts -name "*.tar.gz" -exec cp {} release-assets/ \;
90+
find artifacts -name "*.zip" -exec cp {} release-assets/ \;
91+
92+
- name: Extract tag name
93+
id: tag
94+
run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
95+
96+
- name: Generate changelog
97+
id: changelog
98+
run: |
99+
# Get the previous tag
100+
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
101+
102+
if [ -n "$PREV_TAG" ]; then
103+
# Generate changelog from commits between tags
104+
CHANGELOG=$(git log --pretty=format:"- %s" $PREV_TAG..HEAD | head -20)
105+
else
106+
# First release - show recent commits
107+
CHANGELOG=$(git log --pretty=format:"- %s" --max-count=20)
108+
fi
109+
110+
echo "changelog<<EOF" >> $GITHUB_OUTPUT
111+
echo "$CHANGELOG" >> $GITHUB_OUTPUT
112+
echo "EOF" >> $GITHUB_OUTPUT
113+
114+
- name: Create Release
115+
uses: softprops/action-gh-release@v1
116+
with:
117+
tag_name: ${{ steps.tag.outputs.tag }}
118+
name: Release ${{ steps.tag.outputs.tag }}
119+
body: |
120+
## What's Changed
121+
122+
${{ steps.changelog.outputs.changelog }}
123+
124+
## Downloads
125+
126+
Choose the appropriate binary for your platform:
127+
- **Linux (x86_64)**: `gribble-x86_64-unknown-linux-gnu.tar.gz`
128+
- **Windows (x64)**: `gribble-x86_64-pc-windows-msvc.zip`
129+
- **macOS (Intel)**: `gribble-x86_64-apple-darwin.tar.gz`
130+
- **macOS (Apple Silicon)**: `gribble-aarch64-apple-darwin.tar.gz`
131+
132+
### Installation
133+
134+
**Linux/macOS:**
135+
```bash
136+
tar -xzf gribble-x86_64-unknown-linux-gnu.tar.gz
137+
sudo mv gribble-x86_64-unknown-linux-gnu /usr/local/bin/gribble
138+
```
139+
140+
**Windows:**
141+
Extract the zip file and add the directory to your PATH.
142+
files: release-assets/*
143+
draft: false
144+
prerelease: false
145+
env:
146+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,47 @@ Press `i` to show detailed information:
8989
- Minimum terminal size 80x24
9090
- Read permissions for system information
9191

92+
## Releases
93+
94+
Pre-built binaries are available for download on the [Releases page](https://github.com/Cod-e-Codes/gribble/releases).
95+
96+
### Supported Platforms
97+
98+
- **Linux (x86_64)** - `gribble-x86_64-unknown-linux-gnu.tar.gz`
99+
- **Windows (x64)** - `gribble-x86_64-pc-windows-msvc.zip`
100+
- **macOS (Intel)** - `gribble-x86_64-apple-darwin.tar.gz`
101+
- **macOS (Apple Silicon)** - `gribble-aarch64-apple-darwin.tar.gz`
102+
103+
### Installation
104+
105+
**Linux/macOS:**
106+
```bash
107+
# Download and extract
108+
tar -xzf gribble-x86_64-unknown-linux-gnu.tar.gz
109+
110+
# Make executable and move to PATH
111+
chmod +x gribble-x86_64-unknown-linux-gnu
112+
sudo mv gribble-x86_64-unknown-linux-gnu /usr/local/bin/gribble
113+
```
114+
115+
**Windows:**
116+
Extract the zip file and add the directory to your PATH environment variable.
117+
118+
## Development
119+
120+
### Creating a Release
121+
122+
Use the included release script to create a new version:
123+
124+
```bash
125+
./release.sh 1.0.0
126+
```
127+
128+
This will:
129+
- Update the version in `Cargo.toml`
130+
- Create and push a git tag
131+
- Trigger GitHub Actions to build and publish cross-platform binaries
132+
92133
## License
93134

94135
MIT License

release.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
3+
# Gribble Release Script
4+
# Usage: ./release.sh [version]
5+
# Example: ./release.sh 1.1.0
6+
7+
set -e
8+
9+
if [ $# -eq 0 ]; then
10+
echo "Usage: $0 [version]"
11+
echo "Example: $0 1.1.0"
12+
exit 1
13+
fi
14+
15+
VERSION=$1
16+
TAG="v$VERSION"
17+
18+
# Validate version format (basic check)
19+
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
20+
echo "Error: Version must be in format X.Y.Z (e.g., 1.1.0)"
21+
exit 1
22+
fi
23+
24+
# Check if we're on main branch
25+
CURRENT_BRANCH=$(git branch --show-current)
26+
if [ "$CURRENT_BRANCH" != "main" ]; then
27+
echo "Error: Must be on main branch to create a release. Current branch: $CURRENT_BRANCH"
28+
exit 1
29+
fi
30+
31+
# Check if working directory is clean
32+
if ! git diff-index --quiet HEAD --; then
33+
echo "Error: Working directory is not clean. Commit or stash your changes first."
34+
exit 1
35+
fi
36+
37+
# Check if tag already exists
38+
if git tag -l | grep -q "^$TAG$"; then
39+
echo "Error: Tag $TAG already exists"
40+
exit 1
41+
fi
42+
43+
# Update version in Cargo.toml if it exists
44+
if [ -f "Cargo.toml" ]; then
45+
echo "Updating version in Cargo.toml..."
46+
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml
47+
48+
# Commit version update
49+
git add Cargo.toml
50+
git commit -m "Bump version to $VERSION"
51+
fi
52+
53+
# Create and push tag
54+
echo "Creating tag $TAG..."
55+
git tag -a "$TAG" -m "Release $TAG"
56+
57+
echo "Pushing to origin..."
58+
git push origin main
59+
git push origin "$TAG"
60+
61+
echo ""
62+
echo "✅ Release $TAG created and pushed!"
63+
echo "🚀 GitHub Actions will now build and publish the release automatically."
64+
echo "📦 Check the Actions tab to monitor the build progress."

0 commit comments

Comments
 (0)