Build #595
This file contains hidden or 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: Build | |
on: | |
push: | |
branches: [ master ] | |
schedule: | |
# Every 12 hours | |
- cron: 0 */12 * * * | |
workflow_dispatch: | |
jobs: | |
build-matrix: | |
name: Generate build matrix | |
runs-on: ubuntu-latest | |
outputs: | |
skip_build: "${{ steps.generate-matrix.outputs.skip_build }}" | |
matrix: "${{ steps.generate-matrix.outputs.matrix }}" | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
lfs: true | |
- uses: actions/cache@v4 | |
id: cache-venv | |
with: | |
path: ./.venv/ | |
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements*.txt') }} | |
restore-keys: | | |
${{ runner.os }}-venv- | |
- name: Install Python dependencies | |
if: steps.cache-venv.outputs.cache-hit != 'true' | |
run: | | |
python3 -m venv .venv | |
source .venv/bin/activate | |
pip install -r requirements.txt | |
- name: Build the matrix | |
id: generate-matrix | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
source .venv/bin/activate | |
OUTPUT="$(python3 -m dfn_build.build_matrix)" | |
MATRIX=$(echo $OUTPUT | jq -c ".matrix") | |
echo "matrix=${MATRIX}" >> $GITHUB_OUTPUT | |
SKIP_BUILD=$(echo $OUTPUT | jq -r -c ".skip_build") | |
echo "skip_build=${SKIP_BUILD}" >> $GITHUB_OUTPUT | |
build-lib: | |
runs-on: ubuntu-20.04 | |
name: Build libdeepfilter | |
needs: build-matrix | |
if: needs.build-matrix.outputs.skip_build != 'true' | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJson(needs.build-matrix.outputs.matrix) }} | |
env: | |
RUST_VERSION: "1.78.0" | |
CARGO_C_VERSION: "0.10.3" | |
OUR_TAG: "${{ matrix.our_tag }}" | |
UPSTREAM_REF: "${{ matrix.ref }}" | |
UPSTREAM_SHORT_REF: "${{ matrix.short_ref }}" | |
UPSTREAM_TARBALL: "${{ matrix.tarball }}" | |
ARTIFACT_NAME: "libdeepfilter-${{ matrix.short_ref }}-${{ matrix.target }}" | |
TARBALL_SAVE_PATH: "${{ github.workspace }}/build/DeepFilterNet.tar.gz" | |
BUILD_ROOT_PATH: "${{ github.workspace }}/build/root" | |
ARTIFACT_PATH: "${{ github.workspace }}/build/libdeepfilter" | |
IS_PRERELEASE: ${{ startsWith(matrix.our_tag, 'prerelease-') }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
lfs: true | |
- name: Download upstream tarball | |
run: | | |
set -ux | |
./dfn_build/download.sh | |
- name: Install Rust toolchain | |
run: | | |
rustup toolchain install ${{ env.RUST_VERSION }} | |
rustup default ${{ env.RUST_VERSION }} | |
- uses: Swatinem/rust-cache@v2.7.3 | |
with: | |
env-vars: "CARGO CC CFLAGS CXX CMAKE RUST" | |
cache-all-crates: true | |
workspaces: | | |
${{ env.BUILD_ROOT_PATH }} -> target | |
- name: Add Rust target and install cargo-c | |
run: | | |
set -ux | |
rustup +${{ env.RUST_VERSION }} target add "${{ matrix.target }}" | |
cargo +${{ env.RUST_VERSION }} install "cargo-c@${{ env.CARGO_C_VERSION }}" | |
- name: Build upstream project | |
env: | |
TARGET: ${{ matrix.target }} | |
run: | | |
set -ux | |
./dfn_build/build.sh | |
cd "$(dirname "${ARTIFACT_PATH}")" | |
tar cvzf "${ARTIFACT_NAME}.tar.gz" "$(basename "${ARTIFACT_PATH}")" | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: "${{ env.ARTIFACT_NAME }}.tar.gz" | |
path: "build/${{ env.ARTIFACT_NAME }}.tar.gz" | |
retention-days: 30 | |
- name: Release | |
uses: ncipollo/release-action@v1.14.0 | |
with: | |
tag: "${{ env.OUR_TAG }}" | |
name: "${{ env.UPSTREAM_SHORT_REF }}" | |
draft: ${{ ! env.IS_PRERELEASE }} | |
allowUpdates: true | |
updateOnlyUnreleased: ${{ ! env.IS_PRERELEASE }} | |
artifactErrorsFailBuild: true | |
generateReleaseNotes: false | |
prerelease: ${{ env.IS_PRERELEASE }} | |
artifacts: "build/${{ env.ARTIFACT_NAME }}.tar.gz" | |
body: | | |
Build of upstream DeepFilterNet. | |
Upstream ref: `${{ env.UPSTREAM_REF }}` | |
Upstream source: ${{ env.UPSTREAM_TARBALL }} | |
Rust version: `${{ env.RUST_VERSION }}` | |
Cargo-C version: `${{ env.CARGO_C_VERSION }}` |