Skip to content

Commit

Permalink
❤️ merge pull request #89 from FWDekker/dev~
Browse files Browse the repository at this point in the history
❤️ v1.3.0~
  • Loading branch information
FWDekker authored Jan 10, 2024
2 parents 0c72a50 + 6287d2e commit d3172ae
Show file tree
Hide file tree
Showing 14 changed files with 163 additions and 57 deletions.
5 changes: 3 additions & 2 deletions .fpm
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
--description "mommy's here to support you~"
--url "https://github.com/FWDekker/mommy"
--maintainer "Florine W. Dekker"
--deb-changelog ./CHANGELOG.md
--rpm-changelog ./CHANGELOG.md
--deb-changelog ./pkg/fpm/deb.changelog
--deb-upstream-changelog ./CHANGELOG.md
--rpm-changelog ./pkg/fpm/rpm.changelog
17 changes: 11 additions & 6 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:

permissions:
contents: write
discussions: write
packages: read

jobs:
Expand Down Expand Up @@ -197,11 +198,13 @@ jobs:
uses: softprops/action-gh-release@v1
if: github.event_name != 'workflow_dispatch'
with:
draft: false
prerelease: false
target_commitish: main
tag_name: ${{ env.MOMMY_VERSION }}
body_path: RELEASE_NOTES.md
files: mommy*
draft: false
prerelease: false
discussion_category_name: announcements

release-apt:
needs: [ release-mommy ]
Expand Down Expand Up @@ -244,10 +247,10 @@ jobs:
echo "::endgroup::"
echo "::group::Commit changes"
git add --all
git config --global user.name "FWDekkerBot"
git config --global user.email "bot@fwdekker.com"
git commit -am "🔖 mommy added package mommy $MOMMY_VERSION~"
git add --all
git commit -m "🔖 mommy added package mommy $MOMMY_VERSION~"
echo "::endgroup::"
if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then
Expand Down Expand Up @@ -314,7 +317,8 @@ jobs:
echo "::group::Commit update"
sudo -u build git config --global user.name "FWDekkerBot"
sudo -u build git config --global user.email "bot@fwdekker.com"
sudo -u build git commit -am "🔖 mommy updated the build files to mommy $MOMMY_VERSION~"
sudo -u build git add --all
sudo -u build git commit -m "🔖 mommy updated the build files to mommy $MOMMY_VERSION~"
echo "::endgroup::"
echo "::group::Fast-forward dev"
Expand Down Expand Up @@ -368,7 +372,8 @@ jobs:
echo "::group::Commit update"
git config --global user.name "FWDekkerBot"
git config --global user.email "bot@fwdekker.com"
git commit -am "🔖 mommy updated the formula to mommy $MOMMY_VERSION~"
git add --all
git commit -m "🔖 mommy updated the formula to mommy $MOMMY_VERSION~"
echo "::endgroup::"
echo "::group::Fast-forward dev"
Expand Down
32 changes: 30 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
name: CI

on: [ push, pull_request ]
on:
push:
paths-ignore:
- 'README.md'
- 'SECURITY.md'
- '.github/img/**'
pull_request:
paths-ignore:
- 'README.md'
- 'SECURITY.md'
- '.github/img/**'

jobs:
test-linux:
Expand Down Expand Up @@ -56,6 +66,14 @@ jobs:
repository: FWDekker/homebrew-mommy
path: homebrew-mommy
ref: dev
- name: Patch homebrew-mommy
working-directory: homebrew-mommy
env:
RELEVANT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
# Point the formula to the commit that is being tested in this workflow
sed -i -e "s|head \(.*\), branch: .*|head \1, revision: \"$RELEVANT_SHA\"|g" mommy.rb
git -c user.name="ignore" -c user.email="ignore" commit -am "ignore"
- name: Test Homebrew package
run: |
echo "::group::Enable Homebrew"
Expand Down Expand Up @@ -161,9 +179,11 @@ jobs:
run: chown -R build:build ./aur-mommy/
- name: Test AUR package
working-directory: ./aur-mommy/
env:
RELEVANT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
echo "::group::Patch"
sudo -u build ./update.sh dev
sudo -u build ./update.sh "$RELEVANT_SHA"
echo "::endgroup::"
echo "::group::Build and install"
Expand Down Expand Up @@ -312,6 +332,14 @@ jobs:
repository: FWDekker/homebrew-mommy
path: homebrew-mommy
ref: dev
- name: Patch homebrew-mommy
working-directory: homebrew-mommy
env:
RELEVANT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
# Point the formula to the commit that is being tested in this workflow
sed -i -e "s|head \(.*\), branch: .*|head \1, revision: \"$RELEVANT_SHA\"|g" mommy.rb
git -c user.name="ignore" -c user.email="ignore" commit -am "ignore"
- name: Test Homebrew package
run: |
echo "::group::Enable Homebrew"
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# Changelog
## [1.3.0] -- 2024-01-10
### added
* 🪹 mommy now supports newlines in templates using `%%N%%`~ ([#58](https://github.com/FWDekker/mommy/issues/58)) ([#82](https://github.com/FWDekker/mommy/issues/82))
* 🛡️ mommy now has a [security policy](https://github.com/FWDekker/intellij-randomness/security)~

### fixed
* 🚒 mommy fixes the description url in her manual page~ ([#81](https://github.com/FWDekker/mommy/issues/81)) ([#82](https://github.com/FWDekker/mommy/issues/82))
* 🕰️ mommy uses the correct types of changelogs in the right places ([#83](https://github.com/FWDekker/mommy/issues/83))
* 🏃 mommy no longer crashes when using `\` or `&` in variables~ ([#84](https://github.com/FWDekker/mommy/issues/84)) ([#87](https://github.com/FWDekker/mommy/issues/87))


## [1.2.6] -- 2023-11-29
### fixed
* 🚒 mommy fixes her apt repository release script~ ([#73](https://github.com/FWDekker/mommy/issues/73))
Expand Down
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ build:
@rm -f "$(build_dir)/bin/mommy.bak" "$(build_dir)/man/man1/mommy.1.bak"

@# Compress
@gzip -f "$(build_dir)/man/man1/mommy.1"
@gzip -9nf "$(build_dir)/man/man1/mommy.1"


## Installation
Expand Down
71 changes: 42 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

---

🚚 [**installation**](#-installation) | 📖 [**usage**](#-usage) | 🙋 [**configuration**](#-configuration) | 🐚 [**shell integration**](#-shell-integration) | ⚗️ [**development**](#%EF%B8%8F-development) | 💖 [**acknowledgements**](#-acknowledgements)
🚚 [**installation**](#-installation) | 📖 [**usage**](#-usage) | 🙋 [**configuration**](#-configuration) | 🐚 [**shell integration**](#-shell-integration) | ⚗️ [**development**](#%EF%B8%8F-development) | 💖 [**acknowledgements**](#-acknowledgements)

---

Expand Down Expand Up @@ -89,33 +89,43 @@ find your operating system and package manager for the right instructions~
<details>
<summary>debian/ubuntu/apt-based</summary>

* **apt** (automatic updates)

* **apt ≥2.2.4** (automatic updates)
this method requires apt v2.2.4 or newer.
check your version of apt with `apt -v`~

installs from the [mommy apt repository](https://github.com/FWDekker/apt-mommy).
the repository supports all architectures and suites~
1. register the repository in apt:
([more info](https://stackoverflow.com/a/71384057/))
```shell
sudo mkdir -p /etc/apt/keyrings/

wget -O- https://raw.githubusercontent.com/FWDekker/apt-mommy/main/deb/Release.key | \
gpg --dearmor | \
sudo tee /etc/apt/keyrings/mommy.gpg > /dev/null

echo "deb [signed-by=/etc/apt/keyrings/mommy.gpg] https://raw.githubusercontent.com/FWDekker/apt-mommy/main/deb/ ./" | \
sudo tee /etc/apt/sources.list.d/mommy.list > /dev/null
```
2. (optional)
set mommy's repository priority lower than the distro's official repositories:
([more info](https://wiki.debian.org/DebianRepository/UseThirdParty#Standard_pinning))
```shell
echo -e "Package: *\nPin: origin o=mommy\nPin-Priority: 100" | \
sudo tee /etc/apt/preferences.d/pin-fwdekker-mommy > /dev/null
```
3. install mommy:
```shell
sudo apt update
sudo apt install mommy
```

```shell
sudo curl -fsSo /etc/apt/sources.list.d/mommy.sources https://raw.githubusercontent.com/FWDekker/apt-mommy/main/deb/mommy.sources
sudo chmod 644 /etc/apt/sources.list.d/mommy.sources

sudo apt update
sudo apt install mommy
```
* **apt <2.2.4** (automatic updates)
this method works on all versions of apt~

installs from the [mommy apt repository](https://github.com/FWDekker/apt-mommy).
the repository supports all architectures and suites~

[check this page for details on what this code does](https://stackoverflow.com/a/71384057/)~
```shell
sudo mkdir -m 0755 -p /etc/apt/keyrings/

wget -O- https://raw.githubusercontent.com/FWDekker/apt-mommy/main/deb/Release.key | \
gpg --dearmor | \
sudo tee /etc/apt/keyrings/mommy.gpg > /dev/null;
sudo chmod 644 /etc/apt/keyrings/EXAMPLE.gpg

echo "deb [signed-by=/etc/apt/keyrings/mommy.gpg] https://raw.githubusercontent.com/FWDekker/apt-mommy/main/deb/ ./" | \
sudo tee /etc/apt/sources.list.d/mommy.list > /dev/null;
sudo chmod 644 /etc/apt/sources.list.d/EXAMPLE.list

sudo apt update
sudo apt install mommy
```
* **homebrew** (automatic updates)
installs from the [mommy tap](https://github.com/FWDekker/homebrew-mommy).
(requires [brew](https://brew.sh/).)
Expand Down Expand Up @@ -481,10 +491,10 @@ elements that contain whitespace only, and elements that start with a `#` are ig
then mommy will never use templates that contain `cat`, and will never use templates that contain `dog`~

### 🧬 custom templates
you can add a [list](#-lists) of your own compliments to either `MOMMY_COMPLIMENTS` or `MOMMY_COMPLIMENTS_EXTRA`, but
there is a slight difference:
you can add a [list](#-lists) of your own compliments to either `MOMMY_COMPLIMENTS` or `MOMMY_COMPLIMENTS_EXTRA`.
there is a slight difference between the two lists:

* if you want both the default _and_ your own compliments, add your own compliments to `MOMMY_COMPLIMENTS_EXTRA`, but
* if you want both the default _and_ your own compliments, add your own compliments to `MOMMY_COMPLIMENTS_EXTRA`~
* if you want your own compliments and _not_ the default compliments, add your own compliments to `MOMMY_COMPLIMENTS`~

and similarly so for encouragements~
Expand All @@ -501,6 +511,7 @@ outputs `your mommy loves you`~
| `%%THEM%%` | mommy's object pronoun (e.g. him, her, them) |
| `%%THEIR%%` | mommy's possessive pronoun (e.g. his, her, their) |
| `%%SWEETIE%%` | what mommy calls you |
| `%%N%%` | a newline |
### ✍️ renaming the mommy executable
if you want to write `daddy npm test` instead of `mommy npm test`, you can create a symlink~
Expand Down Expand Up @@ -745,6 +756,8 @@ every merge into `main` automatically build and releases a new version~
* ensure no line breaks are used as whitespace;
github release notes use them as actual line breaks~
* update `pkg/rpkg/mommy.spec.rpkg` if changes were made to copr's rpkg packaging process~
* update `pkg/fpm/deb.changelog` if changes were made to fpm's debian packaging process~
* update `pkg/fpm/rpm.changelog` if changes were made to fpm's rpm packaging process~
* update acknowledgements in `README.md`~
* update promotional images in `.github/img/`~
Expand Down
11 changes: 11 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 🛡️ security policy
even if this looks like a funny project, mommy takes security seriously.
mommy doesn't want any of her little children to get hurt!

if you discover or suspect a security vulnerability, please **do not open a public issue** because others could exploit
it before it's fixed.
instead, go to
[mommy's special "report a vulnerability" page on github](https://github.com/go-gitea/gitea/security/advisories/new) and
submit the issue there.
mommy's maids will respond to you as quickly as possible.
you will be thanked publicly for your report, unless you don't want that~
6 changes: 6 additions & 0 deletions pkg/fpm/deb.changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mommy (1.3.0-1) stable; urgency=low

* finally added a changelog~
* no package changes compared to previous versions though~

-- Florine W. Dekker Wed, 10 Jan 2024 21:32:32 +0100
5 changes: 5 additions & 0 deletions pkg/fpm/rpm.changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This changelog is only for packages built using fpm.

* Wed Jan 10 2024 Florine W. Dekker - 1.3.0-1
- finally added a changelog for rpm builds on github~
- no package changes compared to previous versions though~
7 changes: 4 additions & 3 deletions pkg/rpkg/mommy.spec.rpkg
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ rm -rf "%{_tmppath}/shellspec/"
%{_datarootdir}/zsh/site-functions/_mommy

%changelog
# Changelog lists changes to the packaging, not to the software.
* Tue Mar 14 2023 Florine W. Dekker 1.2.3-1
- Initial release with rpkg
# This changelog is only for packages built using rpkg on copr.

* Tue Mar 14 2023 Florine W. Dekker - 1.2.3-1
- initial release with rpkg~
2 changes: 1 addition & 1 deletion src/main/man/man1/mommy.1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ e.g. \fBmommy\fP -s $?


.SH description
https://github.com/FWDekker/mommy/blob/%%VERSION_NUMBER%%/README.md
https://github.com/FWDekker/mommy/tree/v%%VERSION_NUMBER%%#readme


.SH bugs
Expand Down
30 changes: 19 additions & 11 deletions src/main/sh/mommy
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ list_contains_any() {
# Takes the list in stdin and (1) removes all lines starting with `#`, (2) replaces each `/` with a newline, (3) removes
# all blank lines, and (4) removes all entries that contain any of the entries in the sanitized list `$1` as a
# substring.
list_sanitize() {
list_normalize() {
cat |
grep -v "^#" |
tr "/" "$n" |
Expand All @@ -113,6 +113,13 @@ else
}
fi

# Escapes stdin to be used as a replacement string in sed.
#
# Only the characters `\` and `&` need replacement, since we assume that `/` does not occur.
escape_sed_replacement() {
cat | sed -e 's/\\/\\\\/g' -e 's/&/\\\&/g'
}


## Functions
# Prints `$2`, but with color depending on `$1`. If `$1` equals `lolcat`, stdin is piped to `lolcat`. If `$1` is empty,
Expand Down Expand Up @@ -170,18 +177,19 @@ split_pronouns() {
# 4. prepends `$4` and appends `$5`; and
# 5. writes to stdout.
fill_template() {
sweetie="$(echo "$1" | list_sanitize | list_choose)"
split_pronouns "$(echo "$2" | list_sanitize | list_choose)"
caregiver="$(echo "$3" | list_sanitize | list_choose)"
sweetie="$(echo "$1" | list_normalize | list_choose | escape_sed_replacement)"
split_pronouns "$(echo "$2" | list_normalize | list_choose | escape_sed_replacement)"
caregiver="$(echo "$3" | list_normalize | list_choose | escape_sed_replacement)"

prefix="$(echo "$4" | list_sanitize | list_choose)"
suffix="$(echo "$5" | list_sanitize | list_choose)"
prefix="$(echo "$4" | list_normalize | list_choose | escape_sed_replacement)"
suffix="$(echo "$5" | list_normalize | list_choose | escape_sed_replacement)"

template="$(cat | sed -e "s/%%SWEETIE%%/$sweetie/g" \
-e "s/%%THEY%%/$they/g" \
-e "s/%%THEM%%/$them/g" \
-e "s/%%THEIR%%/$their/g" \
-e "s/%%CAREGIVER%%/$caregiver/g")"
-e "s/%%CAREGIVER%%/$caregiver/g" \
-e "s/%%N%%/\\$n/g")"

capitalize "$prefix$template$suffix" "$6"
return 0
Expand Down Expand Up @@ -253,7 +261,7 @@ else
fi

# Choose and fill template (if enabled)
if list_contains_any "$command_exit_code" "$(echo "$MOMMY_IGNORED_STATUSES" | list_sanitize)"; then
if list_contains_any "$command_exit_code" "$(echo "$MOMMY_IGNORED_STATUSES" | list_normalize)"; then
exit "$command_exit_code"
elif [ "$command_exit_code" -eq 0 ] && [ "$MOMMY_COMPLIMENTS_ENABLED" = "1" ]; then
templates="$MOMMY_COMPLIMENTS/$MOMMY_COMPLIMENTS_EXTRA"
Expand All @@ -263,11 +271,11 @@ else
exit "$command_exit_code"
fi

color="$(echo "$MOMMY_COLOR" | list_sanitize | list_choose)"
forbidden_words="$(echo "$MOMMY_FORBIDDEN_WORDS" | list_sanitize)"
color="$(echo "$MOMMY_COLOR" | list_normalize | list_choose)"
forbidden_words="$(echo "$MOMMY_FORBIDDEN_WORDS" | list_normalize)"

response="$(echo "$templates" |
list_sanitize "$forbidden_words" |
list_normalize "$forbidden_words" |
list_choose |
fill_template "$MOMMY_SWEETIE" "$MOMMY_PRONOUNS" "$MOMMY_CAREGIVER" "$MOMMY_PREFIX" \
"$MOMMY_SUFFIX" "$MOMMY_CAPITALIZE")"
Expand Down
Loading

0 comments on commit d3172ae

Please sign in to comment.