Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Release

on:
push:
tags: ["v*"]

jobs:
release:
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
bundler-cache: true

- name: Verify tag matches Drip::VERSION
run: |
version="$(bundle exec ruby -Ilib -e 'require "drip/version"; print Drip::VERSION')"
if [ "${GITHUB_REF_NAME}" != "v${version}" ]; then
echo "tag ${GITHUB_REF_NAME} does not match Drip::VERSION v${version}" >&2
exit 1
fi

- name: Extract release notes from CHANGELOG.md
run: |
version="${GITHUB_REF_NAME#v}"
awk -v v="$version" '
/^## \[/ { in_section = index($0, "## [" v "]") == 1; next }
in_section { print }
' CHANGELOG.md > release-notes.md
if ! grep -q '[^[:space:]]' release-notes.md; then
echo "no CHANGELOG.md section found for ${version}" >&2
exit 1
fi

- uses: rubygems/release-gem@v1

- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${GITHUB_REF_NAME}" pkg/*.gem \
--title "${GITHUB_REF_NAME}" \
--notes-file release-notes.md \
--verify-tag
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,14 @@ subscriber.email
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request

## Releasing

1. Set `Drip::VERSION` in `lib/drip/version.rb`.
2. Move the `[Unreleased]` entries in `CHANGELOG.md` under a new `## [x.y.z] - YYYY-MM-DD` heading.
3. Merge to `main`.
4. From an up-to-date `main`, tag and push: `git tag -a vX.Y.Z -m vX.Y.Z && git push origin vX.Y.Z`.

Pushing the tag triggers `.github/workflows/release.yml`, which checks that the
tag matches `Drip::VERSION`, publishes the gem to RubyGems, and creates the
GitHub release with the matching `CHANGELOG.md` section as its notes.
Loading