Skip to content

Commit

Permalink
first attempt at binary distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
tayloraswift committed Jan 30, 2025
1 parent 8ac089c commit b65fbca
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 0 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/Deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: package

on:
workflow_dispatch:
# We build semver tags, and the master branch.
push:
branches: [ master ]
tags:
- '[0-9]+.[0-9]+.[0-9]+'

jobs:
macos:
runs-on: macos-15
name: macOS
steps:
- name: Setup AWS CLI
uses: aws-actions/configure-aws-credentials@v1
with:
aws-secret-access-key: ${{ secrets.AWS_S3_ACCESS_SECRET }}
aws-access-key-id: ${{ vars.AWS_S3_ACCESS_KEY }}
aws-region: us-east-1

- name: Checkout repository
uses: actions/checkout@v3

- name: Build Archer
run: |
swift --version
swift build -c release --product archer
tar -czf archer.tar.gz -C .build/release archer
- name: Upload products
env:
ARCHER_PLATFORM: "${{ runner.os }}-${{ runner.arch }}"
ARCHER_VERSION: ${{ github.head_ref || github.ref_name }}

run: Scripts/Deploy archer.tar.gz

linux:
strategy:
matrix:
os:
- codename: jammy
version: Ubuntu-22.04
display: Ubuntu 22.04

- codename: noble
version: Ubuntu-24.04
display: Ubuntu 24.04
arch:
- id: aarch64
name: ARM64

- id: x86_64
name: X64

runs-on: ubuntu-24.04
name: "${{ matrix.os.display }} (${{ matrix.arch.id }})"
steps:
- name: Setup AWS CLI
uses: aws-actions/configure-aws-credentials@v1
with:
aws-secret-access-key: ${{ secrets.AWS_S3_ACCESS_SECRET }}
aws-access-key-id: ${{ vars.AWS_S3_ACCESS_KEY }}
aws-region: us-east-1

- name: Checkout repository
uses: actions/checkout@v3

- name: Build Archer
run: |
Scripts/BuildForBinaryDistribution ${{ matrix.arch.id }} \
--os ${{ matrix.os.codename }} \
tar -czf archer.tar.gz -C .build.${{ matrix.arch.id }} archer
- name: Upload products
env:
ARCHER_PLATFORM: "${{ matrix.os.version }}-${{ matrix.arch.name }}"
ARCHER_VERSION: ${{ github.head_ref || github.ref_name }}

run: Scripts/Deploy archer.tar.gz
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.build
/.build.*
/.vscode

/node_modules
Expand All @@ -14,4 +15,6 @@
/Packages/
/Package.resolved

/swift-cross-aarch64

/*.wasm
54 changes: 54 additions & 0 deletions Scripts/BuildForBinaryDistribution
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
set -e

SWIFT_VERSION=6.0.3

HOST_ARCH=$(uname -m)
DEST_ARCH=aarch64
DEST_OS=noble
LIBC=gnu

while [[ $# -gt 0 ]]; do
case $1 in
--os )
shift

case $1 in
jammy | noble )
DEST_OS=$1
shift
;;

* )
echo "Unsupported OS '$1'"
exit 1
;;
esac
;;

x86_64 | aarch64)
DEST_ARCH=$1
shift
;;

* )
echo "Unknown architecture '$1'"
exit 1
;;
esac
done

# We actually have to clone the repo, as it contains symlinks that GitHub won’t follow with a
# simple HTTP GET request.
git -C swift-cross-aarch64 pull || git clone https://github.com/tayloraswift/swift-cross-aarch64

docker run --rm \
-v $PWD:/package \
-w /package \
tayloraswift/swift-cross-aarch64:${SWIFT_VERSION}-${DEST_OS} \
/home/ubuntu/$HOST_ARCH/swift/usr/bin/swift build \
--configuration release \
--scratch-path .build.$DEST_ARCH \
--cache-path /swiftpm \
--destination swift-cross-aarch64/Destinations/$HOST_ARCH/$DEST_ARCH-$DEST_OS.json \
--static-swift-stdlib
20 changes: 20 additions & 0 deletions Scripts/Deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
set -e

if [ -z $ARCHER_PLATFORM ]; then
echo "ARCHER_PLATFORM environment variable not set"
exit 1
fi

if [ -z $ARCHER_VERSION ]; then
echo "ARCHER_VERSION environment variable not set"
exit 1
fi

while [[ $# -gt 0 ]]; do
aws s3 cp $1 \
s3://swiftinit/archer/$ARCHER_VERSION/$ARCHER_PLATFORM/$1 \
--content-encoding gzip \
--content-type application/gzip
shift
done

0 comments on commit b65fbca

Please sign in to comment.