Skip to content

Release

Release #47

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:
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 aarch64)
if: runner.os == 'Linux' && matrix.target == 'aarch64-unknown-linux-gnu'
run: cargo install cross
- name: Install OpenSSL and Perl modules (Windows)
if: runner.os == 'Windows'
run: |
choco install openssl.light -y
choco install strawberryperl -y
refreshenv
$env:PATH = "C:\Strawberry\perl\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\c\bin;$env:PATH"
$env:OPENSSL_DIR = "C:\Program Files\OpenSSL-Win64"
$env:OPENSSL_LIB_DIR = "C:\Program Files\OpenSSL-Win64\lib"
$env:OPENSSL_INCLUDE_DIR = "C:\Program Files\OpenSSL-Win64\include"
$env:PERL5LIB = "C:\Strawberry\perl\lib;C:\Strawberry\perl\site\lib"
$env:OPENSSL_NO_VENDOR = "1"
$env:X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR = "1"
$env:OPENSSL_CONFIG_DIR = "C:\Program Files\OpenSSL-Win64\ssl"
[Environment]::SetEnvironmentVariable("PATH", $env:PATH, "Machine")
[Environment]::SetEnvironmentVariable("OPENSSL_DIR", $env:OPENSSL_DIR, "Machine")
[Environment]::SetEnvironmentVariable("OPENSSL_LIB_DIR", $env:OPENSSL_LIB_DIR, "Machine")
[Environment]::SetEnvironmentVariable("OPENSSL_INCLUDE_DIR", $env:OPENSSL_INCLUDE_DIR, "Machine")
[Environment]::SetEnvironmentVariable("PERL5LIB", $env:PERL5LIB, "Machine")
[Environment]::SetEnvironmentVariable("OPENSSL_NO_VENDOR", $env:OPENSSL_NO_VENDOR, "Machine")
[Environment]::SetEnvironmentVariable("X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR", $env:X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR, "Machine")
[Environment]::SetEnvironmentVariable("OPENSSL_CONFIG_DIR", $env:OPENSSL_CONFIG_DIR, "Machine")
cpan App::cpanminus
cpanm Locale::Maketext::Simple
cpanm Params::Check
cpanm IPC::Cmd
shell: pwsh
- name: Set OpenSSL and Perl environment variables (Windows)
if: runner.os == 'Windows'
run: |
echo "OPENSSL_DIR=C:\Program Files\OpenSSL-Win64" >> $GITHUB_ENV
echo "OPENSSL_LIB_DIR=C:\Program Files\OpenSSL-Win64\lib" >> $GITHUB_ENV
echo "OPENSSL_INCLUDE_DIR=C:\Program Files\OpenSSL-Win64\include" >> $GITHUB_ENV
echo "PERL5LIB=C:\Strawberry\perl\lib;C:\Strawberry\perl\site\lib" >> $GITHUB_ENV
echo "OPENSSL_NO_VENDOR=1" >> $GITHUB_ENV
echo "X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR=1" >> $GITHUB_ENV
echo "OPENSSL_CONFIG_DIR=C:\Program Files\OpenSSL-Win64\ssl" >> $GITHUB_ENV
echo "C:\Strawberry\perl\bin" >> $GITHUB_PATH
shell: bash
- name: Cargo Build
run: |
if [ "${{ runner.os }}" = "Linux" ]; then
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
cross build --release --target ${{ matrix.target }}
else
cargo 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: Prepare asset
run: |
if [ "${{ matrix.target }}" ]; then
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} ${{ matrix.artifact_name }}
else
cp target/release/${{ matrix.artifact_name }} ${{ matrix.artifact_name }}
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.artifact_name }}
asset_name: bilistream-${{ needs.create-release.outputs.version }}-${{ matrix.asset_name }}
asset_content_type: application/octet-stream