2021-03-09 05:54:56 +00:00
|
|
|
name: CI
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
push:
|
|
|
|
branches: [main, master]
|
|
|
|
|
|
|
|
env:
|
|
|
|
RUSTFLAGS: "-C debuginfo=0 -D warnings"
|
|
|
|
CARGO_TERM_COLOR: always
|
|
|
|
CARGO_INCREMENTAL: 0
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
tests:
|
|
|
|
name: Tests
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
continue-on-error: ${{ matrix.toolchain == 'nightly' }}
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
|
|
toolchain: [stable, beta, nightly]
|
|
|
|
include:
|
|
|
|
- os: macos-latest
|
|
|
|
MACOS: true
|
|
|
|
- os: windows-latest
|
|
|
|
- os: ubuntu-latest
|
|
|
|
steps:
|
2024-04-16 18:06:13 +00:00
|
|
|
- uses: actions/checkout@v4
|
2021-03-09 05:54:56 +00:00
|
|
|
|
|
|
|
- name: install linux deps
|
|
|
|
run: |
|
|
|
|
sudo apt update
|
2021-06-29 07:12:28 +00:00
|
|
|
sudo apt install -y --no-install-recommends libasound2-dev pkg-config
|
2021-03-09 05:54:56 +00:00
|
|
|
if: contains(matrix.os, 'ubuntu')
|
|
|
|
|
|
|
|
- name: install ${{ matrix.toolchain }} toolchain
|
|
|
|
id: install_toolchain
|
2024-04-20 07:57:02 +00:00
|
|
|
run: rustup toolchain install ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
|
2021-03-09 05:54:56 +00:00
|
|
|
|
2024-03-27 07:27:38 +00:00
|
|
|
- run: cargo clippy -- -D warnings
|
|
|
|
if: matrix.toolchain == 'stable' && matrix.os == 'ubuntu-latest'
|
2021-03-09 05:54:56 +00:00
|
|
|
|
|
|
|
- run: |
|
|
|
|
rustup component add rustfmt
|
|
|
|
cargo fmt --all -- --check
|
|
|
|
if: matrix.toolchain == 'stable' && matrix.os == 'ubuntu-latest'
|
|
|
|
|
2021-06-29 07:12:28 +00:00
|
|
|
- run: cargo test --all-targets
|
|
|
|
- run: cargo test --features=symphonia-all --all-targets
|
2021-03-29 07:20:48 +00:00
|
|
|
cargo-publish:
|
|
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
|
|
env:
|
|
|
|
CRATESIO_TOKEN: ${{ secrets.CRATESIO_TOKEN }}
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2024-04-16 18:06:13 +00:00
|
|
|
- uses: actions/checkout@v4
|
2021-03-29 07:20:48 +00:00
|
|
|
- name: Update apt
|
|
|
|
run: sudo apt update
|
|
|
|
- name: Install alsa
|
2021-06-29 07:12:28 +00:00
|
|
|
run: sudo apt install -y --no-install-recommends libasound2-dev pkg-config
|
2021-03-29 07:20:48 +00:00
|
|
|
- name: Run cargo publish for rodio
|
|
|
|
continue-on-error: true
|
|
|
|
run: |
|
|
|
|
RODIO_TMP=$(mktemp /tmp/rodioXXX.txt) || echo "::error::mktemp error"
|
2021-03-29 07:26:54 +00:00
|
|
|
echo "RODIO_TMP=$RODIO_TMP" >> $GITHUB_ENV
|
2021-03-29 07:20:48 +00:00
|
|
|
cargo publish --token $CRATESIO_TOKEN 2> $RODIO_TMP
|
|
|
|
- name: Check if rodio is already published
|
|
|
|
run: |
|
|
|
|
empty=0
|
2021-03-29 07:26:54 +00:00
|
|
|
RODIO_TMP="${{ env.RODIO_TMP }}"
|
2021-03-29 07:20:48 +00:00
|
|
|
grep -q '[^[:space:]]' < $RODIO_TMP || empty=1
|
|
|
|
[ $empty -eq 0 ] && cat $RODIO_TMP
|
|
|
|
[ $empty -eq 1 ] || grep -q "is already uploaded" < $RODIO_TMP
|
2024-07-04 10:49:04 +00:00
|
|
|
|
|
|
|
create-git-tag:
|
|
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Check if WORKFLOW_TOKEN is set
|
|
|
|
run: |
|
|
|
|
if [ -z "${{ secrets.WORKFLOW_TOKEN }}" ]; then
|
|
|
|
echo "Personal access token WORKFLOW_TOKEN is not set"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Checked `WORKFLOW_TOKEN` is set"
|
|
|
|
fi
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
with:
|
2024-07-09 10:30:46 +00:00
|
|
|
fetch-depth: 0 # Fetch all history to list all existing tags
|
2024-07-04 10:49:04 +00:00
|
|
|
token: ${{ secrets.WORKFLOW_TOKEN }}
|
|
|
|
- name: Extract version from Cargo.toml
|
|
|
|
id: extract_version
|
|
|
|
run: |
|
|
|
|
version=$(awk '/\[package\]/,/^version/ { if ($1 == "version") { gsub(/"/, "", $3); print $3 } }' Cargo.toml)
|
|
|
|
echo "Version value found: $version"
|
|
|
|
echo "version=$version" >> $GITHUB_OUTPUT
|
|
|
|
- name: Check if tag exists
|
|
|
|
id: check_tag
|
|
|
|
run: |
|
|
|
|
version=${{ steps.extract_version.outputs.version }}
|
|
|
|
version_name="v$version"
|
|
|
|
if git rev-parse "refs/tags/$version_name" >/dev/null 2>&1; then
|
|
|
|
echo "Tag $version_name already exists"
|
|
|
|
echo "tag_exists=true" >> $GITHUB_OUTPUT
|
|
|
|
else
|
|
|
|
echo "Tag $version_name does not exist"
|
|
|
|
echo "tag_exists=false" >> $GITHUB_OUTPUT
|
|
|
|
fi
|
|
|
|
- name: Create and push tag
|
|
|
|
if: steps.check_tag.outputs.tag_exists == 'false'
|
|
|
|
run: |
|
|
|
|
version=${{ steps.extract_version.outputs.version }}
|
|
|
|
git config --global user.name 'github-actions'
|
|
|
|
git config --global user.email 'github-actions@github.com'
|
|
|
|
version_name="v$version"
|
|
|
|
git tag -a "$version_name" -m "Release for $version_name"
|
2024-11-08 00:58:21 +00:00
|
|
|
git push origin $version_name
|