Skip to content

Release

Release #1

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:
push:
# 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@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit
- name: Checkout Git Repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Ruby
uses: ruby/setup-ruby@2a18b06812b0e15bb916e1df298d3e740422c47e # v1.203.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: 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
run: bundle exec rake bump_version[${{ inputs.version }}]
# 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@9e85cb11501bebc2ae661c1500176316d3987059 # v1.1.0
with:
await-release: ${{ ! inputs.dry-run }}
# 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@v6
with:
branch: release-v${{ inputs.version }}
title: "Release v${{ inputs.version }}"
body: |
- [ ] 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@v1
with:
draft: true
generateReleaseNotes: true
tag: v${{ inputs.version }}