name: coreaudio-sys
on: [push, pull_request]
jobs:
  # Run cargo test with default, no and all features.
  # Also build the docs with all features to make sure docs.rs will work.
  macos-test:
    runs-on: macOS-latest
    steps:
    - uses: actions/checkout@v2
    - name: Install llvm and clang
      run: brew install llvm
    - name: Install stable
      uses: actions-rs/toolchain@v1
      with:
        profile: minimal
        toolchain: stable
        override: true
    - name: cargo test
      run: cargo test --verbose
    - name: cargo test - no features
      run: cargo test --no-default-features --verbose
    - name: cargo test - all features
      run: cargo test --all-features --verbose
    - name: cargo doc - all features
      run: cargo doc --all-features --verbose

  # Check that cross-compilation from linux is working.
  # TODO: This is adapted from old travis file, should probably also:
  # - Check more feature permutations.
  # - Use more recent SDK? Looks like 10.13 is used atm.
  # - Check iOS target?
  linux-cross-compile:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Install stable
      uses: actions-rs/toolchain@v1
      with:
        profile: minimal
        toolchain: stable
        override: true
    - name: Add apple target
      run: rustup target add x86_64-apple-darwin
    - name: Download SDK
      run: curl -sL https://github.com/phracker/MacOSX-SDKs/releases/download/10.13/MacOSX10.13.sdk.tar.xz | tar -Jxf -; export COREAUDIO_SDK_PATH="$PWD/MacOSX10.13.sdk"
    - name: Cargo build
      run: cargo build --verbose --target=x86_64-apple-darwin

  # Publish a new version when pushing to master.
  # Will succeed if the version has been updated, otherwise silently fails.
  cargo-publish:
    if: github.event_name == 'push' && github.ref == 'refs/heads/master'
    env:
      CRATESIO_TOKEN: ${{ secrets.CRATESIO_TOKEN }}
    runs-on: macOS-latest
    steps:
    - uses: actions/checkout@v2
    - name: Install llvm and clang
      run: brew install llvm
    - name: Install stable
      uses: actions-rs/toolchain@v1
      with:
        profile: minimal
        toolchain: stable
        override: true
    - name: cargo publish
      continue-on-error: true
      run: cargo publish --token $CRATESIO_TOKEN

Add github CI and auto-publish workflow
Add github CI and auto-publish workflow
