Skip to content

Publish Docker image #44

Publish Docker image

Publish Docker image #44

Workflow file for this run

name: Publish Docker image
on: [workflow_dispatch]
jobs:
push_to_registry:
name: Push base Docker image
runs-on: ubuntu-latest
steps:
- name: Check out GitHub repo
uses: actions/checkout@v2
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build image and push to Docker Hub
uses: docker/build-push-action@v2
with:
context: .devcontainer
push: true
tags: colemancda/swift-armv7:latest
push_prebuilt:
name: Push prebuilt Docker image
runs-on: ubuntu-latest
needs: push_to_registry
steps:
- name: Check out GitHub repo
uses: actions/checkout@v2
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build image and push to Docker Hub
uses: docker/build-push-action@v2
with:
push: true
tags: colemancda/swift-armv7:latest-prebuilt
push_runtime:
name: Push runtime Docker image
runs-on: [self-hosted, Linux, ARM]
steps:
- name: Check out GitHub repo
uses: actions/checkout@v2
- name: Download Swift runtime
run: |
export SRC_ROOT=$GITHUB_WORKSPACE
export DOWNLOAD_FILE=$SRC_ROOT/build/swift-armv7.tar.gz
export TAR_URL=https://github.com/colemancda/swift-armv7/releases/download/0.6.0/swift-armv7.tar.gz
mkdir -p $SRC_ROOT/build
wget -q $TAR_URL -O $DOWNLOAD_FILE
- name: Build Docker image
run: ./build-runtime.sh
- name: Push to Docker Hub
run: docker push colemancda/swift-armv7:latest-runtime
crosscompile-macos:
name: Build Xcode toolchain
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Swift Version
run: swift --version
- name: Generate Xcode toolchain
run: |
export SRC_ROOT=$GITHUB_WORKSPACE
./generate-xcode-toolchain.sh
- name: Cross compile Swift package
run: |
export SRC_ROOT=$GITHUB_WORKSPACE
./build-swift-hello.sh
- name: Archive swift-hello
uses: actions/upload-artifact@v3
with:
name: swift-hello-crosscompile-macos
path: ./build/swift-hello/armv7-unknown-linux-gnueabihf/release/swift-hello
crosscompile-linux:
name: Crosscompile from Linux
runs-on: ubuntu-latest
container: colemancda/swift-armv7:latest-prebuilt
needs: push_prebuilt
steps:
- name: Swift Version
run: swift --version
- name: Cross compile Swift package
run: |
cd $SRC_ROOT
./generate-swiftpm-toolchain.sh
./build-swift-hello.sh
- name: Archive swift-hello
uses: actions/upload-artifact@v3
with:
name: swift-hello-crosscompile-linux
path: ./build/swift-hello/armv7-unknown-linux-gnueabihf/release/swift-hello
test-swift-hello-armv7:
name: Test Swift runtime
runs-on: [self-hosted, Linux, ARM]
strategy:
matrix:
os: [macos, linux]
container: colemancda/swift-armv7:latest-runtime
needs: [push_runtime, crosscompile-linux, crosscompile-macos]
steps:
- name: Download swift-hello
uses: actions/download-artifact@v3
with:
name: swift-hello-crosscompile-${{ matrix.os }}
path: /tmp/
- name: Test
run: |
chmod +x /tmp/swift-hello
/tmp/swift-hello