Skip to content

Commit 59e1528

Browse files
committed
Publish from GitHub Action and add release script
1 parent 6bb0726 commit 59e1528

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed

.github/workflows/release.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
release:
10+
types:
11+
- published
12+
13+
jobs:
14+
push:
15+
if: github.event_name == 'release' && github.event.action == 'published'
16+
runs-on: ubuntu-latest
17+
environment: release
18+
permissions:
19+
id-token: write
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Set up Ruby
23+
uses: ruby/setup-ruby@v1
24+
with:
25+
bundler-cache: true
26+
ruby-version: ruby
27+
28+
- uses: rubygems/release-gem@v1

Rakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# frozen_string_literal: true
22

3+
require 'bundler/gem_tasks'
34
require 'rake/testtask'
45
require 'rubocop/rake_task'
56

dev-bin/release.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
set -eu -o pipefail
4+
5+
changelog=$(cat CHANGELOG.md)
6+
7+
regex='
8+
## ([0-9]+\.[0-9]+\.[0-9]+) \(([0-9]{4}-[0-9]{2}-[0-9]{2})\)
9+
10+
((.|
11+
)*)
12+
'
13+
14+
if [[ ! $changelog =~ $regex ]]; then
15+
echo "Could not find date line in change log!"
16+
exit 1
17+
fi
18+
19+
version="${BASH_REMATCH[1]}"
20+
date="${BASH_REMATCH[2]}"
21+
notes="$(echo "${BASH_REMATCH[3]}" | sed -n -E '/^## [0-9]+\.[0-9]+\.[0-9]+/,$!p')"
22+
23+
echo "$notes"
24+
if [[ "$date" != "$(date +"%Y-%m-%d")" ]]; then
25+
echo "$date is not today!"
26+
exit 1
27+
fi
28+
29+
tag="v$version"
30+
31+
if [ -n "$(git status --porcelain)" ]; then
32+
echo ". is not clean." >&2
33+
exit 1
34+
fi
35+
36+
perl -pi -e "s/(?<=s.version\s{,20}=\s{,20}\').+?(?=\')/$version/g" maxmind-db.gemspec
37+
38+
echo $"Test results:"
39+
40+
rake
41+
42+
echo $'\nDiff:'
43+
git diff
44+
45+
echo $'\nRelease notes:'
46+
echo "$notes"
47+
48+
read -e -p "Commit changes and push to origin? " should_push
49+
50+
if [ "$should_push" != "y" ]; then
51+
echo "Aborting"
52+
exit 1
53+
fi
54+
55+
git commit -m "Update for $tag" -a
56+
57+
git push
58+
59+
gh release create --target "$(git branch --show-current)" -t "$version" -n "$notes" "$tag"

0 commit comments

Comments
 (0)