Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f201939
ci: add GitHub release workflow with dynamic versioning
nerdCopter Dec 4, 2025
0ddc469
fix: github-release workflow - wire inputs, outputs, tags, and upgrad…
nerdCopter Dec 9, 2025
1259466
refactor: simplify github-release workflow (Option B)
nerdCopter Dec 9, 2025
b1df57e
improve: add format validation and explicit error handling in github-…
nerdCopter Dec 9, 2025
b537015
Merge branch 'master' into 20251204_vergen_CI
nerdCopter Dec 9, 2025
9125c08
refactor: consolidate release workflows - remove github-release.yml
nerdCopter Dec 9, 2025
1babe27
feat: include full version info (semver + vergen) in CLI and release …
nerdCopter Dec 9, 2025
f86b1e9
fix: extract version on all platforms in release workflow
nerdCopter Dec 9, 2025
5dd4366
refactor: remove duplicate version extraction from publish-crates job
nerdCopter Dec 9, 2025
2318223
refactor: move version extraction out of matrix to separate job
nerdCopter Dec 9, 2025
1d5ccbb
fix: remove unconditional version print and replace gh-release action…
nerdCopter Dec 9, 2025
1a327d6
fix: harden version extraction step in release workflow
nerdCopter Dec 9, 2025
47fa5c7
fix: add build info to release notes in GitHub release workflow
nerdCopter Dec 9, 2025
26778a1
refactor: extract version from Cargo.toml and git, not from binary
nerdCopter Dec 9, 2025
db57cc3
fix: align release notes date with binary output and prevent race con…
nerdCopter Dec 10, 2025
79ff3ac
feat: add status indicators throughout release workflow for better vi…
nerdCopter Dec 10, 2025
47b2e93
refactor: use prebuilt artifact for version verification instead of r…
nerdCopter Dec 10, 2025
bd9977e
ci,build: eliminate duplicate builds in release workflow
nerdCopter Dec 10, 2025
8cc806a
docs: add GitHub Actions & workflow design guidelines to AGENTS.md
nerdCopter Dec 10, 2025
8a09dca
docs: condense GitHub Actions guidelines in AGENTS.md
nerdCopter Dec 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Build and Test
on:
push:
branches: [main, master]
tags:
- 'v*'
pull_request:
branches: [main, master]

Expand Down Expand Up @@ -88,13 +90,13 @@ jobs:
matrix:
include:
- os: ubuntu-latest
artifact_name: bbl_parser-linux
artifact_name: bbl_parser-linux-x64
binary_path: target/release/bbl_parser
- os: windows-latest
artifact_name: bbl_parser-windows
artifact_name: bbl_parser-windows-x64
binary_path: target/release/bbl_parser.exe
- os: macos-latest
artifact_name: bbl_parser-macos
artifact_name: bbl_parser-macos-x64
binary_path: target/release/bbl_parser

steps:
Expand Down
156 changes: 135 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ on:

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
publish:
publish-crates:
name: Publish to crates.io
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
Comment thread
coderabbitai[bot] marked this conversation as resolved.
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -21,28 +21,142 @@ jobs:
with:
toolchain: stable

- name: Cache cargo dependencies
uses: actions/cache@v4
- name: Publish to crates.io
run: |
cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
echo "✅ Successfully published to crates.io"

download-ci-artifacts:
name: Download CI Build Artifacts
runs-on: ubuntu-latest
strategy:
matrix:
artifact_name:
- bbl_parser-linux-x64
- bbl_parser-windows-x64
- bbl_parser-macos-x64
steps:
- name: Download artifact from CI workflow using GitHub CLI
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
# Find the most recent successful ci.yml run for this commit
RUN_ID=$(gh run list \
--workflow=ci.yml \
--commit=${{ github.sha }} \
--status=success \
--limit=1 \
--json databaseId \
--jq '.[0].databaseId')

if [ -z "$RUN_ID" ]; then
echo "❌ No successful ci.yml run found for commit ${{ github.sha }}"
echo "Make sure ci.yml completed successfully before publishing release"
exit 1
fi

echo "📦 Downloading ${{ matrix.artifact_name }} from run ID: $RUN_ID"

# Download the artifact
gh run download "$RUN_ID" \
--name "${{ matrix.artifact_name }}" \
--dir ./artifacts/${{ matrix.artifact_name }}

echo "✅ Successfully downloaded ${{ matrix.artifact_name }}"

- name: Re-upload artifact for release workflow
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: ./artifacts/${{ matrix.artifact_name }}/*
overwrite: true
if-no-files-found: error

determine-version:
name: Extract Version Information
needs: download-ci-artifacts
runs-on: ubuntu-latest
outputs:
build_info: ${{ steps.extract.outputs.build_info }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Extract version from Cargo.toml and git
id: extract
run: |
set -e

# Extract semver from Cargo.toml
SEMVER=$(grep '^version' Cargo.toml | head -1 | cut -d'"' -f2)

# Get git info from GitHub context
GIT_SHA="${{ github.sha }}"
GIT_SHA_SHORT="${GIT_SHA:0:7}"

# Get git commit date from repository (matches VERGEN_GIT_COMMIT_DATE in binary)
GIT_COMMIT_DATE=$(git log -1 --format=%ci "${{ github.sha }}" | cut -d' ' -f1)

# Format version string to match binary output
BUILD_INFO="${SEMVER} ${GIT_SHA_SHORT} (${GIT_COMMIT_DATE})"

echo "✅ Extracted version: $BUILD_INFO"

# Write output with proper quoting
echo "build_info<<EOF" >> $GITHUB_OUTPUT
echo "$BUILD_INFO" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

Comment thread
coderabbitai[bot] marked this conversation as resolved.
- name: Download Linux binary artifact
uses: actions/download-artifact@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Verify version matches tag
name: bbl_parser-linux-x64
path: ./binary-check

- name: Verify version consistency
env:
EXPECTED: ${{ steps.extract.outputs.build_info }}
run: |
CARGO_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
TAG_VERSION=${GITHUB_REF#refs/tags/v}
if [[ "$CARGO_VERSION" != "$TAG_VERSION" ]]; then
echo "Version mismatch: Cargo.toml has $CARGO_VERSION, tag is v$TAG_VERSION"
set -e

chmod +x ./binary-check/bbl_parser
BINARY_VERSION=$(./binary-check/bbl_parser -V)
if [ "$BINARY_VERSION" = "$EXPECTED" ]; then
echo "✅ Version match confirmed: binary='$BINARY_VERSION'"
else
echo "❌ Version mismatch detected:"
echo " Binary output: '$BINARY_VERSION'"
echo " Expected: '$EXPECTED'"
exit 1
fi

- name: Run tests
run: cargo test --all-features
upload-release-assets:
name: Upload Assets to GitHub Release
needs: [download-ci-artifacts, determine-version]
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: release-artifacts

- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Upload release assets
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
BUILD_INFO="${{ needs.determine-version.outputs.build_info }}"

# Upload all artifacts for this release
gh release upload "${{ github.ref_name }}" release-artifacts/*/* \
--repo "$GH_REPO" \
--clobber

# Update release notes with build information
gh release edit "${{ github.ref_name }}" \
--notes "**Build Information:** $BUILD_INFO" \
--repo "$GH_REPO"
Comment thread
coderabbitai[bot] marked this conversation as resolved.
echo "✅ Release notes updated with build information"
echo ""
echo "🎉 Release complete! Version $BUILD_INFO is now live."
6 changes: 6 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
## Data Validation
- **REQUIRED:** The CSV output must precisely match the format and header order of blackbox_decode CSV files.

## GitHub Actions & Workflow Design
- **Prefer native tooling:** Use GitHub Actions features, `git` CLI, `gh` CLI (not third-party actions).
- **Reuse artifacts:** Build once (ci.yml), download in downstream jobs (release.yml) — ~8-10x faster, lower costs.
- **Explicit dependencies:** Use `needs:` clauses for job ordering; validate upstream success before proceeding.
- **Error handling:** Validate artifacts exist; use `set -e` in scripts; provide clear error messages.

## Committing Rules
- **Commit Conditions:** Only commit if:
- `cargo clippy --all-targets --all-features -- -D warnings` passes.
Expand Down
15 changes: 6 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ use bbl_parser::types::{BBLHeader, DecodedFrame, FrameDefinition, FrameStats};
// Import ExportOptions from crate library
use bbl_parser::ExportOptions;

// Include vergen generated environment variables
const GIT_SHA: &str = env!("VERGEN_GIT_SHA", "unknown");
const GIT_COMMIT_DATE: &str = env!("VERGEN_GIT_COMMIT_DATE", "unknown");

// Build version string from git info
// Build version string with semver + git info
// Format: "0.9.0 14be1ee (2025-12-04)"
const VERSION_STR: &str = concat!(
env!("CARGO_PKG_VERSION"),
" ",
env!("VERGEN_GIT_SHA", "unknown"),
" (",
env!("VERGEN_GIT_COMMIT_DATE", "unknown"),
Expand Down Expand Up @@ -259,10 +258,8 @@ fn should_have_frame(frame_index: u32, sysconfig: &HashMap<String, i32>) -> bool
}

fn build_command() -> Command {
let about_text = format!(
"\n\nRead and parse BBL blackbox log files. Exports to CSV by default (optionally GPX/JSON).\n {} {} ({})",
env!("CARGO_PKG_NAME"), GIT_SHA, GIT_COMMIT_DATE
);
let about_text =
"Read and parse BBL blackbox log files. Exports to CSV by default (optionally GPX/JSON).";

Command::new(env!("CARGO_PKG_NAME"))
.version(VERSION_STR)
Expand Down