cdestroy 0.0.1

Build native libraries WITHOUT cmake
Documentation
# Replace this line with the commented one to actually run the action in your repo(s)
on: public
#on: [push, pull_request]

name: CI
jobs:
  lint:
    name: Lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true

      # make sure all code has been formatted with rustfmt
      - run: rustup component add rustfmt
      - name: check rustfmt
        uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: -- --check --color always

      # run clippy to verify we have no warnings
      - run: rustup component add clippy
      - name: cargo fetch
        uses: actions-rs/cargo@v1
        with:
          command: fetch
      - name: cargo clippy
        uses: actions-rs/cargo@v1
        with:
          command: clippy
          args: --lib --tests -- -D warnings

  test:
    name: Test
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macOS-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v1
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true
      - name: cargo fetch
        uses: actions-rs/cargo@v1
        with:
          command: fetch
      - name: cargo test build
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: --tests --release
      - name: cargo test
        uses: actions-rs/cargo@v1
        with:
          command: test
          args: --release

  # Remove this check if you don't use cargo-deny in the repo
  deny-check:
    name: cargo-deny
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: EmbarkStudios/cargo-deny-action@v0

  # Remove this check if you don't publish the crate(s) from this repo
  publish-check:
    name: Publish Check
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - uses: actions-rs/toolchain@v1
      with:
        toolchain: stable
        override: true
    - name: cargo fetch
      uses: actions-rs/cargo@v1
      with:
        command: fetch
    - name: cargo publish check
      uses: actions-rs/cargo@v1
      with:
        command: publish
        args: --dry-run

  # Remove this job if you don't publish the crate(s) from this repo
  # You must add a crates.io API token to your GH secrets called CRATES_IO_TOKEN
  publish:
    name: Publish
    needs: [test, deny-check, publish-check]
    runs-on: ubuntu-latest
    if: startsWith(github.ref, 'refs/tags/')
    steps:
    - uses: actions/checkout@v1
    - uses: actions-rs/toolchain@v1
      with:
        toolchain: stable
        override: true
    - name: cargo fetch
      uses: actions-rs/cargo@v1
      with:
        command: fetch
    - name: cargo publish
      uses: actions-rs/cargo@v1
      env:
        CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
      with:
        command: publish

  # Remove this job if you don't release binaries
  # Replace occurances of $BIN_NAME with the name of your binary
  release:
    name: Release
    needs: [test, deny-check]
    if: startsWith(github.ref, 'refs/tags/')
    strategy:
      matrix:
        os: [ubuntu-latest, macOS-latest, windows-latest]
        include:
          - os: ubuntu-latest
            rust: stable
            target: x86_64-unknown-linux-musl
            bin: $BIN_NAME
            # We don't enable the progress feature when targeting
            # musl since there are some dependencies on shared libs
            features: ""
          - os: windows-latest
            rust: stable
            target: x86_64-pc-windows-msvc
            bin: $BIN_NAME.exe
            features: --features=progress
          - os: macOS-latest
            rust: stable
            target: x86_64-apple-darwin
            bin: $BIN_NAME
            features: --features=progress
    runs-on: ${{ matrix.os }}
    steps:
      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: ${{ matrix.rust }}
          override: true
          target: ${{ matrix.target }}
      - name: Install musl tools
        if: matrix.os == 'ubuntu-latest'
        run: |
          sudo apt-get install -y musl-tools
      - name: Checkout
        uses: actions/checkout@v1
      - name: cargo fetch
        uses: actions-rs/cargo@v1
        with:
          command: fetch
          args: --target ${{ matrix.target }}
      - name: Release build
        uses: actions-rs/cargo@v1
        if: matrix.os != 'ubuntu-latest'
        with:
          command: build
          args: --release --target ${{ matrix.target }} ${{ matrix.features }}
      - name: Package
        shell: bash
        run: |
          name=$BIN_NAME
          tag=$(git describe --tags --abbrev=0)
          release_name="$name-$tag-${{ matrix.target }}"
          release_tar="${release_name}.tar.gz"
          mkdir "$release_name"

          if [ "${{ matrix.target }}" != "x86_64-pc-windows-msvc" ]; then
              strip "target/${{ matrix.target }}/release/${{ matrix.bin }}"
          fi

          cp "target/${{ matrix.target }}/release/${{ matrix.bin }}" "$release_name/"
          cp README.md LICENSE-APACHE LICENSE-MIT "$release_name/"
          tar czvf "$release_tar" "$release_name"

          rm -r "$release_name"

          # Windows environments in github actions don't have the gnu coreutils installed,
          # which includes the shasum exe, so we just use powershell instead
          if [ "${{ matrix.os }}" == "windows-latest" ]; then
            echo "(Get-FileHash \"${release_tar}\" -Algorithm SHA256).Hash | Out-File -Encoding ASCII -NoNewline \"${release_tar}.sha256\"" | pwsh -c -
          else
            echo -n "$(shasum -ba 256 "${release_tar}" | cut -d " " -f 1)" > "${release_tar}.sha256"
          fi
      - name: Publish
        uses: softprops/action-gh-release@v1
        with:
          draft: true
          files: '$BIN_NAME*'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}