-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (46 loc) · 1.57 KB
/
Copy pathrelease-on-merge.yml
File metadata and controls
53 lines (46 loc) · 1.57 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
name: Release on merge
# When a release/* PR merges into main, create a GitHub release (tag v-<version>).
# Events from GITHUB_TOKEN do not start other workflows; publish.yml is triggered via
# workflow_run when this workflow completes (see publish.yml).
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
id: ver
run: |
VERSION="$(node -p "require('./package.json').version")"
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
- name: Create GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
VERSION="${{ steps.ver.outputs.version }}"
TAG="v-${VERSION}"
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 }}" \
--title "${VERSION}" \
--generate-notes