Skip to content

fix ci for macos

fix ci for macos #348

Workflow file for this run

name: Build products and release
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
# Add permissions needed for creating releases
permissions:
contents: write
jobs:
determine-version:
name: Determine Version
runs-on: ubuntu-22.04-arm
outputs:
version: ${{ steps.set-version.outputs.version }}
steps:
- name: Set version
id: set-version
run: |
TIMESTAMP=$(date +'%Y.%m.%d-%H%M%S')
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
VERSION="${TIMESTAMP}"
else
VERSION="${TIMESTAMP}-dev"
fi
echo "Setting version to $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
build:
needs: determine-version
strategy:
matrix:
include:
- artifact-name: edge-agent-linux-static-musl-aarch64
os: ubuntu-22.04-arm
container: swift:6.2.0
swift-sdk: aarch64-swift-linux-musl
swift-sdk-url: https://download.swift.org/swift-6.2-release/static-sdk/swift-6.2-RELEASE/swift-6.2-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz
swift-sdk-checksum: d2225840e592389ca517bbf71652f7003dbf45ac35d1e57d98b9250368769378
product: edge-agent
- artifact-name: edge-agent-linux-static-musl-x86_64
os: ubuntu-22.04-arm
container: swift:6.2.0
swift-sdk: x86_64-swift-linux-musl
swift-sdk-url: https://download.swift.org/swift-6.2-release/static-sdk/swift-6.2-RELEASE/swift-6.2-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz
swift-sdk-checksum: d2225840e592389ca517bbf71652f7003dbf45ac35d1e57d98b9250368769378
product: edge-agent
- artifact-name: edge-cli-linux-static-musl-aarch64
os: ubuntu-22.04-arm
container: swift:6.2.0
swift-sdk: aarch64-swift-linux-musl
swift-sdk-url: https://download.swift.org/swift-6.2-release/static-sdk/swift-6.2-RELEASE/swift-6.2-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz
swift-sdk-checksum: d2225840e592389ca517bbf71652f7003dbf45ac35d1e57d98b9250368769378
product: edge
- artifact-name: edge-cli-linux-static-musl-x86_64
os: ubuntu-22.04-arm
container: swift:6.2.0
swift-sdk: x86_64-swift-linux-musl
swift-sdk-url: https://download.swift.org/swift-6.2-release/static-sdk/swift-6.2-RELEASE/swift-6.2-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz
swift-sdk-checksum: d2225840e592389ca517bbf71652f7003dbf45ac35d1e57d98b9250368769378
product: edge
- artifact-name: edge-cli-macos-arm64
os: macos-15
xcode-select: /Applications/Xcode_26.app
product: edge
name: ${{ matrix.artifact-name }}
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
- uses: actions/checkout@v4
- name: Install Static Linux SDK
if: ${{ matrix.swift-sdk-url != '' }}
run: |
swift sdk install ${{ matrix.swift-sdk-url }} --checksum ${{ matrix.swift-sdk-checksum }}
- name: xcode-select
if: ${{ matrix.xcode-select != '' }}
run: |
sudo xcode-select --switch ${{ matrix.xcode-select }}
- name: Inject Version
run: |
# Use the version from the needs context
echo "Using version: ${{ needs.determine-version.outputs.version }}"
./Scripts/inject-version.sh "${{ needs.determine-version.outputs.version }}"
- name: Build
shell: bash
run: |
args=(
--configuration release
--product "${{ matrix.product }}"
)
if [ -n "${{ matrix.swift-sdk }}" ]; then
args+=(--swift-sdk "${{ matrix.swift-sdk }}")
fi
# Add optimization flags for edge-agent builds
if [ "${{ matrix.product }}" == "edge-agent" ]; then
args+=(-Xswiftc -whole-module-optimization)
args+=(-Xlinker --gc-sections)
args+=(-Xlinker --strip-all)
fi
swift build "${args[@]}"
# Copy built binary to the output directory
OUTPUT_DIR=${{ matrix.artifact-name }}
BIN_PATH=$(swift build --show-bin-path "${args[@]}")
mkdir $OUTPUT_DIR
cp $BIN_PATH/${{ matrix.product }} $OUTPUT_DIR/
# If a folder exists at $BIN_PATH/edge-agent_${{ matrix.product }}.bundle, copy it to output/
if [ -d "$BIN_PATH/edge-agent_${{ matrix.product }}.bundle" ]; then
cp -r $BIN_PATH/edge-agent_${{ matrix.product }}.bundle $OUTPUT_DIR/
fi
- name: Create tarball
run: |
tar -czvf ${{ matrix.artifact-name }}.tar.gz ${{ matrix.artifact-name }}/
- name: Upload binary artifact
id: upload-artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}.tar.gz
path: ${{ matrix.artifact-name }}.tar.gz
retention-days: 14
if-no-files-found: error
release:
name: Release
runs-on: ubuntu-22.04-arm
needs: [determine-version, build]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: List files
run: |
ls -la
# Create a newline-delimited list of tar.gz files
{
echo 'FILES<<EOF'
find . -name "*.tar.gz" | sort
echo 'EOF'
} >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
with:
name: ${{ needs.determine-version.outputs.version }}
tag_name: ${{ needs.determine-version.outputs.version }}
draft: false
prerelease: true
files: ${{ env.FILES }}
generate_release_notes: true
fail_on_unmatched_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# NEW: move/update a 'latest' tag to this prerelease's commit
# needed so .git exists in the workspace
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0 # grab history + tags
- name: Update 'latest' tag
run: |
set -euo pipefail
git fetch origin --tags --force
TAG='${{ needs.determine-version.outputs.version }}' # your tag, e.g. 2025.09.16-224322
TARGET_SHA="$(git rev-list -n 1 "refs/tags/$TAG" || true)"
if [ -z "$TARGET_SHA" ]; then TARGET_SHA="$GITHUB_SHA"; fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -fa latest "$TARGET_SHA" -m "Latest prerelease: $TAG"
git push -f origin refs/tags/latest