Skip to content

feat(cli): make rate-limit, max-retries, concurrent-downloads and bat… #117

feat(cli): make rate-limit, max-retries, concurrent-downloads and bat…

feat(cli): make rate-limit, max-retries, concurrent-downloads and bat… #117

Workflow file for this run

name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-*'
permissions:
contents: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
name: Build (${{ matrix.platform }})
strategy:
matrix:
include:
- os: macos-15
platform: macos
build-path: apple/Products/Release
archive-name: exfig-macos
- os: ubuntu-latest
platform: linux-x64
build-path: x86_64-unknown-linux-gnu/release
archive-name: exfig-linux-x64
container: swift:6.3-jammy
extra-flags: --static-swift-stdlib -Xlinker -lcurl -Xlinker -lxml2 -Xlinker -lssl -Xlinker -lcrypto -Xlinker -lz
- os: windows-latest
platform: windows-x64
build-path: x86_64-unknown-windows-msvc/release
archive-name: exfig-windows-x64
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
- name: Install Git LFS (Linux)
if: matrix.platform == 'linux-x64'
run: |
apt-get update
apt-get install -y git-lfs
git lfs install
- uses: actions/checkout@v6
with:
lfs: true
- name: Install Swift (Windows)
if: matrix.platform == 'windows-x64'
uses: compnerd/gha-setup-swift@v0.3.0
with:
branch: swift-6.3-release
tag: 6.3-RELEASE
- name: Install Swift 6.3 toolchain (macOS)
if: matrix.platform == 'macos'
run: |
curl -fLo swift-6.3.pkg "https://download.swift.org/swift-6.3-release/xcode/swift-6.3-RELEASE/swift-6.3-RELEASE-osx.pkg"
sudo installer -pkg swift-6.3.pkg -target /
TOOLCHAINS=$(plutil -extract CFBundleIdentifier raw /Library/Developer/Toolchains/swift-6.3-RELEASE.xctoolchain/Info.plist)
echo "TOOLCHAINS=$TOOLCHAINS" >> "$GITHUB_ENV"
- name: Install system dependencies (Linux)
if: matrix.platform == 'linux-x64'
run: |
apt-get install -y libcurl4-openssl-dev libxml2-dev libssl-dev
- name: Set version from tag (Unix)
if: matrix.platform != 'windows-x64'
run: |
VERSION="${GITHUB_REF#refs/tags/}"
FILE="Sources/ExFigCLI/ExFigCommand.swift"
if [ "${{ matrix.platform }}" = "macos" ]; then
sed -i '' "s/static let version = \".*\"/static let version = \"$VERSION\"/" "$FILE"
else
sed -i "s/static let version = \".*\"/static let version = \"$VERSION\"/" "$FILE"
fi
- name: Set version from tag (Windows)
if: matrix.platform == 'windows-x64'
shell: pwsh
run: |
$version = $env:GITHUB_REF -replace '^refs/tags/', ''
$file = "Sources/ExFigCLI/ExFigCommand.swift"
(Get-Content $file) -replace 'static let version = ".*"', "static let version = `"$version`"" | Set-Content $file
- name: Build release binary (macOS)
if: matrix.platform == 'macos'
run: |
# Build each architecture separately to avoid xcodebuild issues with binary targets
swift build -c release --arch arm64
swift build -c release --arch x86_64
# Create universal binary
mkdir -p .build/apple/Products/Release
lipo -create \
.build/arm64-apple-macosx/release/exfig \
.build/x86_64-apple-macosx/release/exfig \
-output .build/apple/Products/Release/exfig
# Copy resource bundles from arm64 build (they're arch-independent)
cp -r .build/arm64-apple-macosx/release/*.bundle .build/apple/Products/Release/
- name: Build release binary (Linux)
if: matrix.platform == 'linux-x64'
run: swift build -c release ${{ matrix.extra-flags }}
- name: Build release binary (Windows)
if: matrix.platform == 'windows-x64'
run: swift build -c release
- name: Create release archive (macOS)
if: matrix.platform == 'macos'
run: |
mkdir -p dist
cp .build/${{ matrix.build-path }}/exfig dist/ExFig
cp -r .build/${{ matrix.build-path }}/exfig_AndroidExport.bundle dist/
cp -r .build/${{ matrix.build-path }}/exfig_XcodeExport.bundle dist/
cp -r .build/${{ matrix.build-path }}/exfig_FlutterExport.bundle dist/
cp -r .build/${{ matrix.build-path }}/exfig_WebExport.bundle dist/
cp -r .build/${{ matrix.build-path }}/exfig_ExFigCLI.bundle dist/
cp LICENSE dist/
cd dist && zip -r ../${{ matrix.archive-name }}.zip .
- name: Create release archive (Linux)
if: matrix.platform == 'linux-x64'
run: |
mkdir -p dist
cp .build/${{ matrix.build-path }}/exfig dist/ExFig
cp -r .build/${{ matrix.build-path }}/exfig_AndroidExport.resources dist/
cp -r .build/${{ matrix.build-path }}/exfig_XcodeExport.resources dist/
cp -r .build/${{ matrix.build-path }}/exfig_FlutterExport.resources dist/
cp -r .build/${{ matrix.build-path }}/exfig_WebExport.resources dist/
cp -r .build/${{ matrix.build-path }}/exfig_ExFigCLI.resources dist/
cp LICENSE dist/
cd dist && tar -czf ../${{ matrix.archive-name }}.tar.gz -- *
- name: Create release archive (Windows)
if: matrix.platform == 'windows-x64'
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path dist
Copy-Item ".build/${{ matrix.build-path }}/exfig.exe" "dist/ExFig.exe"
# Resource bundles are optional — not all modules produce them on every build config
Copy-Item ".build/${{ matrix.build-path }}/exfig_AndroidExport.resources" "dist/" -Recurse -ErrorAction SilentlyContinue
Copy-Item ".build/${{ matrix.build-path }}/exfig_XcodeExport.resources" "dist/" -Recurse -ErrorAction SilentlyContinue
Copy-Item ".build/${{ matrix.build-path }}/exfig_FlutterExport.resources" "dist/" -Recurse -ErrorAction SilentlyContinue
Copy-Item ".build/${{ matrix.build-path }}/exfig_WebExport.resources" "dist/" -Recurse -ErrorAction SilentlyContinue
Copy-Item ".build/${{ matrix.build-path }}/exfig_ExFigCLI.resources" "dist/" -Recurse -ErrorAction SilentlyContinue
Copy-Item "LICENSE" "dist/"
Compress-Archive -Path "dist/*" -DestinationPath "${{ matrix.archive-name }}.zip"
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.archive-name }}
path: |
${{ matrix.archive-name }}.zip
${{ matrix.archive-name }}.tar.gz
if-no-files-found: ignore
update-version:
name: Update Version and Changelog
needs: build
if: ${{ !contains(github.ref, '-') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: main
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update version in main branch
run: |
VERSION="${GITHUB_REF#refs/tags/}"
FILE="Sources/ExFigCLI/ExFigCommand.swift"
sed -i "s/static let version = \".*\"/static let version = \"$VERSION\"/" "$FILE"
sed -i "s/version = \".*\"/version = \"${VERSION#v}\"/" "Sources/ExFigCLI/Resources/Schemas/PklProject"
- name: Update CHANGELOG.md
uses: orhun/git-cliff-action@v4
with:
config: cliff.toml
args: --output CHANGELOG.md
env:
GITHUB_REPO: ${{ github.repository }}
- name: Commit and push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Sources/ExFigCLI/ExFigCommand.swift Sources/ExFigCLI/Resources/Schemas/PklProject CHANGELOG.md
git diff --staged --quiet || git commit -m "chore(release): bump version to ${GITHUB_REF#refs/tags/v}"
git push origin main
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
- name: Generate release notes
id: changelog
uses: orhun/git-cliff-action@v4
with:
config: cliff.toml
args: --latest --strip header
env:
GITHUB_REPO: ${{ github.repository }}
- name: Install Pkl CLI
run: |
curl -sL https://github.com/apple/pkl/releases/download/0.30.2/pkl-linux-amd64 -o /usr/local/bin/pkl
chmod +x /usr/local/bin/pkl
- name: Update PklProject version
run: |
VERSION="${GITHUB_REF#refs/tags/v}"
sed -i "s/version = \".*\"/version = \"$VERSION\"/" Sources/ExFigCLI/Resources/Schemas/PklProject
- name: Package PKL schemas
run: |
pkl project package \
--output-path ".pkl-out/%{name}@%{version}/" \
Sources/ExFigCLI/Resources/Schemas
- name: Generate shell completions
run: |
set -euo pipefail
USAGE_VERSION="3.0.0"
curl --fail -sL "https://github.com/jdx/usage/releases/download/v${USAGE_VERSION}/usage-x86_64-unknown-linux-gnu.tar.gz" -o usage.tar.gz
tar xzf usage.tar.gz
chmod +x usage
mkdir -p completions
./usage generate completion bash exfig -f exfig.usage.kdl > completions/exfig.bash
./usage generate completion zsh exfig -f exfig.usage.kdl > completions/_exfig
./usage generate completion fish exfig -f exfig.usage.kdl > completions/exfig.fish
for f in completions/exfig.bash completions/_exfig completions/exfig.fish; do
if [[ ! -s "$f" ]]; then
echo "::error::Generated completion file is empty: $f"
exit 1
fi
done
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
body: ${{ steps.changelog.outputs.content }}
prerelease: ${{ contains(github.ref, '-') }}
files: |
artifacts/exfig-macos/exfig-macos.zip
artifacts/exfig-linux-x64/exfig-linux-x64.tar.gz
artifacts/exfig-windows-x64/exfig-windows-x64.zip
.pkl-out/exfig@*/*
completions/exfig.bash
completions/_exfig
completions/exfig.fish
update-homebrew:
name: Update Homebrew Tap
needs: release
if: ${{ !contains(github.ref, '-') }}
runs-on: ubuntu-latest
steps:
- name: Get version from tag
id: version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
- name: Download release assets and calculate SHA256
id: sha
run: |
VERSION="${{ steps.version.outputs.version }}"
curl -sL "https://github.com/DesignPipe/exfig/releases/download/v${VERSION}/exfig-macos.zip" -o exfig-macos.zip
MACOS_SHA=$(sha256sum exfig-macos.zip | cut -d' ' -f1)
echo "macos=${MACOS_SHA}" >> "$GITHUB_OUTPUT"
curl -sL "https://github.com/DesignPipe/exfig/releases/download/v${VERSION}/exfig-linux-x64.tar.gz" -o exfig-linux.tar.gz
LINUX_SHA=$(sha256sum exfig-linux.tar.gz | cut -d' ' -f1)
echo "linux=${LINUX_SHA}" >> "$GITHUB_OUTPUT"
- name: Checkout Homebrew tap
uses: actions/checkout@v6
with:
repository: DesignPipe/homebrew-tap
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
path: homebrew-tap
- name: Update formula
run: |
VERSION="${{ steps.version.outputs.version }}"
MACOS_SHA="${{ steps.sha.outputs.macos }}"
LINUX_SHA="${{ steps.sha.outputs.linux }}"
FORMULA="homebrew-tap/Formula/exfig.rb"
sed -i "s/version \".*\"/version \"${VERSION}\"/" "$FORMULA"
sed -i "0,/sha256 \"[a-f0-9]*\"/s//sha256 \"${MACOS_SHA}\"/" "$FORMULA"
sed -i "0,/sha256 \"${MACOS_SHA}\"/! {0,/sha256 \"[a-f0-9]*\"/s//sha256 \"${LINUX_SHA}\"/}" "$FORMULA"
cat "$FORMULA"
- name: Commit and push
working-directory: homebrew-tap
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/exfig.rb
git diff --staged --quiet || git commit -m "chore: bump to v${{ steps.version.outputs.version }}"
git push