name: Release
on:
push:
tags:
- 'v*.*.*'
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test before release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Run tests
run: cargo test --verbose
build:
name: Build release binaries
needs: test
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
binary_name: csvlint
archive_ext: tar.gz
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
binary_name: csvlint
archive_ext: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
binary_name: csvlint.exe
archive_ext: zip
- os: macos-latest
target: x86_64-apple-darwin
binary_name: csvlint
archive_ext: tar.gz
- os: macos-latest
target: aarch64-apple-darwin
binary_name: csvlint
archive_ext: tar.gz
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install musl tools (Linux musl only)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
sudo apt update
sudo apt install -y musl-tools
- name: Cache cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }} --verbose
- name: Strip binary (Unix only)
if: matrix.os != 'windows-latest'
run: strip target/${{ matrix.target }}/release/${{ matrix.binary_name }}
- name: Create archive
shell: bash
run: |
staging="csvlint-${{ github.ref_name }}-${{ matrix.target }}"
mkdir -p "$staging"
# Copy binary
cp "target/${{ matrix.target }}/release/${{ matrix.binary_name }}" "$staging/"
# Copy additional files
cp README.md LICENSE "$staging/"
if [[ "${{ matrix.archive_ext }}" == "zip" ]]; then
7z a "$staging.zip" "$staging"/*
echo "ASSET=$staging.zip" >> $GITHUB_ENV
else
tar czf "$staging.tar.gz" "$staging"
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
fi
- name: Upload release artifact
uses: actions/upload-artifact@v4
with:
name: csvlint-${{ matrix.target }}
path: ${{ env.ASSET }}
release:
name: Create GitHub Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Generate release notes
run: |
# Extract version from tag
VERSION=${GITHUB_REF#refs/tags/}
echo "VERSION=$VERSION" >> $GITHUB_ENV
# Create release notes
cat > release_notes.md << EOF
# CSV Linter $VERSION
A fast CSV linter written in Rust that validates CSV files according to RFC 4180.
## 🎯 Features
- **Full RFC 4180 Compliance**: Strict validation mode with CRLF line ending checks
- **Multiple Delimiters**: Support for comma, tab, pipe, colon, and semicolon
- **Detailed Error Reports**: Specific error messages with record numbers
- **Cross-platform**: Binaries available for Linux, macOS, and Windows
## 📦 Installation
Download the appropriate binary for your platform from the assets below.
## 🚀 Usage
\`\`\`bash
# Basic validation
csvlint data.csv
# Strict RFC 4180 compliance
csvlint --rfc4180 data.csv
# Custom delimiter
csvlint --delimiter '\t' data.tsv
\`\`\`
## 📋 Assets
Choose the appropriate binary for your platform:
- **Linux (glibc)**: \`csvlint-$VERSION-x86_64-unknown-linux-gnu.tar.gz\`
- **Linux (musl)**: \`csvlint-$VERSION-x86_64-unknown-linux-musl.tar.gz\`
- **macOS (Intel)**: \`csvlint-$VERSION-x86_64-apple-darwin.tar.gz\`
- **macOS (Apple Silicon)**: \`csvlint-$VERSION-aarch64-apple-darwin.tar.gz\`
- **Windows**: \`csvlint-$VERSION-x86_64-pc-windows-msvc.zip\`
EOF
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
body_path: release_notes.md
files: artifacts/*/csvlint-*
generate_release_notes: true
prerelease: ${{ contains(github.ref_name, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-crate:
name: Publish to crates.io
needs: test
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref_name, '-')
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
docker:
name: Build and push Docker image
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: ghcr.io/${{ github.repository }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true