-
Notifications
You must be signed in to change notification settings - Fork 36
132 lines (113 loc) · 5.42 KB
/
Copy pathrelease.yaml
File metadata and controls
132 lines (113 loc) · 5.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# 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 this action to admins.
if: github.repository == 'block/elasticgraph' && contains('["myronmarston", "bsorbo"]', github.actor)
runs-on: ubuntu-latest
environment:
name: rubygems.org
url: https://rubygems.org/search?query=elasticgraph
permissions:
actions: write
contents: write
id-token: write
pull-requests: write
steps:
# Set up
- name: Harden Runner
uses: step-security/harden-runner@05e31511f85b41b11d1cf0ef85d0992719546e2c # v2.21.0
with:
egress-policy: audit
- name: Checkout Git Repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Ruby
uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.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: 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: 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@7f9650160c1a4e7989fdc9855807bdbd421d8b6b # v1.4.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@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
sign-commits: false
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)
# PRs created using GITHUB_TOKEN don't trigger `pull_request` workflows (GitHub prevents
# this to avoid infinite loops). We explicitly trigger CI here so that the release PR
# gets the required `All CI Checks Passed` status check for branch protection.
- name: Trigger CI on release branch
run: gh workflow run ci.yaml --ref release-v${{ inputs.version }}
env:
GH_TOKEN: ${{ github.token }}
- name: Create GitHub Release
uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0
with:
draft: true
generateReleaseNotes: true
tag: v${{ inputs.version }}