Skip to content

add release workflow #5

add release workflow

add release workflow #5

Workflow file for this run

name: Release
on:
release:
types: [published]
push:
branches: [workflow-release-test]
env:
CARGO_TERM_COLOR: always
RUST_MIN_STACK: 16777212
permissions:
contents: write
jobs:
build:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
include:
- platform: ubuntu-latest
artifact-path: target/release/sdl
artifact-platform-name: linux-x64
env-command: ">> $GITHUB_ENV"
- platform: macos-latest
artifact-path: target/release/sdl
artifact-platform-name: macos-x64
env-command: ">> $GITHUB_ENV"
- platform: windows-latest
artifact-path: target/release/sdl.exe
artifact-platform-name: windows-x64
env-command: "| Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append"
runs-on: ${{ matrix.platform }}
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- name: Update Rust
run: rustup update
- uses: swatinem/rust-cache@v2
- name: Install multiarch dependencies (linux-armhf and linux-arm64)
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: |
sudo dpkg --add-architecture armhf
sudo dpkg --add-architecture arm64
sudo sed -i'' -E 's/^(deb|deb-src) /\1 [arch=amd64,i386] /' /etc/apt/sources.list
echo "deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs) main restricted universe" | sudo tee /etc/apt/sources.list.d/armhf.list
echo "deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs)-security main restricted universe" | sudo tee -a /etc/apt/sources.list.d/armhf.list
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs) main restricted universe" | sudo tee /etc/apt/sources.list.d/arm64.list
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs)-security main restricted universe" | sudo tee -a /etc/apt/sources.list.d/arm64.list
sudo apt-get update -y
sudo apt-get install -yq libssl-dev:armhf libssl-dev:armhf libssl-dev:arm64
- name: Build, get version
run: |
cargo run --release --bin sdl -- --help
echo "SDL_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages | .[0].version')" ${{ matrix.env-command }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: sdl-${{ env.SDL_VERSION }}-${{ matrix.artifact-platform-name }}
path: ${{ matrix.artifact-path }}
if-no-files-found: error
- name: Build (macos-aarch64)
if: ${{ matrix.platform == 'macos-latest' }}
run: |
rustup target add aarch64-apple-darwin
cargo build --release --bin sdl --target aarch64-apple-darwin
- name: Upload artifacts (macos-aarch64)
uses: actions/upload-artifact@v4
if: ${{ matrix.platform == 'macos-latest' }}
with:
name: sdl-${{ env.SDL_VERSION }}-macos-aarch64
path: target/aarch64-apple-darwin/release/sdl
if-no-files-found: error
- name: Build (linux-armv7-gnueabihf)
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: |
rustup target add armv7-unknown-linux-gnueabihf
sudo apt-get install -yq gcc-arm-linux-gnueabihf
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=/usr/bin/arm-linux-gnueabihf-gcc
cargo build --release --bin sdl --target armv7-unknown-linux-gnueabihf
- name: Upload artifacts (linux-armv7-gnueabihf)
uses: actions/upload-artifact@v4
if: ${{ matrix.platform == 'ubuntu-latest' }}
with:
name: sdl-${{ env.SDL_VERSION }}-linux-armv7-gnueabihf
path: target/armv7-unknown-linux-gnueabihf/release/sdl
if-no-files-found: error
- name: Build (linux-aarch64-gnu)
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: |
rustup target add aarch64-unknown-linux-gnu
sudo apt-get install -yq gcc-aarch64-linux-gnu
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/aarch64-linux-gnu-gcc
cargo build --release --bin sdl --target aarch64-unknown-linux-gnu
- name: Upload artifacts (linux-aarch64-gnu)
uses: actions/upload-artifact@v4
if: ${{ matrix.platform == 'ubuntu-latest' }}
with:
name: sdl-${{ env.SDL_VERSION }}-linux-aarch64-gnu
path: target/aarch64-unknown-linux-gnu/release/sdl
if-no-files-found: error
- name: Build (linux-x86_64-musl)
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: |
rustup target add x86_64-unknown-linux-musl
sudo apt-get install -yq musl-tools
cargo build --release --bin sdl --target x86_64-unknown-linux-musl
- name: Upload artifacts (linux-x86_64-musl)
uses: actions/upload-artifact@v4
if: ${{ matrix.platform == 'ubuntu-latest' }}
with:
name: sdl-${{ env.SDL_VERSION }}-linux-x64-musl
path: target/x86_64-unknown-linux-musl/release/sdl
if-no-files-found: error