Skip to content

Conversation

blink-so[bot]
Copy link

@blink-so blink-so bot commented Sep 10, 2025

Overview

Adds comprehensive release automation with GitHub Actions to build and distribute jail binaries across Unix platforms, plus development tooling improvements.

🚀 Automated Releases

Release on Tags

Simply push a version tag to create a release:

git tag v1.0.0
git push origin v1.0.0

This automatically:

  • ✅ Builds binaries for 4 platforms
  • ✅ Creates compressed archives (.tar.gz)
  • ✅ Publishes GitHub release
  • ✅ Generates download instructions

Development Builds

Every push to main and PR creates artifacts:

  • ✅ Available in Actions tab
  • ✅ 30-day retention
  • ✅ Perfect for testing

💻 Supported Platforms

Platform Architecture Binary Archive
🐧 Linux x64 jail-linux-amd64 .tar.gz
🐧 Linux ARM64 jail-linux-arm64 .tar.gz
🍎 macOS Intel jail-darwin-amd64 .tar.gz
🍎 macOS Apple Silicon jail-darwin-arm64 .tar.gz

🛠️ Development Tools

Makefile

Added focused Makefile with core targets:

make build         # Build for current platform
make build-all     # Cross-platform builds
make test          # Run tests with race detection
make test-coverage # Generate coverage reports
make clean         # Clean build artifacts
make fmt           # Format code
make lint          # Lint code (requires golangci-lint)

Build Script

Local cross-platform build script:

./scripts/build.sh  # Builds all 4 platforms

🔧 Environment Preservation

Fixed sudo environment issues:

  • Automatic detection when running under sudo
  • Environment restoration for original user (USER, HOME, PATH, XDG_*)
  • Cross-platform support (Linux + macOS)
  • Transparent operation - no user intervention required

📁 Files Added/Modified

GitHub Actions Workflows

  • .github/workflows/release.yml: Automated releases on tags
  • .github/workflows/build.yml: Build artifacts on push/PR
  • .github/workflows/ci.yml: Updated to use Makefile targets

Development Tools

  • Makefile: Core build, test, clean targets
  • scripts/build.sh: Local cross-platform build script
  • main.go: Added version variable for build-time injection
  • .gitignore: Ignore local build directory

Environment Preservation

  • environment/sudo.go: Sudo detection and user environment restoration
  • network/linux.go: Updated to restore user environment
  • network/macos.go: Updated to restore user environment

Documentation

  • RELEASES.md: Focused release process documentation

🎯 Key Design Decisions

Unix-Only Focus

  • No Windows builds - jail requires root privileges and network namespaces
  • Consistent archives - .tar.gz for all platforms
  • Simplified workflows - no platform-specific handling

Simplified Tooling

  • Focused Makefile - core targets only, no system management
  • Direct dependencies - golangci-lint required (no fallbacks)
  • Clean workflows - removed redundant makefile-build workflow

Environment Handling

  • Automatic sudo detection - no configuration needed
  • Comprehensive restoration - USER, HOME, PATH, XDG directories
  • Backward compatible - no impact on non-sudo execution

🧪 Testing

  • ✅ Local build script creates all 4 binaries successfully
  • ✅ Makefile targets work correctly (build, test, clean)
  • ✅ Environment restoration tested with sudo scenarios
  • ✅ Cross-compilation tested for all target platforms
  • ✅ Version injection works with git tags and dev builds
  • ✅ All workflows use proper caching and optimization

📦 Usage After Merge

For Users

  1. Go to Releases
  2. Download binary for your platform
  3. Extract and install: tar -xzf jail-*.tar.gz && chmod +x jail && sudo mv jail /usr/local/bin/

For Developers

  1. Local development: make build, make test, make clean
  2. Cross-platform builds: make build-all or ./scripts/build.sh
  3. Create releases: git tag v1.0.0 && git push origin v1.0.0

For Sudo Users

  • Just works: sudo jail --allow "github.com" -- curl https://github.com
  • Preserves environment: Subprocess gets your user environment, not root's

This provides a complete development and release pipeline with proper environment handling! 🎉

blink-so bot and others added 8 commits September 10, 2025 00:15
Added GitHub Actions workflows for:
- Automated releases on version tags
- Cross-platform binary builds (Linux, macOS, Windows)
- Artifact uploads for testing
- Local build script for development

Supports 6 platforms: Linux/macOS/Windows x amd64/arm64

Co-authored-by: f0ssel <[email protected]>
Removed Windows platform support from:
- GitHub Actions release workflow
- GitHub Actions build workflow
- Local build script
- Documentation

Now supports 4 platforms:
- Linux: amd64, arm64
- macOS: amd64 (Intel), arm64 (Apple Silicon)

All builds create .tar.gz archives for consistency.

Co-authored-by: f0ssel <[email protected]>
Added comprehensive Makefile with targets:
- make build: Build for current platform
- make build-all: Cross-platform builds
- make test: Run tests
- make clean: Clean artifacts
- make install/uninstall: System installation
- make help: Show all targets

Includes version injection, coverage reports, and development tools.

Co-authored-by: f0ssel <[email protected]>
Updated workflows to use Makefile targets for consistency:

## CI Workflow
- Use 'make tidy' instead of 'go mod download' + 'go mod verify'
- Use 'make test' instead of 'go test -v -race ./...'
- Use 'make build' instead of 'go build -v ./...'

## Build & Release Workflows
- Use 'make tidy' for dependency management
- Keep direct Go commands for cross-compilation (needed for matrix builds)
- Maintain parallel builds for different platforms

## New Makefile Build Workflow
- Added weekly workflow that demonstrates 'make build-all'
- Builds all platforms in single job using Makefile
- Manual trigger available for testing
- Uploads all binaries as single artifact

This ensures consistency between local development (using Makefile)
and CI/CD (using same Makefile targets where appropriate).

Tested: make tidy && make test && make build works correctly.

Co-authored-by: f0ssel <[email protected]>
…lp targets

Removed targets that are not core to build/test workflow:
- install/uninstall: System installation should be manual
- tidy: Direct go mod commands are clearer in workflows
- dev-setup: Too opinionated for a build tool
- help: Makefile is simple enough without help

Remaining focused targets:
- build: Build for current platform
- build-all: Cross-platform builds
- test: Run tests with race detection
- test-coverage: Generate coverage reports
- clean: Clean build artifacts
- fmt: Format code
- lint: Lint code

Updated GitHub Actions workflows to use direct Go commands
for dependency management instead of removed make tidy.

Updated RELEASES.md to reflect simplified Makefile.

Tested: make build && make test && make clean works correctly.

Co-authored-by: f0ssel <[email protected]>
Simplified the lint target to just run golangci-lint directly
instead of falling back to go vet when golangci-lint is not available.

Before:
- Complex shell logic to check if golangci-lint exists
- Fallback to go vet if not found
- Confusing behavior (different tools run depending on environment)

After:
- Simple: golangci-lint run
- Clear error if golangci-lint not installed
- Consistent behavior across environments

Updated RELEASES.md to document the golangci-lint requirement.

Tested: make lint fails cleanly with clear error when golangci-lint missing.

Co-authored-by: f0ssel <[email protected]>
Removed .github/workflows/makefile-build.yml as it duplicated
the functionality of the existing build.yml workflow.

The makefile-build workflow was added to demonstrate make build-all
but it created unnecessary duplication:

- build.yml: Builds on push/PR with matrix for parallel builds
- makefile-build.yml: Weekly + manual trigger using make build-all

The existing build.yml workflow already provides:
- Cross-platform builds for all supported platforms
- Artifact uploads for testing
- Triggered on every push/PR for immediate feedback

Users can run 'make build-all' locally if they want to build
all platforms in a single command.

Now we have a clean, focused workflow structure:
- ci.yml: Testing and verification
- build.yml: Cross-platform binary builds
- release.yml: Automated releases on tags

Co-authored-by: f0ssel <[email protected]>
Removed all development-related content from RELEASES.md:

## Removed Sections
- Local Development (Makefile usage, build scripts)
- Development Builds (GitHub Actions artifacts)
- Manual cross-compilation examples
- Build troubleshooting
- Version injection examples

## Kept Release-Focused Content
- Automated release process (git tag workflow)
- Supported platforms table
- Release process for maintainers
- Version naming conventions
- Installation from GitHub releases
- Release troubleshooting

The file now focuses exclusively on:
1. How to cut a release (git tag v1.0.0)
2. What gets built and released
3. How users install releases
4. Troubleshooting release issues

Development information belongs in README.md or separate docs,
not in a release-focused document.

Co-authored-by: f0ssel <[email protected]>
@f0ssel f0ssel merged commit 9ab4f79 into main Sep 10, 2025
7 checks passed
@f0ssel f0ssel deleted the blink/add-release-automation branch September 16, 2025 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant