Skip to content

Added CD GHA

Added CD GHA #22

Workflow file for this run

# This workflow automatically releases binaries upon tagging.
name: spot-cpp-sdk CD
on:
push:
tags:
- '*'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: bdaiinstitute/spot_cpp_sdk_builder
jobs:
build-docker-image:
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
strategy:
matrix:
config:
- { arch: "amd64" }
- { arch: "arm64" }
name: Build docker image for ${{ matrix.config.arch }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU # as virtualization is necessary to build container images
uses: docker/setup-qemu-action@v3
- name: Setup Docker buildx # to workaround: https://github.com/docker/build-push-action/issues/461
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c # https://github.com/docker/login-action
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}_${{ matrix.config.arch }}
- name: Build and push
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a # https://github.com/docker/build-push-action
id: build
with:
context: .
file: .devcontainer/Dockerfile.${{ matrix.config.arch }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
build-artifacts:
strategy:
matrix:
config:
- { arch: "amd64" }
- { arch: "arm64" }
name: Build spot-cpp-sdk for ${{ matrix.config.arch }}
needs: build-docker-image
runs-on: ubuntu-latest
container:
# env cannot be used here...
image: ghcr.io/bdaiinstitute/spot_cpp_sdk_builder_${{ matrix.config.arch }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Build spot-sdk-cpp
run: |
cd spot-sdk-cpp/cpp
mkdir build
cd build
cmake ../ -DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_FIND_PACKAGE_PREFER_CONFIG=TRUE -DBUILD_CHOREOGRAPHY_LIBS=ON
make -j2 install package
- name: Upload ${{ matrix.config.arch }} artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.config.arch }}-artifact
path: '*.deb'
retention-days: 1
bundle-debians:
name: Release artifacts
runs-on: ubuntu-latest
needs: build-artifacts
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: '*-artifact'
merge-multiple: true
- name: Release to GitHub
uses: softprops/action-gh-release@v1
with:
name: Release ${{ github.ref_name }}
files: '*.deb'