Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reusable infrastructure for creating AUTHORS files #141

Merged
merged 12 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
key:
${{ runner.os }}-cococo-node-${{
hashFiles('conventional_commit_config/package-lock.json') }}
- run: cd authors && make test
- run: cd conventional_commit_config && make test
- run: cd changelog && make test
- run: cd licenses && make test
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
format: # formats all code bases
(cd authors && make --no-print-dir format)
(cd changelog && make --no-print-dir format)
(cd conventional_commit_config && make --no-print-dir format)
(cd licenses && make --no-print-dir format)
Expand Down
24 changes: 24 additions & 0 deletions authors/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
format: .bin/shfmt
echo formatting source code ...
.bin/shfmt --write .

test: .bin/shellcheck .bin/shfmt # runs all automated tests
echo running tests ...
.bin/shellcheck authors.sh
.bin/shfmt --diff .

.bin/shellcheck: Makefile
echo installing Shellcheck ...
curl -sSL https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz | tar xJ
mkdir -p .bin
mv shellcheck-stable/shellcheck .bin
rm -rf shellcheck-stable
touch .bin/shellcheck # update the timestamp so that Make doesn't re-install Shellcheck each time it runs

.bin/shfmt: Makefile
echo installing Shellfmt ...
mkdir -p .bin
curl -sSL https://github.com/mvdan/sh/releases/download/v3.5.1/shfmt_v3.5.1_linux_amd64 -o .bin/shfmt
chmod +x .bin/shfmt

.SILENT:
44 changes: 44 additions & 0 deletions authors/authors.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash

# This script creates an AUTHORS file similar to https://github.com/google/go-github/blob/master/AUTHORS
# listing the authors of the product in the current directory. Call it like this:
#
# curl https://raw.githubusercontent.com/ory/ci/master/authors/authors.sh | env PRODUCT=<product name> bash

##############################
# CONFIGURATION

# name of the file to create
filename=AUTHORS

# entries to ignore
ignores=(ory-bot dependabot circleci@ory.am kevin.goslar@originate.com)

##############################
# IMPLEMENTATION

# verify arguments
if [ -z "$PRODUCT" ]; then
echo "Usage: env PRODUCT=<product name>" "$0"
exit 1
fi

# determine all authors from the Git history
authors=$(git log --pretty=format:"%an <%ae>" | sort | uniq)

# filter entries to ignore
for ignore in "${ignores[@]}"; do
authors=$(echo "$authors" | grep -v "$ignore")
done

# write file
{
echo "# This is the official list of $PRODUCT authors."
echo "# If you don't want to be on this list, please contact Ory."
echo ""
echo "$authors"
} >$filename

# print success message
count=$(echo "$authors" | wc -l)
echo "Identified $count contributors."