From ecd7d1c7e341510fa72abf3eb6f748f69667db42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Saparelli?= Date: Sat, 10 Apr 2021 23:53:12 +1200 Subject: [PATCH] Switch to gh actions and clean up metadata and build stuff --- .github/workflows/audit.yml | 12 +++ .github/workflows/check.yml | 56 ++++++++++++++ .github/workflows/release.yml | 140 ++++++++++++++++++++++++++++++++++ .travis.yml | 83 -------------------- CONTRIBUTING.md | 28 ++----- Cargo.toml | 49 +++++++----- Makefile | 30 -------- README.md | 8 +- bin/manpage | 2 + ci/before.sh | 18 ----- ci/deploy.sh | 87 --------------------- ci/script.sh | 10 --- 12 files changed, 252 insertions(+), 271 deletions(-) create mode 100644 .github/workflows/audit.yml create mode 100644 .github/workflows/check.yml create mode 100644 .github/workflows/release.yml delete mode 100644 .travis.yml delete mode 100644 Makefile create mode 100755 bin/manpage delete mode 100755 ci/before.sh delete mode 100755 ci/deploy.sh delete mode 100755 ci/script.sh diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml new file mode 100644 index 0000000..8fd8458 --- /dev/null +++ b/.github/workflows/audit.yml @@ -0,0 +1,12 @@ +name: Security audit +on: + schedule: + - cron: '0 0 * * *' +jobs: + audit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/audit-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..d48fb84 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,56 @@ +on: + pull_request: + push: + branches: + - main + - try/** + tags-ignore: + - v*.*.* + +name: Checks & Tests + +jobs: + check: + strategy: + matrix: + platform: + - ubuntu + - windows + - macos + + name: Check & Test on ${{ matrix.platform }} + runs-on: "${{ matrix.platform }}-latest" + + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - run: rustup component add clippy + - uses: actions-rs/cargo@v1 + with: + command: check + - uses: actions-rs/cargo@v1 + with: + command: test + - uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings + + msrv: + name: Check on MSRV + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: 1.38.0 + override: true + - uses: actions-rs/cargo@v1 + with: + command: check + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2d998dc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,140 @@ +name: Release + +on: + push: + tags: + - "*.*.*" + +jobs: + build: + strategy: + matrix: + name: + - linux-amd64-gnu + - linux-amd64-musl + - linux-i686-musl + - linux-armhf-gnu + - linux-arm64-gnu + - mac-x86-64 + - windows-x86-64 + include: + - name: linux-amd64-gnu + os: ubuntu-latest + target: x86_64-unknown-linux-gnu + cross: false + + - name: linux-amd64-musl + os: ubuntu-latest + target: x86_64-unknown-linux-musl + cross: true + + - name: linux-i686-musl + os: ubuntu-latest + target: i686-unknown-linux-musl + cross: true + + - name: linux-armhf-gnu + os: ubuntu-latest + target: armv7-unknown-linux-gnueabihf + cross: true + + - name: linux-arm64-gnu + os: ubuntu-latest + target: aarch64-unknown-linux-gnu + cross: true + + - name: mac-x86-64 + os: macos-latest + target: x86_64-apple-darwin + cross: false + + - name: windows-x86-64 + os: windows-latest + target: x86_64-pc-windows-msvc + cross: false + + name: Binaries for ${{ matrix.name }} + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }} + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + - uses: actions-rs/cargo@v1 + name: Build + with: + use-cross: ${{ matrix.cross }} + command: build + args: --release --locked --target ${{ matrix.target }} + - name: Package + shell: bash + run: | + set -euxo pipefail + ext="" + [[ "${{ matrix.name }}" == windows-* ]] && ext=".exe" + bin="target/${{ matrix.target }}/release/watchexec${ext}" + version=$(echo "${{ github.ref }}" | cut -d/ -f3 | cut -dv -f2) + dst="watchexec-${version}-${{ matrix.target }}" + mkdir "$dst" + strip "$bin" || true + mv "$bin" "$dst/" + mv README.md LICENSE completions doc/watchexec.1 "$dst/" + - name: Archive (tar) + if: '! startsWith(matrix.name, ''windows-'')' + shell: bash + run: | + set -euxo pipefail + version=$(echo "${{ github.ref }}" | cut -d/ -f3 | cut -dv -f2) + dst="watchexec-${version}-${{ matrix.target }}" + tar cavf "$dst.tar.xz" "$dst" + - name: Archive (deb) + if: startsWith(matrix.name, 'linux-') + shell: bash + run: | + set -euxo pipefail + version=$(echo "${{ github.ref }}" | cut -d/ -f3 | cut -dv -f2) + dst="watchexec-${version}-${{ matrix.target }}" + mkdir -p "deb/$dst" + cd "deb/$dst" + mkdir -p DEBIAN usr/{bin,share/{man/man1,zsh/site-functions}} + cp "../../$dst/watchexec" usr/bin/ + cp "../../$dst/watchexec.1" usr/share/man/man1/ + cp "../../$dst/completions/zsh" usr/share/zsh/site-functions/_watchexec + cat <<-CONTROL > DEBIAN/control + Package: watchexec + Version: ${version} + Architecture: $(echo "${{ matrix.name }}" | cut -d- -f2) + Maintainer: Félix Saparelli + Installed-Size: $(du -d1 usr | tail -n1 | cut -d\t -f1) + Homepage: https://github.com/watchexec/watchexec + Description: Executes commands in response to file modifications. + Software development often involves running the same commands over and over. Boring! + Watchexec is a simple, standalone tool that watches a path and runs a command whenever it detects modifications. + CONTROL + cd .. + fakeroot dpkg -b "$dst" + mv "$dst.deb" ../ + cd .. + - name: Archive (zip) + if: startsWith(matrix.name, 'windows-') + shell: bash + run: | + set -euxo pipefail + version=$(echo "${{ github.ref }}" | cut -d/ -f3 | cut -dv -f2) + dst="watchexec-${version}-${{ matrix.target }}" + 7z a "$dst.zip" "$dst" + - uses: softprops/action-gh-release@v1 + with: + files: | + watchexec-*.tar.xz + watchexec-*.deb + watchexec-*.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 603752c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,83 +0,0 @@ -dist: xenial -language: rust - -cache: - - directories: - - $HOME/.cargo - - target/debug/deps - - target/$TARGET/debug/deps -before_cache: - # Travis can't cache files that are not readable by "others" - - chmod -R a+r $HOME/.cargo - -addons: - apt: - packages: - - fakeroot - - musl-dev - - musl-tools - -env: - global: - - PROJECT_NAME=watchexec - -jobs: - fast_finish: true - allow_failures: - - env: CARGO_CLIPPY=1 TARGET=x86_64-unknown-linux-gnu - - env: TARGET=i686-unknown-linux-musl - - env: TARGET=x86_64-unknown-linux-musl - - env: TARGET=x86_64-pc-windows-gnu - include: - # Default test+release versions - - os: windows - rust: stable - env: TARGET=x86_64-pc-windows-msvc - - os: osx - rust: stable - env: TARGET=x86_64-apple-darwin - - os: linux - rust: stable - env: TARGET=x86_64-unknown-linux-gnu - - # Extra targets, released on best-effort - - os: linux - rust: stable - env: TARGET=i686-unknown-linux-musl - - os: linux - rust: stable - env: TARGET=x86_64-unknown-linux-musl - - os: windows - rust: stable - env: TARGET=x86_64-pc-windows-gnu - - # Minimum version advertised in readme - - os: windows - rust: 1.38.0 - env: TARGET=x86_64-pc-windows-msvc - - os: linux - rust: 1.38.0 - env: TARGET=x86_64-unknown-linux-gnu - - # Clippy only - - env: CARGO_CLIPPY=1 TARGET=x86_64-unknown-linux-gnu - -before_install: ci/before.sh -script: ci/script.sh - -before_deploy: ci/deploy.sh -deploy: - provider: releases - api_key: - secure: sbV2K4G2SA78U6d8SNZKExenWnuv1MsJ/9ovDDH4ucnzkpJEWDV2iwPklcu5oaRj3Sz4jYuYXToqcbJmSjL5eXjlk8rh2sG2LWT+8Up3X1vxte2XFXko15I/613rD8E/qWfS9FqzmuhMX+gb4P7OwWvVUwtw0IIuSGfBW/TEgUTFUZnUmgdm5ra8VnV3CvmTbn8botxbkdAUvk4C0g7yqHjlV7v9xU+DEXz2Y820cAH8ulu1ZU3JBm+XfVzZ09kByeQ7wnvyRuE4RhVtKK8nKUy+2JF7HX5N+0Du8z9ZHosV6+uoUz9i2OecYzAvL8xKiSkeHBqTxIDTeM4lnnDmnm5LsJ4aEU6pBSuWhglmflTbtAN7rBfYgZGJ6je6Gem5bOcCDtGI7+2qjf00Jo7vbmyK6D6Y6yxwf3W0QnOZcXrn9BWZLMMgochIBlVTTM1zFodcprpdHo8iHNVms3A++WqLnp1O0L/55id59VITGJNafy2vmXU/nlQi2MO03s3SF3jdHT7rchYjJRAcGR79QtCLiL3CbYnaQJsDNviyMm1VC6hkst0tXB8t12v2ht5NU7NEN8E31jnnRLRnwr7LUFRgOzFVF0M5jSqs3eCLnYyI7gCMKL2qOZ2yxJuD9bKsVZDpVvUqnaj5ifE+TMYoONPrc9W1hTyfcND9MhCsM+g= - file_glob: true - file: ${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.* - skip_cleanup: true - on: - repo: watchexec/watchexec - tags: true - rust: stable - -notifications: - email: - on_success: never diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dd82fc9..ddedcb6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -47,12 +47,6 @@ Apart from that, welcome and thank you for your time! A release goes through these steps: -0. Versioning indications on PRs. These are statements by the maintainers when reviewing or - discussing PRs generally in `[square brackets]` that make an indication of what implication - merging the PR will have on versioning. For example: - - > [versioning note: this is a feature add but not considered an api breaking change (due to the builder)] - 1. Opening a draft release. Before even merging anything, a draft (only visible privately) release is made. These are a github feature and only visible to maintainers. Name the release... that can be descriptive or whimsical or both. Release title template is `{version without v}: {title}`. @@ -70,7 +64,8 @@ A release goes through these steps: also added the corresponding completions, manpage entries, readme entries. Or two PRs may conflict slightly or do the same thing twice, in which case harmonising things is required here. -5. Run `cargo fmt`, `cargo test`, `cargo clippy`. CI will also run, wait for that. In the meantime: +5. Run `cargo fmt`, `cargo test`, `cargo clippy`, `bin/manpage`. Commit the result, if any. + CI will also run, wait for that. In the meantime: 6. Run through related issues to the PRs and close them if that wasn't done automatically. Or if the PRs only fixed a problem partially, chime in to mention that, and to restate what remains to fix. @@ -79,23 +74,14 @@ A release goes through these steps: 8. Check for any dependency updates with `cargo outdated -R`. -9. Change the version number, run `cargo check`, and make a commit that contains _only_ the - Cargo.toml and Cargo.lock changes. Use the version number (without `v` prefix) as only message. +9. Run `bin/version 1.2.3` where `1.2.3` is the new version number. This will tag and push, + triggering the GitHub Action for releases. -10. Create an annotated tag named the naked version (without `v` prefix), with identical message: +10. Wait for all builds to complete, then attach the draft release to the tag, and publish it. - ``` - $ git tag -am 1.14.0{,} - ``` +11. Run the `cargo publish`. -11. Push: `$ git push --follow-tags`. - -12. Edit the draft release, select the newly pushed tag, and publish it. Built artifacts will get - built and get added automatically to the release as downloads. - -13. Run the `cargo publish`. - -14. Announce the release. +12. Announce the release. --- vim: tw=100 diff --git a/Cargo.toml b/Cargo.toml index 40542fd..58d6225 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,36 +1,32 @@ [package] name = "watchexec" version = "1.14.1" -authors = ["Matt Green "] + +authors = ["Matt Green ", "Félix Saparelli "] +license = "Apache-2.0" description = "Executes commands in response to file modifications" +keywords = ["watcher", "inotify", "fsevents", "kqueue"] +categories = ["command-line-utilities"] + documentation = "https://github.com/watchexec/watchexec" homepage = "https://github.com/watchexec/watchexec" repository = "https://github.com/watchexec/watchexec" readme = "README.md" -keywords = ["watcher", "inotify", "fsevents", "kqueue"] -categories = ["command-line-utilities"] -license = "Apache-2.0" -exclude = ["/ci/*", "/pkg/*", "/.travis.yml", "/Makefile", "/appveyor.yml"] + edition = "2018" +exclude = ["/pkg", "/bin", "/.github"] -[badges] -appveyor = { repository = "watchexec/watchexec" } -travis-ci = { repository = "watchexec/watchexec" } - -[profile.dev] -panic = "abort" - -[profile.release] -lto = true -panic = "abort" +[[bin]] +name = "watchexec" +doc = false [dependencies] +derive_builder = "0.9.0" glob = "0.3.0" globset = "0.4.5" lazy_static = "1.1.0" log = "0.4.4" notify = "4.0.15" -derive_builder = "0.9.0" walkdir = "2.3.1" [dependencies.clap] @@ -50,9 +46,22 @@ nix = "0.17.0" version = "0.3.9" features = ["ioapiset", "jobapi2", "tlhelp32"] -[[bin]] -name = "watchexec" -doc = false - [build-dependencies] embed-resource = "1.3.3" + +[profile.dev] +panic = "abort" + +[profile.release] +lto = true +panic = "abort" +codegen-units = 1 + +[package.metadata.binstall] +pkg-url = "{ repo }/releases/download/{ version }/{ name }-{ version }-{ target }.tar.xz" +bin-dir = "{ name }-{ version }-{ target }/{ bin }{ format }" +pkg-fmt = "txz" + +[package.metadata.binstall.overrides.x86_64-pc-windows-msvc] +pkg-url = "{ repo }/releases/download/{ version }/{ name }-{ version }-{ target }.zip" +pkg-fmt = "zip" diff --git a/Makefile b/Makefile deleted file mode 100644 index e2ec70c..0000000 --- a/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -LATEST_TAG=$(shell git tag | tail -n1) - -.PHONY: doc test - -debug: src/* Cargo.toml - @cargo build - -release: src/* Cargo.toml - @cargo build --release --locked - -clean: - @cargo clean - -test: - @cargo test - -doc: doc/watchexec.1.ronn - @ronn doc/watchexec.1.ronn - -cargo-release: - @cargo publish - -homebrew-release: - @brew bump-formula-pr --strict --url="https://github.com/mattgreen/watchexec/archive/$(LATEST_TAG).tar.gz" watchexec - -install: release - @cp target/release/watchexec /usr/bin - -uninstall: - @rm /usr/bin/watchexec diff --git a/README.md b/README.md index ecee34f..22eecf4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # watchexec -[![Build status](https://badgen.net/travis/watchexec/watchexec/main)](https://travis-ci.org/watchexec/watchexec) +[![CI status](https://github.com/watchexec/watchexec/actions/workflows/check.yml/badge.svg)](https://github.com/watchexec/watchexec/actions/workflows/check.yml) [![Crates.io status](https://badgen.net/crates/v/watchexec)](https://crates.io/crates/watchexec) [![Docs status](https://docs.rs/watchexec/badge.svg)](https://docs.rs/watchexec) @@ -91,6 +91,10 @@ Requires Rust 1.38 or later. $ cargo install watchexec +#### [Binstall](https://github.com/ryankurte/cargo-binstall) + + $ cargo binstall watchexec + #### Pre-built Use the GitHub Releases tab to obtain the tarball/zipfile appropriate for your platform and architecture, extract it, and place it in your `PATH`. @@ -111,7 +115,7 @@ PRs for packaging in unsupported distros are welcome. #### Debian -A deb package is available for amd64 architectures in the GitHub Releases. +A deb package is available for several architectures in the GitHub Releases. #### Arch Linux diff --git a/bin/manpage b/bin/manpage new file mode 100755 index 0000000..2d75aeb --- /dev/null +++ b/bin/manpage @@ -0,0 +1,2 @@ +#!/bin/sh +exec ronn doc/watchexec.1.ronn diff --git a/ci/before.sh b/ci/before.sh deleted file mode 100755 index 339b17b..0000000 --- a/ci/before.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -set -e - -rustup target add $TARGET -cargo clean --target $TARGET --verbose - -if [ $TRAVIS_OS_NAME = windows ]; then - choco install windows-sdk-10.1 -fi - -if [[ ! -z "$CARGO_AUDIT" ]]; then - which cargo-audit || cargo install --debug cargo-audit - # --debug for faster build at the minimal expense of runtime speed -elif [[ ! -z "$CARGO_CLIPPY" ]]; then - rustup component add clippy -fi - diff --git a/ci/deploy.sh b/ci/deploy.sh deleted file mode 100755 index fb5584c..0000000 --- a/ci/deploy.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env bash - -if [[ ! -z "$CARGO_CLIPPY" ]]; then - echo Clippy says: I shan’t deploy - exit 1 -fi - -### Vars - -project="$PROJECT_NAME" -tag="$TRAVIS_TAG" -target="$TARGET" - -[[ -z "$project" ]] && exit 21 -[[ -z "$tag" ]] && exit 22 -[[ -z "$target" ]] && exit 23 - -ext="" -windows="" -if [[ "$target" == *"windows"* ]]; then - choco install 7zip - ext=".exe" - windows="1" -fi - -build_dir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp) -out_dir=$(pwd) -name="$project-$tag-$target" - -### Build - -cargo build --target $target --release --locked - -### Decorate - -mkdir "$build_dir/$name" -cp -v "target/$target/release/$project$ext" "$build_dir/$name/" -cp -v LICENSE "$build_dir/$name/" -cp -v README.md "$build_dir/$name/" -cp -v completions/zsh "$build_dir/$name/" -cp -v doc/watchexec.1 "$build_dir/$name/" -ls -shal "$build_dir/$name/" - -### Strip - -cd "$build_dir" -strip "$name/$project$ext" -ls -shal "$name/" - -### Pack - -if [[ -z "$windows" ]]; then - tar cvf "$out_dir/$name.tar" "$name" - cd "$out_dir" - xz -f9 "$name.tar" -else - 7z a "$out_dir/$name.zip" "$name" -fi - -### Debify - -if [[ "$target" == "x86_64-unknown-linux-gnu" ]]; then - mkdir -p "$build_dir/deb/$name" - cd "$build_dir/deb/$name" - - mkdir -p DEBIAN usr/bin usr/share/man/man1 usr/share/zsh/site-functions - cp "../../$name/watchexec" usr/bin/ - cp "../../$name/watchexec.1" usr/share/man/man1/ - cp "../../$name/zsh" usr/share/zsh/site-functions/_watchexec - cat < DEBIAN/control -Package: watchexec -Version: ${TRAVIS_TAG} -Architecture: amd64 -Maintainer: Félix Saparelli -Installed-Size: $(du -d1 usr | tail -n1 | cut -d\t -f1) -Homepage: https://github.com/watchexec/watchexec -Description: Executes commands in response to file modifications. - Software development often involves running the same commands over and over. Boring! - Watchexec is a simple, standalone tool that watches a path and runs a command whenever it detects modifications. -CONTROL - cd .. - fakeroot dpkg -b "$name" - mv "$name.deb" "$out_dir/" - popd -fi - -ls -shal "$out_dir/" diff --git a/ci/script.sh b/ci/script.sh deleted file mode 100755 index b82b0bd..0000000 --- a/ci/script.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -if [[ ! -z "$CARGO_AUDIT" ]]; then - cargo check --target $TARGET - cargo audit -elif [[ ! -z "$CARGO_CLIPPY" ]]; then - cargo clippy --target $TARGET -else - cargo test --target $TARGET -fi