Update tagging of images #20
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Cross-Platform and Cross-Architecture Release Build | |
on: | |
push: | |
tags: | |
- 'v*' | |
permissions: | |
contents: write | |
packages: write | |
jobs: | |
build-and-release: | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- {os: ubuntu-latest, arch: x64} | |
- {os: ubuntu-latest, arch: arm64} | |
# - {os: windows-latest, arch: x64} | |
# - {os: windows-latest, arch: arm64} | |
- {os: macos-latest, arch: x64} | |
- {os: macos-latest, arch: arm64} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies (Ubuntu) | |
if: startsWith(matrix.config.os, 'ubuntu') | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libboost-all-dev | |
- name: Install dependencies (macOS) | |
if: startsWith(matrix.config.os, 'macos') | |
run: | | |
brew install boost | |
- name: Install dependencies (Windows) | |
if: startsWith(matrix.config.os, 'windows') | |
run: | | |
choco install boost-msvc-14.2 | |
- name: Set up CMake (All platforms) | |
uses: lukka/get-cmake@latest | |
- name: Configure and Build | |
run: | | |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_ARCHITECTURE_ID=${{ matrix.config.arch }} | |
cmake --build build --config Release | |
- name: Rename binaries | |
run: | | |
mv build/serial_client build/serial-client-${{ matrix.config.os }}-${{ matrix.config.arch }} | |
mv build/serial_server build/serial-server-${{ matrix.config.os }}-${{ matrix.config.arch }} | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: artifacts-${{ matrix.config.os }}-${{ matrix.config.arch }} | |
path: | | |
build/serial-client-${{ matrix.config.os }}-${{ matrix.config.arch }} | |
build/serial-server-${{ matrix.config.os }}-${{ matrix.config.arch }} | |
create-and-upload-release: | |
needs: build-and-release | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download all artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: artifacts | |
- name: List all files in artifacts directory | |
run: ls -R artifacts | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref_name }} | |
draft: false | |
prerelease: false | |
- name: Upload Release Assets | |
run: | | |
for file in artifacts/*; do | |
echo "Uploading $file" | |
curl -X POST \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Content-Type: application/octet-stream" \ | |
-T "${file}" \ | |
"${{ steps.create_release.outputs.upload_url }}?name=$(basename $file)&label=$(basename $file)" | |
done | |
container-image: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
component: [server, client] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Extract version from tag | |
run: echo "COMMIT_HASH=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV | |
env: | |
GITHUB_REF: ${{ github.ref }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build container image | |
run: make build-${{ matrix.component }}-image | |
env: | |
COMMIT_HASH: ${{ env.COMMIT_HASH }} | |
- name: Tag container image | |
run: make tag-${{ matrix.component }}-image | |
env: | |
COMMIT_HASH: ${{ env.COMMIT_HASH }} | |
- name: Push container images | |
run: make push-${{ matrix.component }}-images | |
env: | |
COMMIT_HASH: ${{ env.COMMIT_HASH }} |