-
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.
Merge pull request #72 from maxmind/greg/trusted-publishing
Use trusted publishing
- Loading branch information
Showing
5 changed files
with
91 additions
and
44 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,45 +1,4 @@ | ||
# How to release | ||
* Ensure tests pass: `rake` | ||
* Update changelog: Set version and release date | ||
* Set version in `maxmind-db.gemspec` | ||
* Add them: `git add -p` | ||
* Create a branch e.g. `horgh/release` and switch to it. | ||
* `main` is protected. | ||
* Commit: `git commit -m v1.0.0` | ||
* Tag: `git tag -a v1.0.0 -m v1.0.0` | ||
* Clean up to be sure nothing stray gets into gem: `git clean -dxff` | ||
* Create `.gem` file: `gem build maxmind-db.gemspec` | ||
* Complete prerequisites (see below) | ||
* You only need to do this once. You can tell if this is necessary if you | ||
are lacking `:rubygems_api_key` in `~/.local/share/gem/credentials` | ||
(previously `~/.gem/credentials`) | ||
* Upload to rubygems.org: `gem push maxmind-db-1.0.0.gem` | ||
* Push: `git push` | ||
* Push tag: `git push --tags` | ||
* Make a PR and get it merged. | ||
* Double check it looks okay at https://rubygems.org/gems/maxmind-db and | ||
https://www.rubydoc.info/gems/maxmind-db | ||
|
||
|
||
# Prerequisites | ||
|
||
## Step 1 | ||
Sign up for an account at rubygems.org if you don't have one. | ||
|
||
Enable multi factor authentication (for both UI and API). | ||
|
||
|
||
## Step 2 | ||
Ask someone who is an owner of the gem to add you as one. | ||
|
||
They do this by using the `gem owner` command | ||
([docs](https://guides.rubygems.org/command-reference/#gem-owner)). | ||
|
||
|
||
## Step 3 | ||
Run `gem signin`. This will prompt you for your username and password, and | ||
then create an API key for you. Select the scopes `index_rubygems` and | ||
`push_rubygem` (I'm not sure the former is required, but anyway). | ||
|
||
Note you may need an up to date version of rubygems to do this as I believe | ||
support for API keys like this is a newer addition. | ||
See | ||
[here](https://github.com/maxmind/minfraud-api-ruby/blob/main/README.dev.md). |
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=' | ||
## ([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 '/^## [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" |
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