-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub_release_on_release_branch_merge.yml
More file actions
55 lines (48 loc) · 1.73 KB
/
github_release_on_release_branch_merge.yml
File metadata and controls
55 lines (48 loc) · 1.73 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
# When a release/* PR merges into main, create a GitHub release (tag vX.Y.Z).
# Events from GITHUB_TOKEN do not start other workflows; push_gem.yml is triggered via
# workflow_run when this workflow completes (see push_gem.yml).
name: Release on merge
on:
pull_request:
types: [closed]
branches:
- main
concurrency:
group: release-on-merge-${{ github.event.pull_request.number }}
cancel-in-progress: false
permissions:
contents: write
jobs:
github-release:
if: >-
github.event.pull_request.merged == true &&
startsWith(github.head_ref, 'release/') &&
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- name: Checkout merge commit
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
- name: Read version from lib/ruby_proxy_headers/version.rb
id: meta
run: |
VERSION=$(ruby -r ./lib/ruby_proxy_headers/version.rb -e 'puts RubyProxyHeaders::VERSION')
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
VERSION="${{ steps.meta.outputs.version }}"
TAG="v${VERSION}"
MERGE_SHA="${{ github.event.pull_request.merge_commit_sha }}"
if gh release view "${TAG}" --repo "${{ github.repository }}" >/dev/null 2>&1; then
echo "Release ${TAG} already exists; skipping."
exit 0
fi
gh release create "${TAG}" \
--repo "${{ github.repository }}" \
--target "${MERGE_SHA}" \
--title "${TAG}" \
--generate-notes