Skip to content

build:update release.yaml #29

build:update release.yaml

build:update release.yaml #29

Workflow file for this run

name: Release
on:
push:
branches: [ main ]
tags:
- 'v*'
pull_request:
branches: [ main ]
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
version: ${{ steps.get_version.outputs.VERSION }}
steps:
- name: Get version
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- 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 }}
draft: false
prerelease: false
build-and-release:
name: Build and Release
needs: create-release
runs-on: ${{ matrix.os }}
if: startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
include:
- os: ubuntu-latest
artifact_name: bilistream
asset_name: linux-x86_64
- os: ubuntu-latest
artifact_name: bilistream
asset_name: linux-aarch64
target: aarch64-unknown-linux-gnu
- os: windows-latest
artifact_name: bilistream.exe
asset_name: windows-x86_64
- os: windows-latest
artifact_name: bilistream.exe
asset_name: windows-aarch64
target: aarch64-pc-windows-msvc
- os: macOS-latest
artifact_name: bilistream
asset_name: macos-x86_64
- os: macOS-latest
artifact_name: bilistream
asset_name: macos-aarch64
target: aarch64-apple-darwin
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install dependencies (Ubuntu)
if: runner.os == 'Linux' && matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Install vcpkg
uses: lukka/run-vcpkg@v7
with:
vcpkgGitCommitId: 'a42af01b72c28a8e1d7b48107b33e4f286a55ef6'
- name: Build
uses: lukka/run-cmake@v3
with:
useVcpkgToolchainFile: true
buildDirectory: ${{ runner.workspace }}/build
cmakeListsOrSettingsJson: CMakeListsTxtBasic
cmakeAppendedArgs: '-DCMAKE_BUILD_TYPE=Release'
env:
VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }}
- name: Cargo Build
run: |
if [ "${{ matrix.target }}" ]; then
cargo build --release --target ${{ matrix.target }}
else
cargo build --release
fi
shell: bash
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ${{ matrix.target && format('target/{0}/release/{1}', matrix.target, matrix.artifact_name) || format('target/release/{0}', matrix.artifact_name) }}
asset_name: bilistream-${{ needs.create-release.outputs.version }}-${{ matrix.asset_name }}
asset_content_type: application/octet-stream