Skip to content

Commit

Permalink
Update release management:
Browse files Browse the repository at this point in the history
- Add create-release action
- Update the version-bump.sh script
- Remove obsolete .github/.env file and tests
- Rename the :safe_release to :rubygem_release
  • Loading branch information
ddnexus committed Mar 29, 2024
1 parent d9aa5f5 commit 4f1748b
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 33 deletions.
2 changes: 0 additions & 2 deletions .github/.env

This file was deleted.

Empty file added .github/latest_release_body.md
Empty file.
28 changes: 28 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Create Release

on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"

jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Create Release
id: create_release
uses: comnoco/[email protected]
env:
# This token is provided by Actions, you do not need to create your own token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Version ${{ github.ref_name }}
body_path: .github/latest_release_body.md
draft: false
prerelease: false
owner: ddnexus
repo: pagy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 19 additions & 24 deletions scripts/version-bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ function bump(){
}

bump "$ROOT/retype.yml"
bump "$ROOT/.github/.env"
bump "$ROOT/lib/pagy.rb"
bump "$ROOT/lib/config/pagy.rb"
bump "$ROOT/src/pagy.ts"
Expand All @@ -42,19 +41,21 @@ cd "$ROOT/src"
pnpm run build
cd "$ROOT"

# Update CHANGELOG
changelog=$(cat <<-LOG
<hr>
## Version $new_vers
# Set TMPLOG to the changelog content
TMPLOG=$(mktemp)
echo "$(git log --format="- %s%b" "$old_vers"..HEAD)" > "$TMPLOG"
# Edit it
read -p 'Edit and save the changelog content (enter)> '
nano "$TMPLOG"
# Set the release body file used by .github/workflows/create_release.yml
# which is triggered by the :rubygem_release task (push tag)
cp -fv "$TMPLOG" "$ROOT/.github/latest_release_body.md"

$(git log --format="- %s%b" "$old_vers"..HEAD)
LOG
)
# Update CHANGELOG
changelog=$(cat <(echo -e "<hr>\n\n## Version $new_vers\n") "$TMPLOG")
CHANGELOG="$ROOT/CHANGELOG.md"
TMPFILE=$(mktemp)
awk -v l="$changelog" '{sub(/<hr>/, l); print}' "$CHANGELOG" > "$TMPFILE"
mv "$TMPFILE" "$CHANGELOG"
awk -v l="$changelog" '{sub(/<hr>/, l); print}' "$CHANGELOG" > "$TMPLOG"
mv "$TMPLOG" "$CHANGELOG"

# Run test to check the consistency across files
bundle exec ruby -Itest test/pagy_test.rb --name "/pagy::Version match(#|::)/"
Expand All @@ -65,15 +66,9 @@ if [[ $input = y ]] || [[ $input = Y ]]; then
bundle exec "$ROOT/scripts/update_top100.rb"
fi

## Optional show diff
#read -rp 'Do you want to see the diff? (y/n)> ' input
#if [[ $input = y ]] || [[ $input = Y ]]; then
# git diff -U0 --word-diff=color
#fi
#
## Optional commit
#read -rp 'Do you want to commit the changes? (y/n)> ' input
#if [[ $input = y ]] || [[ $input = Y ]]; then
# git add -A
# git commit -m "Version $new_vers"
#fi
# Optional commit
read -rp 'Do you want to commit the changes? (y/n)> ' input
if [[ $input = y ]] || [[ $input = Y ]]; then
git add -A
git commit -m "Version $new_vers"
fi
2 changes: 1 addition & 1 deletion tasks/safe_release.rake → tasks/rubygem_release.rake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module Bundler # :nodoc: all
end

desc 'Checks-build-release-tag-cleanup cycle'
task :safe_release do
task :rubygem_release do
output = `git status --porcelain`
abort 'Working tree dirty!' unless output.empty?

Expand Down
3 changes: 0 additions & 3 deletions test/pagy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ def series_for(page, *expected)
it 'defines the same version in CHANGELOG.md' do
_(Pagy.root.parent.join('CHANGELOG.md').read).must_match "## Version #{Pagy::VERSION}"
end
it 'defines the same version in .github/.env' do
_(File.read('.github/.env')).must_match "VERSION=#{Pagy::VERSION}"
end
it 'defines the same minor version in ./quick-start.md' do
_(File.read('./quick-start.md')).must_match "gem 'pagy', '~> #{Pagy::VERSION.sub(/\.\d+$/, '')}"
end
Expand Down

0 comments on commit 4f1748b

Please sign in to comment.