Skip to content

Create artifacts

Create artifacts #18

# yaml-language-server: $schema=https://json.schemastore.org/github-workflow
name: Create artifacts
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
permissions:
contents: read
jobs:
create-linux-artifacts:
name: Create Linux artifacts
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-24.04]
target: [x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu]
arch: [x64, arm64]
exclude:
- os: ubuntu-24.04
target: x86_64-unknown-linux-gnu
arch: arm64
- os: ubuntu-24.04
target: aarch64-unknown-linux-gnu
arch: x64
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
- name: Install targets
shell: bash
run: |
rustup target add "${{ matrix.target }}";
- name: Install dependencies
shell: bash
run: |
sudo dpkg --add-architecture ${{ matrix.arch }};
sudo apt-get update;
sudo apt-get install -y \
apt-get install -y \
g++-x86-64-linux-gnu \
libc6-dev-amd64-cross \
g++-aarch64-linux-gnu \
libc6-dev-arm64-cross \
build-essential \
crossbuild-essential-arm64 \
crossbuild-essential-amd64 \
git \
pkg-config \
libpq-dev:${{ matrix.arch }} \
libpq5:${{ matrix.arch }} \
libsqlite3-dev:${{ matrix.arch }} \
libsqlite3-0:${{ matrix.arch }} \
libssl-dev:${{ matrix.arch }};
- name: Set compile variables
shell: pwsh
run: |
$sb = [System.Text.StringBuilder]::new()
switch ("${{ matrix.target }}") {
"x86_64-unknown-linux-gnu" {
$null = $sb.AppendLine("CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-linux-gnu-gcc")
$null = $sb.AppendLine("CC_x86_64_unknown_linux_gnu=x86_64-linux-gnu-gcc")
$null = $sb.AppendLine("CXX_x86_64_unknown_linux_gnu=x86_64-linux-gnu-g++")
break
}
"aarch64-unknown-linux-gnu" {
$null = $sb.AppendLine("CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc")
$null = $sb.AppendLine("CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc")
$null = $sb.AppendLine("CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++")
break
}
default {
throw "Unknown target: ${{ matrix.target }}"
}
}
$sb.ToString() >> $env:GITHUB_ENV
- name: Build
shell: bash
env:
FEDIPROTOSYNC_INCLUDE_COMMIT_HASH: "${{ github.event_name == 'workflow_dispatch' || 'false' }}"
FEDIPROTOSYNC_UPDATE_MANIFEST_VERSION: "true"
run: |
cargo build --target "${{ matrix.target }}" --release;
mkdir -p "${{ github.workspace }}/artifacts/linux-${{ matrix.arch }}";
cp "${{ github.workspace }}/target/${{ matrix.target }}/release/fediproto-sync" "${{ github.workspace }}/artifacts/linux-${{ matrix.arch }}/fediproto-sync";
- name: Create artifact (Linux - x64)
uses: actions/upload-artifact@v4
with:
name: "fediproto-sync_linux-${{ matrix.arch }}_${{ github.ref_type == 'tag' && github.ref_name || github.sha }}"
path: ${{ github.workspace }}/artifacts/linux-${{ matrix.arch }}/**/*
if-no-files-found: error