Switch to gh actions and clean up metadata and build stuff

This commit is contained in:
Félix Saparelli 2021-04-10 23:53:12 +12:00
parent 3a3ae89046
commit ecd7d1c7e3
12 changed files with 252 additions and 271 deletions

12
.github/workflows/audit.yml vendored Normal file
View file

@ -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 }}

56
.github/workflows/check.yml vendored Normal file
View file

@ -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

140
.github/workflows/release.yml vendored Normal file
View file

@ -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 <aur@passcod.name>
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 }}

View file

@ -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

View file

@ -47,12 +47,6 @@ Apart from that, welcome and thank you for your time!
A release goes through these steps: 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 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 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}`. 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 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. 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 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. 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`. 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 9. Run `bin/version 1.2.3` where `1.2.3` is the new version number. This will tag and push,
Cargo.toml and Cargo.lock changes. Use the version number (without `v` prefix) as only message. 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.
``` 11. Run the `cargo publish`.
$ git tag -am 1.14.0{,}
```
11. Push: `$ git push --follow-tags`. 12. Announce the release.
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.
--- ---
vim: tw=100 vim: tw=100

View file

@ -1,36 +1,32 @@
[package] [package]
name = "watchexec" name = "watchexec"
version = "1.14.1" version = "1.14.1"
authors = ["Matt Green <mattgreenrocks@gmail.com>"]
authors = ["Matt Green <mattgreenrocks@gmail.com>", "Félix Saparelli <felix@passcod.name>"]
license = "Apache-2.0"
description = "Executes commands in response to file modifications" description = "Executes commands in response to file modifications"
keywords = ["watcher", "inotify", "fsevents", "kqueue"]
categories = ["command-line-utilities"]
documentation = "https://github.com/watchexec/watchexec" documentation = "https://github.com/watchexec/watchexec"
homepage = "https://github.com/watchexec/watchexec" homepage = "https://github.com/watchexec/watchexec"
repository = "https://github.com/watchexec/watchexec" repository = "https://github.com/watchexec/watchexec"
readme = "README.md" 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" edition = "2018"
exclude = ["/pkg", "/bin", "/.github"]
[badges] [[bin]]
appveyor = { repository = "watchexec/watchexec" } name = "watchexec"
travis-ci = { repository = "watchexec/watchexec" } doc = false
[profile.dev]
panic = "abort"
[profile.release]
lto = true
panic = "abort"
[dependencies] [dependencies]
derive_builder = "0.9.0"
glob = "0.3.0" glob = "0.3.0"
globset = "0.4.5" globset = "0.4.5"
lazy_static = "1.1.0" lazy_static = "1.1.0"
log = "0.4.4" log = "0.4.4"
notify = "4.0.15" notify = "4.0.15"
derive_builder = "0.9.0"
walkdir = "2.3.1" walkdir = "2.3.1"
[dependencies.clap] [dependencies.clap]
@ -50,9 +46,22 @@ nix = "0.17.0"
version = "0.3.9" version = "0.3.9"
features = ["ioapiset", "jobapi2", "tlhelp32"] features = ["ioapiset", "jobapi2", "tlhelp32"]
[[bin]]
name = "watchexec"
doc = false
[build-dependencies] [build-dependencies]
embed-resource = "1.3.3" 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"

View file

@ -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

View file

@ -1,6 +1,6 @@
# watchexec # 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) [![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) [![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 $ cargo install watchexec
#### [Binstall](https://github.com/ryankurte/cargo-binstall)
$ cargo binstall watchexec
#### Pre-built #### 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`. 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 #### 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 #### Arch Linux

2
bin/manpage Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
exec ronn doc/watchexec.1.ronn

View file

@ -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

View file

@ -1,87 +0,0 @@
#!/usr/bin/env bash
if [[ ! -z "$CARGO_CLIPPY" ]]; then
echo Clippy says: I shant 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 <<CONTROL > DEBIAN/control
Package: watchexec
Version: ${TRAVIS_TAG}
Architecture: amd64
Maintainer: Félix Saparelli <aur@passcod.name>
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/"

View file

@ -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