Skip to content

Release

Release #51

Workflow file for this run

# This workflow was generated by https://github.com/rubygems/configure_trusted_publisher
name: Release
on:
workflow_dispatch:
inputs:
version:
description: "Version to release (e.g. 1.2.0)"
required: true
type: string
dry-run:
description: "Dry Run"
required: false
type: boolean
default: false
permissions:
contents: read
jobs:
release:
name: Release Gems
# Limit who can run run this action to core maintainers.
if: github.repository == 'block/elasticgraph' && contains('["myronmarston", "BrianSigafoos-SQ"]', github.actor)
runs-on: ubuntu-latest
environment:
name: rubygems.org
url: https://rubygems.org/search?query=elasticgraph
permissions:
contents: write
id-token: write
pull-requests: write
steps:
# Set up
- name: Harden Runner
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
- name: Checkout Git Repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Ruby
uses: ruby/setup-ruby@2a7b30092b0caf9c046252510f9273b4875f3db9 # v1.254.0
with:
working-directory: config/release
bundler-cache: true
ruby-version: ruby
- name: Setup Git Config
# https://github.com/orgs/community/discussions/26560#discussioncomment-3531273
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
- name: Archive Docs (for non-prerelease versions)
run: |
if [[ ! "${{ inputs.version }}" =~ [a-zA-Z] ]]; then
bundle exec rake "site:archive_docs[${{ inputs.version }}]"
git add config/site/archived_docs/v${{ inputs.version }}.tar.gz
git commit -m "Archive docs for v${{ inputs.version }}"
fi
- name: Target Release Rakefile
run: |
rm Rakefile
cp config/release/Rakefile .
git update-index --skip-worktree Rakefile
echo "BUNDLE_GEMFILE=config/release/Gemfile" >> "$GITHUB_ENV"
- name: Bump the ElasticGraph version to release version
run: |
bundle exec rake bump_version[${{ inputs.version }}]
if [[ ! "${{ inputs.version }}" =~ [a-zA-Z] ]]; then
# For non-prerelease versions, squash the doc archive commit with the version bump
git reset --soft HEAD~2 && git commit -C ORIG_HEAD
fi
# Note: we put this after bumping the version because really bumping the version is safe to do in dry-run mode.
- name: Enable Dry Run Mode
if: ${{ inputs.dry-run }}
# As per docs[^1], this is the syntax for setting ENV vars for later steps.
# [^1]: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-environment-variable
run: echo "GEM_RELEASE_PRETEND=true" >> "$GITHUB_ENV"
# Release
- name: Release to rubygems.org
uses: rubygems/release-gem@a25424ba2ba8b387abc8ef40807c2c85b96cbe32 # v1.1.1
with:
await-release: ${{ ! inputs.dry-run }}
- name: Bump the ElasticGraph version to next pre-release version
run: |
unset GEM_RELEASE_PRETEND
bundle exec rake bump_version_to_next_prerelease
# Note: this must come after we release the gem because it resets git back to the same SHA we started on
# (before bumping the version), but the RubyGems release depends on the version having been bumped.
- name: Create pull request for the version bump
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
with:
sign-commits: true
branch: release-v${{ inputs.version }}
title: "Release v${{ inputs.version }}"
body: |
> [!NOTE]
> This PR bumps the ElasticGraph version twice in two separate commits. The released version does not show
> in the overall PR diff but is in the first commit. These two commits should not be squashed or rebased so
> that the tagged commit lands as-is in the base branch.
- [ ] Confirm the [release action](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) succeeded before merging
- [ ] Confirm this version bump should be merged into [${{ github.ref_name }}](https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}) or change the base branch
- [ ] Review and edit the [GitHub Draft Release](https://github.com/${{ github.repository }}/releases) (can be done after this PR is merged)
- name: Create GitHub Release
uses: ncipollo/release-action@bcfe5470707e8832e12347755757cec0eb3c22af # v1.18.0
with:
draft: true
generateReleaseNotes: true
tag: v${{ inputs.version }}