Skip to content

v0.7.7

v0.7.7 #19

Workflow file for this run

name: Create Release binaries
on:
release:
types: [created]
jobs:
buildallplatforms:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Mandatory to use the extract version from tag action
- name: Extract version from tag
id: get_version
uses: dhkatz/get-version-action@v3.0.0
- name: Add executive summary to release body
uses: softprops/action-gh-release@v2
with:
append_body: true
body: |
## 📦 gitsqlite Release
A Git clean/smudge/diff filter for storing SQLite databases in plain text SQL, enabling meaningful diffs and merges.
### Quick Start
1. Download the appropriate binary for your platform and make sure it is reachable from Git Bash (Path)
```bash
# Example for Windows
curl -L -o gitsqlite.exe https://github.com/danielsiegl/gitsqlite/releases/latest/download/gitsqlite-windows-amd64.exe
```
2. Install SQLite 3: `winget install SQLite.SQLite` (Windows) or `sudo apt install sqlite3` (Linux)
3. Configure Git filters:
```bash
echo '*.db filter=gitsqlite' >> .gitattributes
git config filter.gitsqlite.clean "gitsqlite clean"
git config filter.gitsqlite.smudge "gitsqlite smudge"
git config filter.gitsqlite.diff "gitsqlite diff"
```
### Available Binaries
- **Windows**: `gitsqlite-windows-amd64.exe`, `gitsqlite-windows-arm64.exe`
- **Linux**: `gitsqlite-linux-amd64`, `gitsqlite-linux-arm64`
- **macOS**: `gitsqlite-macos-arm64`
📖 **Full documentation**: [README.md](https://github.com/danielsiegl/gitsqlite/blob/main/README.md)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.24'
cache: false
- name: Build All Platforms
shell: pwsh
run: |
Write-Host "Building all platforms with version: ${{ steps.get_version.outputs.version }}" -ForegroundColor Green
# Get Git information for GitHub Actions context
$gitCommit = git rev-parse HEAD
$gitCommitShort = git rev-parse --short HEAD
$repoUrl = "${{ github.server_url }}/${{ github.repository }}"
$releaseTag = "${{ steps.get_version.outputs.version }}"
$gitBranch = "$repoUrl/releases/tag/$releaseTag"
$buildTime = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
# Remove 'v' prefix from version if present
$versionClean = "${{ steps.get_version.outputs.version }}".TrimStart('v')
$version = "$versionClean-$gitCommitShort"
Write-Host "Git commit: $gitCommitShort ($gitCommit)" -ForegroundColor Cyan
Write-Host "Git branch: $gitBranch" -ForegroundColor Cyan
Write-Host "Build time: $buildTime" -ForegroundColor Cyan
Write-Host "Version: $version" -ForegroundColor Cyan
# Create bin directory
$binDir = "bin"
if (-not (Test-Path -Path $binDir)) {
New-Item -ItemType Directory -Path $binDir | Out-Null
Write-Host "Created bin directory" -ForegroundColor Green
}
# Build function integrated from build.ps1
function Build-Platform {
param (
[string]$GOOS,
[string]$GOARCH = "amd64",
[string]$GitCommit,
[string]$GitBranch,
[string]$BuildTime,
[string]$Version
)
Write-Host "Building for $GOOS-$GOARCH..." -ForegroundColor Yellow
# Determine output filename based on OS
$outputFile = if ($GOOS -eq "windows") {
"gitsqlite-$GOOS-$GOARCH.exe"
} elseif ($GOOS -eq "darwin") {
"gitsqlite-macos-$GOARCH"
} else {
"gitsqlite-$GOOS-$GOARCH"
}
# Build ldflags with version information
$ldflagsString = "-X 'github.com/danielsiegl/gitsqlite/internal/version.GitCommit=$GitCommit' -X 'github.com/danielsiegl/gitsqlite/internal/version.GitBranch=$GitBranch' -X 'github.com/danielsiegl/gitsqlite/internal/version.BuildTime=$BuildTime' -X 'github.com/danielsiegl/gitsqlite/internal/version.Version=$Version'"
# Set environment variables and build
$env:GOOS = $GOOS
$env:GOARCH = $GOARCH
$env:CGO_ENABLED = "0"
Write-Host "Executing: go build -ldflags `"$ldflagsString`" -o `"$outputFile`"" -ForegroundColor Gray
& go build -ldflags $ldflagsString -o $outputFile
if ($LASTEXITCODE -ne 0) {
throw "Build failed for $GOOS-$GOARCH with exit code $LASTEXITCODE"
}
# Move to bin directory
Move-Item -Path $outputFile -Destination $binDir -Force
Write-Host "✓ Built and moved to bin directory: $binDir/$outputFile" -ForegroundColor Green
}
# Build for all platforms
try {
Build-Platform -GOOS "linux" -GOARCH "amd64" -GitCommit $gitCommit -GitBranch $gitBranch -BuildTime $buildTime -Version $version
Build-Platform -GOOS "linux" -GOARCH "arm64" -GitCommit $gitCommit -GitBranch $gitBranch -BuildTime $buildTime -Version $version
Build-Platform -GOOS "windows" -GOARCH "amd64" -GitCommit $gitCommit -GitBranch $gitBranch -BuildTime $buildTime -Version $version
Build-Platform -GOOS "windows" -GOARCH "arm64" -GitCommit $gitCommit -GitBranch $gitBranch -BuildTime $buildTime -Version $version
Build-Platform -GOOS "darwin" -GOARCH "arm64" -GitCommit $gitCommit -GitBranch $gitBranch -BuildTime $buildTime -Version $version
Write-Host "✓ All builds completed successfully!" -ForegroundColor Green
# List all built files
Write-Host "`nBuilt files:" -ForegroundColor Cyan
Get-ChildItem -Path $binDir | ForEach-Object {
$size = [math]::Round($_.Length / 1MB, 2)
Write-Host " $($_.Name) ($size MB)" -ForegroundColor White
}
} catch {
Write-Host "✗ Build failed: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}
- name: Upload Linux AMD64 Binary
uses: svenstaro/upload-release-action@2.9.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: bin/gitsqlite-linux-amd64
asset_name: gitsqlite-linux-amd64
tag: ${{ github.ref }}
overwrite: true
- name: Upload Linux ARM64 Binary
uses: svenstaro/upload-release-action@2.9.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: bin/gitsqlite-linux-arm64
asset_name: gitsqlite-linux-arm64
tag: ${{ github.ref }}
overwrite: true
- name: Upload Windows AMD64 Binary
uses: svenstaro/upload-release-action@2.9.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: bin/gitsqlite-windows-amd64.exe
asset_name: gitsqlite-windows-amd64.exe
tag: ${{ github.ref }}
overwrite: true
- name: Upload Windows ARM64 Binary
uses: svenstaro/upload-release-action@2.9.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: bin/gitsqlite-windows-arm64.exe
asset_name: gitsqlite-windows-arm64.exe
tag: ${{ github.ref }}
overwrite: true
- name: Upload macOS ARM64 Binary
uses: svenstaro/upload-release-action@2.9.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: bin/gitsqlite-macos-arm64
asset_name: gitsqlite-macos-arm64
tag: ${{ github.ref }}
overwrite: true