Skip to content

Release

Release #18

Workflow file for this run

name: Release
on:
push:
tags:
- '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
arch: "arm64 --arch x86_64"
build-path: apple/Products/Release
archive-name: exfig-macos
- os: ubuntu-latest
platform: linux-x64
arch: x86_64
build-path: x86_64-unknown-linux-gnu/release
archive-name: exfig-linux-x64
container: swift:6.0
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
- uses: actions/checkout@v5
- name: Select Xcode 16.3 (macOS)
if: matrix.platform == 'macos'
run: sudo xcode-select -s /Applications/Xcode_16.3.app/Contents/Developer
- name: Set version from tag
run: |
VERSION="${GITHUB_REF#refs/tags/v}"
FILE="Sources/ExFig/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: Build release binary
run: swift build -c release --arch ${{ matrix.arch }}
- 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 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 LICENSE dist/
tar -czf ${{ matrix.archive-name }}.tar.gz -C dist .
- name: Upload artifact
uses: actions/upload-artifact@v4
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
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
ref: main
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update version in main branch
run: |
VERSION="${GITHUB_REF#refs/tags/v}"
FILE="Sources/ExFig/ExFigCommand.swift"
sed -i "s/static let version = \".*\"/static let version = \"$VERSION\"/" "$FILE"
- 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/ExFig/ExFigCommand.swift 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, update-version]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
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: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
body: ${{ steps.changelog.outputs.content }}
files: |
artifacts/exfig-macos/exfig-macos.zip
artifacts/exfig-linux-x64/exfig-linux-x64.tar.gz