-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Publish from GitHub Action and add release script
- Loading branch information
Showing
3 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
release: | ||
types: | ||
- published | ||
|
||
jobs: | ||
push: | ||
if: github.event_name == 'release' && github.event.action == 'published' | ||
runs-on: ubuntu-latest | ||
environment: release | ||
permissions: | ||
id-token: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
ruby-version: ruby | ||
|
||
- uses: rubygems/release-gem@v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'bundler/gem_tasks' | ||
require 'rake/testtask' | ||
require 'rubocop/rake_task' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
|
||
set -eu -o pipefail | ||
|
||
changelog=$(cat CHANGELOG.md) | ||
|
||
regex=' | ||
## v([0-9]+\.[0-9]+\.[0-9]+) \(([0-9]{4}-[0-9]{2}-[0-9]{2})\) | ||
((.| | ||
)*) | ||
' | ||
|
||
if [[ ! $changelog =~ $regex ]]; then | ||
echo "Could not find date line in change log!" | ||
exit 1 | ||
fi | ||
|
||
version="${BASH_REMATCH[1]}" | ||
date="${BASH_REMATCH[2]}" | ||
notes="$(echo "${BASH_REMATCH[3]}" | sed -n -E '/^## v[0-9]+\.[0-9]+\.[0-9]+/,$!p')" | ||
|
||
echo "$notes" | ||
if [[ "$date" != "$(date +"%Y-%m-%d")" ]]; then | ||
echo "$date is not today!" | ||
exit 1 | ||
fi | ||
|
||
tag="v$version" | ||
|
||
if [ -n "$(git status --porcelain)" ]; then | ||
echo ". is not clean." >&2 | ||
exit 1 | ||
fi | ||
|
||
perl -pi -e "s/(?<=s.version\s{,20}=\s{,20}\').+?(?=\')/$version/g" maxmind-db.gemspec | ||
|
||
echo $"Test results:" | ||
|
||
rake | ||
|
||
echo $'\nDiff:' | ||
git diff | ||
|
||
echo $'\nRelease notes:' | ||
echo "$notes" | ||
|
||
read -e -p "Commit changes and push to origin? " should_push | ||
|
||
if [ "$should_push" != "y" ]; then | ||
echo "Aborting" | ||
exit 1 | ||
fi | ||
|
||
git commit -m "Update for $tag" -a | ||
|
||
git push | ||
|
||
gh release create --target "$(git branch --show-current)" -t "$version" -n "$notes" "$tag" |