Workspace is a tool suite for file operations, version management, and development workflow automation. Includes refac (string replacement), scrap (local trash folder), unscrap (file restoration), and st8 (automatic versioning).
St8 is an automatic version management tool that integrates with Git to provide semantic versioning based on your repository’s commit history. It calculates version numbers using git tags, commit counts, and change statistics, making it perfect for continuous integration workflows.
St8 uses a three-part versioning scheme based on your Git repository:
v1.0
→ 1.0
)Final Version Format: {major}.{minor}.{patch}
# Repository state:
# - Latest tag: v2.1
# - Commits since tag: 5
# - Total changes: 247
# Result: 2.1.5.247
First, ensure st8 is installed as part of the Workspace tool suite:
# Install all tools including st8
./install.sh
# Or install just st8
cargo install --path . --bin st8
Navigate to your Git repository and install the pre-commit hook:
cd your-git-repo
st8 install
This creates a pre-commit hook that automatically updates your version file before each commit.
Create a .st8.json
configuration file in your repository root:
{
"version": 1,
"enabled": true,
"version_file": "version.txt"
}
Configuration Options:
enabled
: Enable/disable automatic version updatesversion_file
: Path to the file where version should be written (default: version.txt
)auto_detect_project_files
: Automatically detect and update common project files (default: true
)project_files
: Array of additional project files to update (relative to repository root)# Install pre-commit hook
st8 install
# Force reinstall (if already installed)
st8 install --force
# Display current version breakdown
st8 show
Output example:
Current Version Information:
Major (tag): v1.2
Minor (commits since tag): 3
Patch (total changes): 156
Full Version: 1.2.3.156
# Update version file manually
st8 update
# Update even outside git repo
st8 update --no-git
# Update and automatically stage changed files
ws update --git-add
# Show st8 status and configuration
st8 status
Output example:
St8 Status:
Git Repository: ✓
Hook Installed: ✓
Enabled: ✓
Version File: version.txt
Current Version: 1.2.3.156
Version File Exists: ✓
Auto-detect Project Files: ✓
Detected Project Files:
• /path/to/repo/Cargo.toml (Cargo.toml)
• /path/to/repo/package.json (package.json)
# Remove st8 from pre-commit hooks
st8 uninstall
st8 install
version.txt
(or custom version file)If you prefer manual control:
"enabled": false
in .st8.json
st8 update
when neededws update --git-add
to automatically stage updated filesInclude version information in your build scripts:
#!/bin/bash
# Get current version
VERSION=$(cat version.txt)
echo "Building version: $VERSION"
# Use in build process
docker build -t myapp:$VERSION .
St8 automatically detects and updates version fields in common project configuration files:
Supported File Types:
version = "x.y.z"
in [package]
section"version": "x.y.z"
version = "x.y.z"
in [tool.poetry]
and [project]
sectionsversion="x.y.z"
parameter"version": "x.y.z"
version: x.y.z
<version>x.y.z</version>
version = 'x.y.z'
VERSION x.y.z
in project()
declarationConfiguration Example:
{
"version": 1,
"enabled": true,
"version_file": "version.txt",
"auto_detect_project_files": true,
"project_files": ["custom-config.json", "VERSION"]
}
How It Works:
auto_detect_project_files
is true
(default), st8 scans the repository root for supported project filesproject_files
are also updated (if they exist and st8 can detect their type)Disable Auto-Detection:
{
"auto_detect_project_files": false
}
Configure different version file paths:
{
"version_file": "src/version.rs"
}
St8 writes just the version number to the file:
1.2.3.156
You can incorporate this into different file formats using scripts:
Rust example:
# Update Rust version constant
echo "pub const VERSION: &str = \"$(cat version.txt)\";" > src/version.rs
JavaScript example:
# Update package.json version
jq --arg version "$(cat version.txt)" '.version = $version' package.json > package.json.tmp
mv package.json.tmp package.json
Each repository can have its own st8 configuration:
# Project A
cd project-a
st8 install
echo '{"version_file": "VERSION"}' > .st8.json
# Project B
cd project-b
st8 install
echo '{"version_file": "src/version.txt"}' > .st8.json
If the version isn’t updating automatically:
st8 status
ls -la .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
which st8
If version calculations seem wrong:
git status
git tag -l
git log --oneline
st8 show
If configuration isn’t working:
cat .st8.json | jq .
ls -la .st8.json
To completely remove st8 from a repository:
# Remove git hook
st8 uninstall
# Remove configuration (optional)
rm .st8.json
# Remove version file (optional)
rm version.txt
St8 logs all actions to .ws/st8/logs/st8.log
in your repository:
# View recent actions
tail -f .ws/st8/logs/st8.log
# Monitor in real-time
tail -f .ws/st8/logs/st8.log
Log format:
[2024-07-19 14:30:15] Created new pre-commit hook: /path/to/repo/.git/hooks/pre-commit
[2024-07-19 14:30:45] Updated version to: 1.2.3.156 (file: version.txt)
[2024-07-19 14:31:02] Rendered template: src/version.h
The log file is automatically created when st8 performs operations and is stored in the centralized .ws
state directory along with templates and other tool configurations.
git tag v1.0
)For projects using multiple technologies:
# Project structure:
# ├── Cargo.toml (Rust backend)
# ├── package.json (Node.js frontend)
# ├── pyproject.toml (Python scripts)
# └── .st8.json
# St8 automatically updates all three files:
git commit -m "Add new feature"
# → Cargo.toml version updated to 1.2.5.234
# → package.json version updated to 1.2.5.234
# → pyproject.toml version updated to 1.2.5.234
{
"version": 1,
"enabled": true,
"version_file": "VERSION",
"auto_detect_project_files": true,
"project_files": [
"apps/web/package.json",
"services/api/Cargo.toml",
"docs/conf.py"
]
}
# Copy version file
COPY version.txt /app/version.txt
# Use in build args
ARG VERSION
RUN echo "Building version: $VERSION"
- name: Get Version
id: version
run: echo "version=$(cat version.txt)" >> $GITHUB_OUTPUT
- name: Create Release
uses: actions/create-release@v1
with:
tag_name: v$
release_name: Release $
VERSION := $(shell cat version.txt)
build:
@echo "Building version $(VERSION)"
cargo build --release
release: build
git tag v$(VERSION)
git push origin v$(VERSION)