From 6d95b7b6405fb2bfa9e585e2b8c00d5faae9fb23 Mon Sep 17 00:00:00 2001 From: Sven-Hendrik Haase Date: Tue, 21 Jul 2020 01:26:37 +0200 Subject: Switch to GitHub Actions (#344) * Switch to GitHub Actions * Switch CI badge to GitHub Actions flow * Only run on nightly for now --- .github/workflows/ci.yml | 46 +++++++++++++++++++++++ .github/workflows/publish.yml | 74 +++++++++++++++++++++++++++++++++++++ .travis.yml | 85 ------------------------------------------- README.md | 2 +- 4 files changed, 121 insertions(+), 86 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/publish.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..219e187 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,46 @@ +name: CI + +on: [push, pull_request] + +jobs: + ci: + name: CI with ${{ matrix.rust }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + rust: [nightly] + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup Rust toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ matrix.rust }} + override: true + components: rustfmt, clippy + + - name: cargo build + uses: actions-rs/cargo@v1 + with: + command: build + + - name: cargo test + uses: actions-rs/cargo@v1 + with: + command: test + + - name: cargo fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + - name: cargo clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..b2a1503 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,74 @@ +name: Publish + +on: + push: + tags: + - 'v*' + +jobs: + publish: + name: Publish for ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + include: + - os: ubuntu-latest + artifact_name: target/x86_64-unknown-linux-musl/release/miniserve + release_name: linux-x86_64 + target: x86_64-unknown-linux-musl + - os: windows-latest + artifact_name: target/x86_64-pc-windows-msvc/release/miniserve.exe + release_name: windows-x86_64.exe + target: x86_64-pc-windows-msvc + - os: macos-latest + artifact_name: target/x86_64-apple-darwin/release/miniserve + release_name: macos-x86_64 + target: x86_64-apple-darwin + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + target: ${{ matrix.target }} + + - run: sudo apt install musl-tools + if: matrix.os == 'ubuntu-latest' + + - name: cargo build + uses: actions-rs/cargo@v1 + with: + command: build + args: --release --locked --target=${{ matrix.target }} + + - name: Compress binaries + uses: svenstaro/upx-action@v2 + with: + file: ${{ matrix.artifact_name }} + args: --better --lzma + + - name: Get tag name + id: tag_name + run: | + echo ::set-output name=current_version::${GITHUB_REF#refs/tags/v} + shell: bash + + - name: Get CHANGELOG.md entry + id: changelog_reader + uses: mindsers/changelog-reader-action@v1 + with: + version: ${{ steps.tag.outputs.current_version }} + path: ./CHANGELOG.md + + - name: Release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ${{ matrix.artifact_name }} + tag: ${{ github.ref }} + asset_name: miniserve-$tag-${{ matrix.release_name }} + body: ${{ steps.changelog_reader.outputs.log_entry }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2b4c0a0..0000000 --- a/.travis.yml +++ /dev/null @@ -1,85 +0,0 @@ -language: rust -dist: bionic - -# According to https://docs.travis-ci.com/user/customizing-the-build#rows-that-are-allowed-to-fail, -# these empty arrays are actually required. -rust: [] -env: [] - -addons: - apt: - packages: - - mingw-w64 - - upx - - musl - - musl-dev - - musl-tools - -matrix: - allow_failures: - - rust: stable - env: [] - - rust: beta - env: [] - include: - - rust: stable - env: [] - - rust: beta - env: [] - - rust: nightly - env: [] - - rust: nightly - env: - - TARGET=x86_64-unknown-linux-musl - - BIN_NAME=miniserve - - PROPER_NAME=miniserve-linux-x86_64 - os: linux - - rust: nightly - env: - - TARGET=x86_64-pc-windows-gnu - - BIN_NAME=miniserve.exe - - PROPER_NAME=miniserve-win-x86_64.exe - - RUSTFLAGS="-C linker=x86_64-w64-mingw32-gcc" - os: linux - - rust: nightly - env: - - TARGET=x86_64-apple-darwin - - BIN_NAME=miniserve - - PROPER_NAME=miniserve-osx-x86_64 - os: osx - - rust: nightly-2020-03-11 - env: - - CLIPPY=true - -before_install: - - rustup self update - - rustup update - -install: - # On Apple, the default target is already the right one. - - if [[ -n $TARGET && $TARGET != "x86_64-apple-darwin" ]]; then rustup target add $TARGET; fi - - if [[ -n $CLIPPY ]]; then rustup component add clippy; fi - -script: - # If this is a normal, non-deployment build... - - if [[ -z $TARGET && -z $CLIPPY ]]; then cargo build && RUST_BACKTRACE=1 cargo test; fi - - if [[ -n $CLIPPY ]]; then cargo clippy -- --deny clippy::all; fi - - if [[ -n $TARGET ]]; then cargo build --release --locked --target $TARGET; fi - -before_deploy: - # If this is a binary deployment... - - if [[ -n $TARGET ]]; then cp -a target/$TARGET/release/$BIN_NAME $PROPER_NAME && strip $PROPER_NAME; fi - - # Run upx on the binary if this is a deployment for Linux or Windows - - if [[ $TARGET = "x86_64-pc-windows-gnu" ]]; then upx $PROPER_NAME; fi - - if [[ $TARGET = "x86_64-unknown-linux-musl" ]]; then upx $PROPER_NAME; fi - -deploy: - - provider: releases - api_key: - secure: "3lixPJV+e4/iAPKh0nwi6sPxO9OAO3y6h0+lreoi18hj9p8b7uoOXlYFG910BkVi15oCevPvXFDZ/pObqmCfWGX6Ahc5Lh/HTvIZH95kSAYlw/AUhBSKLohT/QXwmzUwaAwffQ0iIagrrBDb8BwMBkzqDmWAM1zuF+fMMfZ+iWB3yUN+QvzU6jYR9msfJSL2tNtgV1eFh7N+Xj277dMkZgkNgea3WwYL/USqaUDIsK5irBszETeg+n6yz2ERsp6SRpJrpZEhDqLaAQfu3pSoyNVP77vQb+q2MixZbYS3Zdq4w3p0LR9qAjFd8Ts38/ki/gGIEdmcO7FT6P1VUFzr+iW9nK49/rbYgw+TMWW+/pQJF6C7I89szsp5m4MUPnxesu/9NVyxrsYPuevgGh5IoB29eYBMoFETEK0XabCD/BAXnHvBbJxAOsZttU0MtjJWa0EelUSkZjaODEZVfGr7Z9I/Ji765QeFLJ4FDovJB056IOIhbAgIcqi9ItanJxsrLTI29BNB/zaMn+WY0s8HvLPanHaEKXg6cuhm8ptvM9nUlcDEx7zpirNV/OHP5/QRasMCpMHE20U7aRakKK+fpCskC78kjeU2fq7iZZp8fv2yocOqeWpX//clYhtuWs878I3MGkjpSxgI2I6nLisx+r/bWJvg1DZf7txW/CYyWIY=" - file: $PROPER_NAME - skip_cleanup: true - on: - branch: master - tags: true - condition: $TRAVIS_RUST_VERSION = nightly && -n $TARGET diff --git a/README.md b/README.md index 27d34fb..e8b0ffb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # miniserve - a CLI tool to serve files and dirs over HTTP -[![Build Status](https://travis-ci.org/svenstaro/miniserve.svg?branch=master)](https://travis-ci.org/svenstaro/miniserve) +[![CI](https://github.com/svenstaro/miniserve/workflows/CI/badge.svg)](https://github.com/svenstaro/miniserve/actions) [![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/svenstaro/miniserve)](https://cloud.docker.com/repository/docker/svenstaro/miniserve/) [![AUR](https://img.shields.io/aur/version/miniserve.svg)](https://aur.archlinux.org/packages/miniserve/) [![Crates.io](https://img.shields.io/crates/v/miniserve.svg)](https://crates.io/crates/miniserve) -- cgit v1.2.3