name: Robrix Release CI
on:
push:
tags:
- 'v*.*.*' - 'v*.*.*-*' workflow_dispatch:
inputs:
target_platforms:
description: 'Target platforms for the release'
required: true
type: choice
options:
- 'All' - 'linux-ubuntu-24.04' - 'linux-ubuntu-24.04-x86_64' - 'linux-ubuntu-24.04-aarch64' - 'linux-ubuntu-22.04' - 'linux-ubuntu-22.04-x86_64' - 'linux-ubuntu-22.04-aarch64' - 'macos-14-aarch64' - 'macos-15-x86_64' - 'windows-2022-x86_64' release_tag:
description: 'Release tag (required if creating release)'
required: false
type: string
default: ''
create_release:
description: 'Create a GitHub Release'
required: true
type: boolean
default: false
pre_release:
description: 'Mark as a pre-release'
required: true
type: boolean
default: false
permissions: write-all
env:
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: short
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
check_tag_version:
name: Check Release Tag and Cargo.toml Version Consistency
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- name: Check tag and Cargo.toml version
run: |
TAG_REF="${GITHUB_REF##*/}"
echo "Current tag: $TAG_REF"
CARGO_MANIFEST_VERSION=$(cargo metadata --no-deps --format-version 1 --frozen | jq -r '.packages[0].version')
echo "Cargo.toml Robrix version: $CARGO_MANIFEST_VERSION"
if [[ "$TAG_REF" != "v$CARGO_MANIFEST_VERSION" ]]; then
echo "Error: Tag '$TAG_REF' does not match Cargo.toml version '$CARGO_MANIFEST_VERSION'."
echo "Please create a tag that matches the Cargo.toml version."
exit 1
else
echo "Tag and Cargo.toml version are consistent."
fi
determine_matrix:
name: Determine Build Matrix
runs-on: ubuntu-latest
if: always() && (needs.check_tag_version.result == 'success' || github.event_name == 'workflow_dispatch')
needs: check_tag_version
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Set build matrix
id: set-matrix
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
case "${{ github.event.inputs.target_platforms }}" in
"All")
matrix='{"include":[{"os":"ubuntu-24.04","arch":"x86_64"},{"os":"ubuntu-24.04-arm","arch":"aarch64"},{"os":"ubuntu-22.04","arch":"x86_64"},{"os":"ubuntu-22.04-arm","arch":"aarch64"},{"os":"macos-14","arch":"aarch64"},{"os":"macos-15-intel","arch":"x86_64"},{"os":"windows-2022","arch":"x86_64"}]}'
;;
"linux-ubuntu-24.04")
matrix='{"include":[{"os":"ubuntu-24.04","arch":"x86_64"},{"os":"ubuntu-24.04-arm","arch":"aarch64"}]}'
;;
"linux-ubuntu-22.04")
matrix='{"include":[{"os":"ubuntu-22.04","arch":"x86_64"},{"os":"ubuntu-22.04-arm","arch":"aarch64"}]}'
;;
"linux-ubuntu-24.04")
matrix='{"include":[{"os":"ubuntu-24.04","arch":"x86_64"}]}'
;;
"linux-ubuntu-24.04-aarch64")
matrix='{"include":[{"os":"ubuntu-24.04-arm","arch":"aarch64"}]}'
;;
"linux-ubuntu-22.04")
matrix='{"include":[{"os":"ubuntu-22.04","arch":"x86_64"}]}'
;;
"linux-ubuntu-22.04-aarch64")
matrix='{"include":[{"os":"ubuntu-22.04-arm","arch":"aarch64"}]}'
;;
"macos-14-aarch64")
matrix='{"include":[{"os":"macos-14","arch":"aarch64"}]}'
;;
"macos-15-x86_64")
matrix='{"include":[{"os":"macos-15-intel","arch":"x86_64"}]}'
;;
"windows-2022-x86_64")
matrix='{"include":[{"os":"windows-2022","arch":"x86_64"}]}'
;;
esac
else
matrix='{"include":[{"os":"ubuntu-24.04","arch":"x86_64"},{"os":"ubuntu-24.04-arm","arch":"aarch64"},{"os":"ubuntu-22.04","arch":"x86_64"},{"os":"ubuntu-22.04-arm","arch":"aarch64"},{"os":"macos-14","arch":"aarch64"},{"os":"macos-15-intel","arch":"x86_64"},{"os":"windows-2022","arch":"x86_64"}]}'
fi
echo "matrix=$matrix" >> $GITHUB_OUTPUT
release_robrix_for_desktop:
name: Release Robrix for Desktop (${{ matrix.os }}, ${{ matrix.arch }})
needs: determine_matrix
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.determine_matrix.outputs.matrix) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Linux necessary dependencies
if: matrix.os == 'ubuntu-22.04' || matrix.os == 'ubuntu-22.04-arm' || matrix.os == 'ubuntu-24.04' || matrix.os == 'ubuntu-24.04-arm'
run: |
sudo apt-get update
sudo apt-get install -y \
libssl-dev \
libsqlite3-dev \
pkg-config \
llvm \
clang \
libclang-dev \
binfmt-support \
libxcursor-dev \
libx11-dev \
libasound2-dev \
libpulse-dev \
libwayland-dev libxkbcommon-dev
- name: Install Rust Stable
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-packager
run: |
cargo +stable install --force --locked cargo-packager
- name: Install robius-packaging-commands
run: |
cargo install --version 0.2.0 --locked --git https://github.com/project-robius/robius-packaging-commands.git robius-packaging-commands
- name: Build
shell: bash
run: |
cargo packager --release
ls ./dist
- name: Set Version
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ github.event.inputs.release_tag }}" ]]; then
VERSION="${{ github.event.inputs.release_tag }}"
VERSION="${VERSION#v}" # Remove 'v' prefix if present
else
VERSION=$(cargo metadata --no-deps --format-version 1 --frozen | jq -r '.packages[0].version')
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
shell: bash
- name: Set Artifact and Upload Paths
shell: bash
run: |
VERSION=${{ env.VERSION }}
OS=${{ matrix.os }}
ARCH=${{ matrix.arch }}
if [[ "$OS" == "ubuntu-22.04" || "$OS" == "ubuntu-24.04" ]]; then
{
echo "DEB=robrix_${VERSION}_amd64.deb"
echo "APPIMAGE=robrix_${VERSION}_x86_64.AppImage"
echo "TAR=robrix_${VERSION}_x86_64.tar.gz"
echo "UPLOAD_FILES<<EOF"
echo "./dist/robrix_${VERSION}_amd64.deb"
echo "./dist/robrix_${VERSION}_x86_64.AppImage"
echo "./dist/robrix_${VERSION}_x86_64.tar.gz"
echo "EOF"
} >> $GITHUB_ENV
elif [[ "$OS" == "ubuntu-22.04-arm" || "$OS" == "ubuntu-24.04-arm" ]]; then
{
echo "DEB=robrix_${VERSION}_arm64.deb"
echo "APPIMAGE=robrix_${VERSION}_aarch64.AppImage"
echo "TAR=robrix_${VERSION}_aarch64.tar.gz"
echo "UPLOAD_FILES<<EOF"
echo "./dist/robrix_${VERSION}_arm64.deb"
echo "./dist/robrix_${VERSION}_aarch64.AppImage"
echo "./dist/robrix_${VERSION}_aarch64.tar.gz"
echo "EOF"
} >> $GITHUB_ENV
elif [[ "$OS" == "macos-14" ]]; then
FILE="robrix-${VERSION}-macOS-${ARCH}.dmg"
mv ./dist/Robrix_${VERSION}_aarch64.dmg ./dist/$FILE
echo "RELEASE_FILE=$FILE" >> $GITHUB_ENV
echo "UPLOAD_FILES=./dist/$FILE" >> $GITHUB_ENV
elif [[ "$OS" == "macos-15-intel" ]]; then
FILE="robrix-${VERSION}-macOS-${ARCH}.dmg"
mv ./dist/Robrix_${VERSION}_x64.dmg ./dist/$FILE
echo "RELEASE_FILE=$FILE" >> $GITHUB_ENV
echo "UPLOAD_FILES=./dist/$FILE" >> $GITHUB_ENV
elif [[ "$OS" == "windows-2022" ]]; then
FILE="robrix-${VERSION}-windows-${ARCH}-setup.exe"
mv ./dist/robrix_${VERSION}_x64-setup.exe ./dist/$FILE
echo "RELEASE_FILE=$FILE" >> $GITHUB_ENV
echo "UPLOAD_FILES=./dist/$FILE" >> $GITHUB_ENV
fi
- name: Upload Release Artifacts
if: |
(github.event_name == 'push') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.create_release == 'true')
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.release_tag || format('v{0}', env.VERSION) }}
name: ${{ github.event_name == 'workflow_dispatch' && format('Robrix {0}', github.event.inputs.release_tag) || format('Robrix v{0}', env.VERSION) }}
token: ${{ secrets.ROBRIX_RELEASE }}
files: ${{ env.UPLOAD_FILES }}
prerelease: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.pre_release == 'true' || contains(github.ref, '-') }}
draft: ${{ github.event_name == 'workflow_dispatch' }}
- name: Upload Artifacts (No Release)
if: |
github.event_name == 'workflow_dispatch' && github.event.inputs.create_release != 'true'
uses: actions/upload-artifact@v4
with:
name: robrix-${{ env.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}
path: ${{ env.UPLOAD_FILES }}
retention-days: 30