Skip to content

Commit 5caa7be

Browse files
authored
ci: add publish workflow (#8)
1 parent f0d2d60 commit 5caa7be

6 files changed

Lines changed: 138 additions & 29 deletions

File tree

.github/workflows/publish.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
# Run all tests first using the reusable workflow
13+
tests:
14+
uses: ./.github/workflows/tests.yml
15+
16+
# Publish job that depends on tests passing
17+
publish:
18+
name: Publish to crates.io
19+
needs: tests
20+
runs-on: ubuntu-latest
21+
environment: publish
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Install Rust
27+
uses: dtolnay/rust-toolchain@stable
28+
with:
29+
toolchain: stable
30+
31+
- name: Setup Rust cache
32+
uses: Swatinem/rust-cache@v2
33+
34+
- name: Verify version matches tag
35+
run: |
36+
# Extract version from Cargo.toml
37+
CARGO_VERSION=$(grep -E '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
38+
39+
# Get the git tag without the 'v' prefix
40+
TAG_VERSION=${GITHUB_REF_NAME#v}
41+
42+
echo "Cargo.toml version: $CARGO_VERSION"
43+
echo "Git tag version: $TAG_VERSION"
44+
45+
if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then
46+
echo "Error: Version mismatch!"
47+
echo "Cargo.toml has version $CARGO_VERSION but git tag is $GITHUB_REF_NAME"
48+
exit 1
49+
fi
50+
51+
echo "Version check passed!"
52+
53+
- name: Build release
54+
run: cargo build --release --verbose
55+
56+
- name: Publish to crates.io
57+
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
58+
env:
59+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- main
77
pull_request:
8+
workflow_call:
89

910
env:
1011
CARGO_TERM_COLOR: always

CONTRIBUTING.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,54 @@ sudo pfctl -a httpjail -sr
163163
sudo pfctl -a httpjail -F all
164164
```
165165

166+
## Release Process
167+
168+
### Publishing a New Version
169+
170+
Releases are automated through GitHub Actions when a version tag is pushed. The process:
171+
172+
1. **Update version in Cargo.toml**
173+
```bash
174+
# Edit Cargo.toml and update the version field
175+
# Example: version = "0.2.0"
176+
```
177+
178+
2. **Commit the version change**
179+
```bash
180+
git add Cargo.toml
181+
git commit -m "Bump version to 0.2.0"
182+
git push
183+
```
184+
185+
3. **Create and push a version tag**
186+
```bash
187+
# Tag format must be v<version> matching Cargo.toml version
188+
git tag v0.2.0
189+
git push origin v0.2.0
190+
```
191+
192+
4. **Automated release workflow**
193+
- The GitHub Actions workflow will automatically:
194+
- Run all tests (macOS, Linux, weak mode)
195+
- Run clippy and format checks
196+
- Verify the tag version matches Cargo.toml
197+
- Build the release binary
198+
- Publish to crates.io (only if all tests pass)
199+
200+
### Prerequisites for Publishing
201+
202+
- **GitHub Environment**: The `publish` environment must be configured in the repository settings
203+
- **Cargo Token**: The `CARGO_REGISTRY_TOKEN` secret must be set in the `publish` environment
204+
- **Version Match**: The git tag (without `v` prefix) must exactly match the version in Cargo.toml
205+
206+
### Manual Publishing (if needed)
207+
208+
If automated publishing fails, you can publish manually:
209+
210+
```bash
211+
cargo publish --token <your-token>
212+
```
213+
166214
## License
167215

168216
By contributing to httpjail, you agree that your contributions will be licensed under the same license as the project.

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "httpjail"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
edition = "2024"
55
license = "CC0-1.0"
66
description = "Monitor and restrict HTTP/HTTPS requests from processes"

README.md

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,32 @@
11
# httpjail
22

3+
[![Crates.io](https://img.shields.io/crates/v/httpjail.svg)](https://crates.io/crates/httpjail)
4+
[![CI](https://github.com/coder/httpjail/actions/workflows/tests.yml/badge.svg)](https://github.com/coder/httpjail/actions/workflows/tests.yml)
5+
36
A cross-platform tool for monitoring and restricting HTTP/HTTPS requests from processes using network isolation and transparent proxy interception.
47

8+
## Installation
9+
10+
### Install via Cargo
11+
12+
```bash
13+
cargo install httpjail
14+
```
15+
16+
### Install from source
17+
18+
```bash
19+
# Clone the repository
20+
git clone https://github.com/coder/httpjail
21+
cd httpjail
22+
23+
# Build with Cargo
24+
cargo build --release
25+
26+
# Install to PATH
27+
sudo cp target/release/httpjail /usr/local/bin/
28+
```
29+
530
## Features
631

732
- 🔒 **Process-level network isolation** - Isolate processes in restricted network environments
@@ -96,44 +121,20 @@ httpjail creates an isolated network environment for the target process, interce
96121
| Sudo required | ⚠️ Yes | ✅ No | 🚧 |
97122
| Force all traffic | ✅ Yes | ❌ No (apps must cooperate) | 🚧 |
98123

99-
## Installation
100-
101-
### Prerequisites
124+
## Prerequisites
102125

103-
#### Linux
126+
### Linux
104127

105128
- Linux kernel 3.8+ (network namespace support)
106129
- nftables (nft command)
107130
- libssl-dev (for TLS)
108131
- sudo access (for namespace creation)
109132

110-
#### macOS
133+
### macOS
111134

112135
- macOS 10.15+ (Catalina or later)
113136
- No special permissions required (runs in weak mode)
114137

115-
### Install from source
116-
117-
```bash
118-
# Clone the repository
119-
git clone https://github.com/yourusername/httpjail
120-
cd httpjail
121-
122-
# Build with Cargo
123-
cargo build --release
124-
125-
# Install to PATH
126-
sudo cp target/release/httpjail /usr/local/bin/
127-
128-
# CA certificate is auto-generated on first run
129-
```
130-
131-
### Install via Cargo
132-
133-
```bash
134-
cargo install httpjail
135-
```
136-
137138
## Usage Examples
138139

139140
### Basic Usage

0 commit comments

Comments
 (0)