diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a4b1aa8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +root = true + +[*] +charset = utf-8 +trim_trailing_whitespace = true + +end_of_line = lf +insert_final_newline = true + +indent_style = space +indent_size = 4 + +[*.md] +trim_trailing_whitespace = false + +[*.yml] +indent_size = 2 diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 3252d83..b062756 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -19,13 +19,14 @@ jobs: if: github.ref == 'refs/heads/main' # For other branches, artifacts are attached to the workflow run as `dist.zip` steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - name: Download built packages uses: actions/download-artifact@v3 with: name: dist - name: Extract version number - run: echo "VERSION=v$(cat ./version)" >> $GITHUB_ENV + run: echo "VERSION=v$(head -n 1 ./version)" >> $GITHUB_ENV - name: Extract release notes id: extract-release-notes uses: ffurrer2/extract-release-notes@v1 @@ -43,7 +44,8 @@ jobs: build-linux: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - name: Install fpm and build dependencies run: | sudo apt install -y rubygems libarchive-tools rpm zstd @@ -59,7 +61,8 @@ jobs: build-macos: runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - name: Install fpm run: sudo gem install --no-document fpm - name: Build package @@ -73,7 +76,8 @@ jobs: build-freebsd: runs-on: macos-12 steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - name: Install fpm && Build package uses: vmactions/freebsd-vm@v0 with: @@ -109,7 +113,8 @@ jobs: build-netbsd: runs-on: macos-12 steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - name: Install fpm && Build package uses: vmactions/netbsd-vm@v0 with: @@ -141,7 +146,8 @@ jobs: build-openbsd: runs-on: macos-12 steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - name: Install fpm && Build package uses: vmactions/openbsd-vm@v0 with: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0cd8e56..0541b1e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,8 @@ jobs: test-linux: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - name: Install ShellSpec run: git clone --depth=1 https://github.com/shellspec/shellspec.git "$HOME/shellspec/" - name: Test script @@ -20,7 +21,7 @@ jobs: - name: Build package run: ./build.sh deb - name: Test package - run: | + run: | sudo apt install -y ./dist/mommy-*.deb MOMMY_EXEC=mommy PATH="$HOME/shellspec:$PATH" ./test.sh sudo apt purge -y mommy @@ -28,7 +29,8 @@ jobs: test-macos: runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - name: Install ShellSpec run: git clone --depth=1 https://github.com/shellspec/shellspec.git "$HOME/shellspec/" - name: Test script @@ -46,7 +48,8 @@ jobs: test-freebsd: runs-on: macos-12 steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - name: Install ShellSpec && Install fpm && Test script && Build package && Test package uses: vmactions/freebsd-vm@v0 with: @@ -95,7 +98,8 @@ jobs: test-netbsd: runs-on: macos-12 steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - name: Install ShellSpec && Install fpm && Test script && Build package && Test package uses: vmactions/netbsd-vm@v0 with: @@ -138,7 +142,8 @@ jobs: test-openbsd: runs-on: macos-12 steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - name: Install ShellSpec && Test script && Build package && Test package uses: vmactions/openbsd-vm@v0 with: diff --git a/.shellspec b/.shellspec index 6e764f3..3a7bd45 100644 --- a/.shellspec +++ b/.shellspec @@ -1 +1,5 @@ --execdir @specfile +--no-warning-as-failure + +# OpenBSD: Workaround for https://github.com/shellspec/shellspec/issues/291 +--shell sh diff --git a/CHANGELOG.md b/CHANGELOG.md index cb99568..5c1f283 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## [Unreleased] +## [1.2.1] -- 2023-02-26 +* mommy supports homebrew now~ +* mommy supports arch linux aur now~ + + ## [1.2.0] -- 2023-02-24 * mommy can output to stdout without redirection by giving her the `-1` option~ * mommy ignores exit code `130` by default, but you can change this by setting `MOMMY_IGNORED_STATUSES`~ diff --git a/README.md b/README.md index ab7734a..aa1f291 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![github latest release](https://img.shields.io/github/v/release/FWDekker/mommy?style=for-the-badge)](https://github.com/FWDekker/mommy/releases/latest) [![github ci status](https://img.shields.io/github/actions/workflow/status/FWDekker/mommy/ci.yml?style=for-the-badge)](https://github.com/FWDekker/mommy/actions/workflows/ci.yml?query=branch%3Amain) [![mommy is licensed under unlicense](https://img.shields.io/github/license/FWDekker/mommy?style=for-the-badge)](https://github.com/FWDekker/mommy/blob/main/LICENSE) +[![mommy is on aur](https://img.shields.io/aur/version/mommy?style=for-the-badge)](https://aur.archlinux.org/packages/mommy/) mommy's here to support you! mommy will compliment you if things go well, and will encourage you if things are not going so well~ @@ -16,6 +17,40 @@ much~ ❤️ mommy works on any unix system. mommy is tested on ubuntu, debian, macos, freebsd, netbsd, and openbsd~ +### package manager +_don't see your favorite package manager? +check the distribution archives below. +not satisfied? +[request support for your favorite installation method by opening an issue](https://github.com/FWDekker/mommy/issues)~_ + +
+arch linux + +install on arch linux from the [aur mommy package](https://aur.archlinux.org/packages/mommy/), probably easiest with +[an aur helper](https://wiki.archlinux.org/title/AUR_helpers): + +```shell +# if you use paru +paru -S mommy +# if you use aura +aura -A mommy +# and so on +``` + +
+ +
+homebrew/linuxbrew + +install with homebrew/linuxbrew from the [mommy tap](https://github.com/FWDekker/homebrew-mommy): + +```shell +brew tap fwdekker/mommy +brew install mommy +``` +
+ +### distribution archives [download the latest release](https://github.com/FWDekker/mommy/releases/latest) for your platform and install as usual: * on debian/ubuntu/etc, run `sudo apt install ./mommy-*.deb`, * on red hat/fedora/etc, run `sudo dnf install ./mommy-*.rpm`, @@ -30,6 +65,7 @@ mommy is tested on ubuntu, debian, macos, freebsd, netbsd, and openbsd~ (usually `/usr/local/bin/`) (and optionally also copy `./src/main/resources/mommy.1` into `/usr/local/man/man1/`) +### what's next? after installation, you can [configure mommy](#configuration) and [integrate mommy with your shell](#shell-integration)~ to update mommy, just repeat the installation process~ @@ -239,7 +275,10 @@ after that, just run `./build.sh deb` (or better: `mommy ./build.sh deb`), and o replace `deb` with [one or more supported output types](https://fpm.readthedocs.io/en/v1.15.1/packaging-types.html). except don't use `pkgin`, but use `openbsd` for openbsd, and use `netbsd` for netbsd~ -before a new release, make sure to update the version number in `./version` and to update the `./CHANGELOG.md`~ +you can also run `PREFIX=/usr ./build.sh install` to install mommy into `/usr`, but this is mostly intended for +integration with package managers such as brew and arch's makepkg~ + +before a new release, make sure to update `./version` and `./CHANGELOG.md`~ to run tests, install [shellspec](https://github.com/shellspec/shellspec) and run `./test.sh`. by default, tests are run against `./src/main/sh/mommy`. diff --git a/build.sh b/build.sh index b2a21e6..2d9dc95 100755 --- a/build.sh +++ b/build.sh @@ -3,8 +3,8 @@ set -e cd -P -- "$(dirname -- "$0")" # Load configuration -version="$(cat version)" -manual_date="$(git log -1 --pretty="format:%cs" src/main/resources/mommy.1)" +version="$(head -n 1 ./version)" +date="$(tail -n 1 ./version)" # Clean rm -rf build/ dist/ @@ -12,7 +12,7 @@ rm -rf build/ dist/ # Prepare mkdir build/ cp src/main/sh/mommy src/main/resources/mommy.1 build/ -sed -i".bak" "s/%%VERSION_NUMBER%%/$version/g;s/%%MANUAL_DATE%%/$manual_date/g" build/* +sed -i".bak" "s/%%VERSION_NUMBER%%/$version/g;s/%%VERSION_DATE%%/$date/g" build/* gzip build/mommy.1 # Build @@ -22,6 +22,10 @@ for target in "$@"; do # Select targets case "$target" in + install) + target_exe="build/mommy=${PREFIX:?Prefix not specified}/bin/mommy" + target_man="build/mommy.1.gz=$PREFIX/share/man/man1/mommy.1.gz" + ;; netbsd) target_exe="build/mommy=/usr/pkg/bin/mommy" target_man="build/mommy.1.gz=/usr/pkg/man/man1/mommy.1.gz" @@ -38,6 +42,9 @@ for target in "$@"; do # Pre-process case "$target" in + install) + # Do nothing + ;; netbsd|openbsd) # Extract properties comment="$(<"./.fpm" grep -- "--description")" @@ -52,8 +59,8 @@ for target in "$@"; do # Copy input files mkdir -p "/tmp/mommy/$(dirname "${target_exe#*=}")" "/tmp/mommy/$(dirname "${target_man#*=}")" - cp "./${target_exe%=*}" "/tmp/mommy/${target_exe#*=}" - cp "./${target_man%=*}" "/tmp/mommy/${target_man#*=}" + cp "./${target_exe%%=*}" "/tmp/mommy/${target_exe#*=}" + cp "./${target_man%%=*}" "/tmp/mommy/${target_man#*=}" # Create control files cd /tmp/mommy @@ -86,10 +93,18 @@ for target in "$@"; do cd - ;; + *) + # Do nothing + ;; esac # Process case "$target" in + install) + mkdir -p "$(dirname "${target_exe#*=}")" "$(dirname "${target_man#*=}")" + cp "./${target_exe%%=*}" "${target_exe#*=}" + cp "./${target_man%%=*}" "${target_man#*=}" + ;; netbsd) cd /tmp/mommy pkg_create \ @@ -123,6 +138,9 @@ for target in "$@"; do # Post-process case "$target" in + install) + # Do nothing + ;; netbsd|openbsd) # Clean up rm -rf /tmp/mommy diff --git a/src/main/resources/mommy.1 b/src/main/resources/mommy.1 index d3fbd00..640af72 100644 --- a/src/main/resources/mommy.1 +++ b/src/main/resources/mommy.1 @@ -1,4 +1,4 @@ -.TH mommy "1" "%%MANUAL_DATE%%" "mommy %%VERSION_NUMBER%%" "user commands" +.TH mommy "1" "%%VERSION_DATE%%" "mommy %%VERSION_NUMBER%%" "user commands" .SH name diff --git a/src/main/sh/mommy b/src/main/sh/mommy index d0878db..f0db972 100755 --- a/src/main/sh/mommy +++ b/src/main/sh/mommy @@ -237,7 +237,7 @@ if [ -n "$MOMMY_OPT_HELP" ]; then exit "$?" fi elif [ -n "$MOMMY_OPT_VERSION" ]; then - echo "mommy v%%VERSION_NUMBER%%" + echo "mommy, v%%VERSION_NUMBER%%, %%VERSION_DATE%%" exit 0 else # Run command diff --git a/src/test/sh/mommy_spec.sh b/src/test/sh/mommy_spec.sh index c7f2cd7..9497d6b 100755 --- a/src/test/sh/mommy_spec.sh +++ b/src/test/sh/mommy_spec.sh @@ -59,29 +59,33 @@ Describe "mommy" Describe "-v/--help: version information" It "outputs version information using -v" When run "$MOMMY_EXEC" -v - The word 1 of output should equal "mommy" - The word 2 of output should match pattern "v%%VERSION_NUMBER%%|v[0-9a-z\.\+]*" + The word 1 of output should equal "mommy," + The word 2 of output should match pattern "v%%VERSION_NUMBER%%,|v[0-9a-z\.\+]*," + The word 3 of output should match pattern "%%VERSION_DATE%%|[0-9]*-[0-9]*-[0-9]*" The status should be success End It "outputs version information using --version" When run "$MOMMY_EXEC" --version - The word 1 of output should equal "mommy" - The word 2 of output should match pattern "v%%VERSION_NUMBER%%|v[0-9a-z\.\+]*" + The word 1 of output should equal "mommy," + The word 2 of output should match pattern "v%%VERSION_NUMBER%%,|v[0-9a-z\.\+]*," + The word 3 of output should match pattern "%%VERSION_DATE%%|[0-9]*-[0-9]*-[0-9]*" The status should be success End It "outputs version information even when --v is not the first option" When run "$MOMMY_EXEC" -s 138 --v - The word 1 of output should equal "mommy" - The word 2 of output should match pattern "v%%VERSION_NUMBER%%|v[0-9a-z\.\+]*" + The word 1 of output should equal "mommy," + The word 2 of output should match pattern "v%%VERSION_NUMBER%%,|v[0-9a-z\.\+]*," + The word 3 of output should match pattern "%%VERSION_DATE%%|[0-9]*-[0-9]*-[0-9]*" The status should be success End It "outputs version information even when --version is not the first option" When run "$MOMMY_EXEC" -s 911 --version - The word 1 of output should equal "mommy" - The word 2 of output should match pattern "v%%VERSION_NUMBER%%|v[0-9a-z\.\+]*" + The word 1 of output should equal "mommy," + The word 2 of output should match pattern "v%%VERSION_NUMBER%%,|v[0-9a-z\.\+]*," + The word 3 of output should match pattern "%%VERSION_DATE%%|[0-9]*-[0-9]*-[0-9]*" The status should be success End End diff --git a/test.sh b/test.sh index 44ba7f0..214e89c 100755 --- a/test.sh +++ b/test.sh @@ -2,5 +2,4 @@ set -e cd -P -- "$(dirname -- "$0")" -# Specify shell with `-shell sh` to work around https://github.com/shellspec/shellspec/issues/291 in OpenBSD -shellspec --shell sh --no-warning-as-failure src/test/sh/mommy_spec.sh +shellspec src/test/sh/mommy_spec.sh diff --git a/version b/version index 26aaba0..e692a26 100644 --- a/version +++ b/version @@ -1 +1,2 @@ -1.2.0 +1.2.1 +2023-02-26