build:update release.yaml #34
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: 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: | |
fail-fast: false | |
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 cross (Linux) | |
if: runner.os == 'Linux' | |
run: cargo install cross | |
- name: Install vcpkg (Windows) | |
if: runner.os == 'Windows' | |
uses: lukka/run-vcpkg@v7 | |
with: | |
vcpkgGitCommitId: 'a42af01b72c28a8e1d7b48107b33e4f286a55ef6' | |
vcpkgTriplet: ${{ matrix.target == 'aarch64-pc-windows-msvc' && 'arm64-windows-static' || 'x64-windows-static' }} | |
vcpkgArguments: openssl | |
- name: Set OPENSSL_DIR and OPENSSL_STATIC (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
echo "OPENSSL_DIR=${{ github.workspace }}/vcpkg/installed/${{ matrix.target == 'aarch64-pc-windows-msvc' && 'arm64-windows-static' || 'x64-windows-static' }}" >> $GITHUB_ENV | |
echo "OPENSSL_STATIC=1" >> $GITHUB_ENV | |
shell: bash | |
- name: Cargo Build | |
run: | | |
if [ "${{ runner.os }}" = "Linux" ]; then | |
if [ "${{ matrix.target }}" ]; then | |
cross build --release --target ${{ matrix.target }} | |
else | |
cross build --release | |
fi | |
else | |
if [ "${{ matrix.target }}" ]; then | |
cargo build --release --target ${{ matrix.target }} | |
else | |
cargo build --release | |
fi | |
fi | |
shell: bash | |
- name: List target directory | |
run: | | |
if [ "${{ matrix.target }}" ]; then | |
ls -R target/${{ matrix.target }}/release | |
else | |
ls -R target/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 |