Skip to content
Open
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
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release

on:
push:
branches: [main]
paths:
- lib/factory_bot/version.rb

jobs:
release:
name: Release gem
runs-on: ubuntu-latest
permissions:
contents: write # create git tag + GitHub release
id-token: write # OIDC token for RubyGems trusted publishing
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
- name: Extract release notes from NEWS.md
id: release_notes
run: |
VERSION=$(ruby -e "require_relative 'lib/factory_bot/version'; puts FactoryBot::VERSION")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
NOTES=$(awk "BEGIN{p=0} /^## $VERSION/{p=1; next} p && /^## /{exit} p{print}" NEWS.md)
echo "notes<<EOF" >> "$GITHUB_OUTPUT"
echo "$NOTES" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
Comment on lines +29 to +31
- uses: rubygems/release-gem@v1
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "v${{ steps.release_notes.outputs.version }}" \
--title "v${{ steps.release_notes.outputs.version }}" \
--notes "${{ steps.release_notes.outputs.notes }}"
Comment on lines +37 to +39
21 changes: 21 additions & 0 deletions .github/workflows/validate-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Validate changelog

on:
pull_request:
paths:
- lib/factory_bot/version.rb

jobs:
validate:
name: Check NEWS.md has release section
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Check NEWS.md contains version section
run: |
VERSION=$(ruby -e "require_relative 'lib/factory_bot/version'; puts FactoryBot::VERSION")
if ! grep -q "^## $VERSION" NEWS.md; then
echo "ERROR: NEWS.md is missing a section for version $VERSION"
echo "Add a '## $VERSION (date)' entry to NEWS.md before bumping the version."
exit 1
fi