Skip to content

Commit

Permalink
Change a few scrip vars
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Apr 25, 2024
1 parent eb90428 commit 2f4d8e3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion scripts/update_top100.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'net/http'

URL_FMT = 'https://api.github.com/repos/ddnexus/pagy/contributors?page=%s'
IMG_WIDTH = '60'
IMG_WIDTH = '40'
MAX_COUNT = 100
START_TAG = '<!-- top100 start -->'
END_TAG = '<!-- top100 end -->'
Expand Down
56 changes: 28 additions & 28 deletions scripts/version-bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ set -e

# Set the root path
dir="$(dirname -- "$0")"
ROOT="$(cd -P -- "$(dirname -- "$dir")" && printf '%s\n' "$(pwd -P)")"
cd $ROOT
root="$(cd -P -- "$(dirname -- "$dir")" && printf '%s\n' "$(pwd -P)")"
cd $root

# Prompt for the new version
old_vers=$(ruby -Igem/lib -rpagy -e 'puts Pagy::VERSION')
Expand All @@ -31,40 +31,40 @@ function bump(){
sed -i "0,/$esc_old_vers/{s/$esc_old_vers/$esc_new_vers/}" "$1"
}

bump "$ROOT/retype.yml"
bump "$ROOT/.github/ISSUE_TEMPLATE/Code.yml"
bump "$ROOT/.github/latest_release_body.md"
bump "$ROOT/gem/apps/calendar.ru"
bump "$ROOT/gem/apps/demo.ru"
bump "$ROOT/gem/apps/rails.ru"
bump "$ROOT/gem/apps/repro.ru"
bump "$ROOT/gem/bin/pagy"
bump "$ROOT/gem/config/pagy.rb"
bump "$ROOT/gem/lib/pagy.rb"
bump "$ROOT/gem/pagy.gemspec"
bump "$ROOT/src/pagy.ts"
bump "$root/retype.yml"
bump "$root/.github/ISSUE_TEMPLATE/Code.yml"
bump "$root/.github/latest_release_body.md"
bump "$root/gem/apps/calendar.ru"
bump "$root/gem/apps/demo.ru"
bump "$root/gem/apps/rails.ru"
bump "$root/gem/apps/repro.ru"
bump "$root/gem/bin/pagy"
bump "$root/gem/config/pagy.rb"
bump "$root/gem/lib/pagy.rb"
bump "$root/gem/pagy.gemspec"
bump "$root/src/pagy.ts"

# Bumps docs example
esc_old_minor_vers=${esc_old_vers%\\*}
esc_new_minor_vers=${esc_new_vers%\\*}
sed -i "0,/$esc_old_minor_vers/{s/$esc_old_minor_vers/$esc_new_minor_vers/}" "$ROOT/quick-start.md"
sed -i "0,/$esc_old_minor_vers/{s/$esc_old_minor_vers/$esc_new_minor_vers/}" "$root/quick-start.md"

cd "$ROOT/src"
cd "$root/src"
pnpm run build
cd "$ROOT"
cd "$root"

# Set TMPLOG to the commit messages that have changes in the "gem" root path
TMPLOG=$(mktemp)
# Set tmplog to the commit messages that have changes in the "gem" root path
tmplog=$(mktemp)
# Iterate through the new commits
for commit in $(git rev-list "$old_vers"..HEAD)
do
if [[ -n $(git show --pretty="format:" --name-only --relative=gem $commit) ]]
then
git show --no-patch --format="- %s" $commit >> "$TMPLOG"
git show --no-patch --format="- %s" $commit >> "$tmplog"
body=$(git show --no-patch --format="%b" $commit)
if [[ -n "$body" ]]
then
sed 's/^/\ \ /' <<<"$body" >> "$TMPLOG"
sed 's/^/\ \ /' <<<"$body" >> "$tmplog"
fi
fi
done
Expand All @@ -73,22 +73,22 @@ done
# which is triggered by the :rubygem_release task (push tag)
lead='^<!-- changes start -->$'
tail='^<!-- changes end -->$'
sed -i "/$lead/,/$tail/{ /$lead/{p; r $TMPLOG
}; /$tail/p; d }" "$ROOT/.github/latest_release_body.md"
sed -i "/$lead/,/$tail/{ /$lead/{p; r $tmplog
}; /$tail/p; d }" "$root/.github/latest_release_body.md"

# Update CHANGELOG
changelog=$(cat <(echo -e "<hr>\n\n## Version $new_vers\n") "$TMPLOG")
CHANGELOG="$ROOT/CHANGELOG.md"
awk -v l="$changelog" '{sub(/<hr>/, l); print}' "$CHANGELOG" > "$TMPLOG"
mv "$TMPLOG" "$CHANGELOG"
changelog=$(cat <(echo -e "<hr>\n\n## Version $new_vers\n") "$tmplog")
changelog_path="$root/CHANGELOG.md"
awk -v l="$changelog" '{sub(/<hr>/, l); print}' "$changelog_path" > "$tmplog"
mv "$tmplog" "$changelog_path"

# Run test to check the consistency across files
bundle exec ruby -Itest test/pagy_test.rb --name "/pagy::Version match(#|::)/"

# Optional update of top 100
read -rp 'Do you want to update the "Top 100 contributors"? (y/n)> ' input
if [[ $input = y ]] || [[ $input = Y ]]; then
bundle exec "$ROOT/scripts/update_top100.rb"
bundle exec "$root/scripts/update_top100.rb"
fi

# Optional commit
Expand Down

0 comments on commit 2f4d8e3

Please sign in to comment.