Skip to content

Commit

Permalink
merge pull request #37 from FWDekker/dev~ ❤️
Browse files Browse the repository at this point in the history
v1.2.1~ 💛
  • Loading branch information
FWDekker authored Feb 26, 2023
2 parents 2cd8631 + 9bd9f7c commit d9b6014
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 32 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
20 changes: 13 additions & 7 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
17 changes: 11 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,15 +21,16 @@ 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
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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions .shellspec
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
--execdir @specfile
--no-warning-as-failure

# OpenBSD: Workaround for https://github.com/shellspec/shellspec/issues/291
--shell sh
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`~
Expand Down
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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~
Expand All @@ -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)~_

<details>
<summary>arch linux</summary>

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

</details>

<details>
<summary>homebrew/linuxbrew</summary>

install with homebrew/linuxbrew from the [mommy tap](https://github.com/FWDekker/homebrew-mommy):

```shell
brew tap fwdekker/mommy
brew install mommy
```
</details>

### 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`,
Expand All @@ -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~
Expand Down Expand Up @@ -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`.
Expand Down
28 changes: 23 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ 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/

# 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
Expand All @@ -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"
Expand All @@ -38,6 +42,9 @@ for target in "$@"; do

# Pre-process
case "$target" in
install)
# Do nothing
;;
netbsd|openbsd)
# Extract properties
comment="$(<"./.fpm" grep -- "--description")"
Expand All @@ -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
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -123,6 +138,9 @@ for target in "$@"; do

# Post-process
case "$target" in
install)
# Do nothing
;;
netbsd|openbsd)
# Clean up
rm -rf /tmp/mommy
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/mommy.1
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/main/sh/mommy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 12 additions & 8 deletions src/test/sh/mommy_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
1.2.0
1.2.1
2023-02-26

0 comments on commit d9b6014

Please sign in to comment.