mirror of
https://github.com/nicklockwood/SwiftFormat.git
synced 2026-05-17 10:30:35 +00:00
101 lines
4.4 KiB
YAML
101 lines
4.4 KiB
YAML
on:
|
|
release:
|
|
types: [published]
|
|
name: Build Release Artifacts
|
|
jobs:
|
|
macos:
|
|
name: Build macOS binary
|
|
runs-on: macos-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v5
|
|
- name: Set Version Number
|
|
run: echo "Using version number $GITHUB_REF_NAME" && sed -i '' "s/let swiftFormatVersion = \"[^\"]*\"/let swiftFormatVersion = \"$GITHUB_REF_NAME\"/" Sources/SwiftFormat.swift
|
|
- name: Build macOS binary (arm64)
|
|
run: swift build -c release --arch arm64 -Xswiftc -Osize
|
|
- name: Build macOS binary (x86_64)
|
|
run: swift build -c release --arch x86_64 -Xswiftc -Osize
|
|
- name: Create universal binary
|
|
run: |
|
|
mkdir -p .build/apple/Products/Release
|
|
lipo -create -output .build/apple/Products/Release/swiftformat .build/arm64-apple-macosx/release/swiftformat .build/x86_64-apple-macosx/release/swiftformat
|
|
- name: Strip macOS binary
|
|
run: strip -rSTx .build/apple/Products/Release/swiftformat
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: swiftformat_macos
|
|
path: .build/apple/Products/Release/swiftformat
|
|
retention-days: 5
|
|
|
|
linux:
|
|
name: Build SwiftFormat for Linux
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v5
|
|
- name: Set Version Number
|
|
run: echo "Using version number $GITHUB_REF_NAME" && sed -i "s/let swiftFormatVersion = \"[^\"]*\"/let swiftFormatVersion = \"$GITHUB_REF_NAME\"/" Sources/SwiftFormat.swift
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v4
|
|
- name: Install cross-binutils for aarch64
|
|
run: sudo apt-get update && sudo apt-get install -y binutils-aarch64-linux-gnu
|
|
- name: Build and export binaries
|
|
uses: docker/build-push-action@v7
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64,linux/arm64
|
|
target: builder
|
|
outputs: type=local,dest=artifacts
|
|
- name: Strip and Move binaries
|
|
run: |
|
|
strip artifacts/linux_amd64/workspace/swiftformat
|
|
mv artifacts/linux_amd64/workspace/swiftformat "${HOME}/swiftformat_linux"
|
|
aarch64-linux-gnu-strip artifacts/linux_arm64/workspace/swiftformat
|
|
mv artifacts/linux_arm64/workspace/swiftformat "${HOME}/swiftformat_linux_aarch64"
|
|
- name: Upload AMD64 Artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: swiftformat_linux
|
|
path: ~/swiftformat_linux
|
|
retention-days: 5
|
|
- name: Upload ARM64 Artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: swiftformat_linux_aarch64
|
|
path: ~/swiftformat_linux_aarch64
|
|
retention-days: 5
|
|
|
|
upload:
|
|
name: Upload release artifacts
|
|
runs-on: ubuntu-latest
|
|
needs: [macos, linux]
|
|
steps:
|
|
- name: Checkout the repository
|
|
uses: actions/checkout@v5
|
|
- uses: actions/download-artifact@v5
|
|
with:
|
|
path: downloaded_artifacts
|
|
pattern: swiftformat_*
|
|
- name: Display structure of downloaded files
|
|
run: ls -R downloaded_artifacts
|
|
- name: Build artifact bundle
|
|
run: ./Scripts/spm-artifact-bundle.sh ${{ github.event.release.name }} downloaded_artifacts/swiftformat_macos/swiftformat downloaded_artifacts/swiftformat_linux/swiftformat_linux downloaded_artifacts/swiftformat_linux_aarch64/swiftformat_linux_aarch64
|
|
- name: Prepare files for upload
|
|
run: |
|
|
# Ensure binaries are executable
|
|
chmod +x downloaded_artifacts/swiftformat_macos/swiftformat
|
|
chmod +x downloaded_artifacts/swiftformat_linux/swiftformat_linux
|
|
chmod +x downloaded_artifacts/swiftformat_linux_aarch64/swiftformat_linux_aarch64
|
|
|
|
# Create individual zip files for each binary directly
|
|
zip -j swiftformat.zip downloaded_artifacts/swiftformat_macos/swiftformat
|
|
zip -j swiftformat_linux.zip downloaded_artifacts/swiftformat_linux/swiftformat_linux
|
|
zip -j swiftformat_linux_aarch64.zip downloaded_artifacts/swiftformat_linux_aarch64/swiftformat_linux_aarch64
|
|
- name: Upload release assets
|
|
uses: skx/github-action-publish-binaries@master
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
args: 'swiftformat.artifactbundle.zip swiftformat.zip swiftformat_linux.zip swiftformat_linux_aarch64.zip'
|