forked from digidem/release-automations
-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (63 loc) · 2.35 KB
/
check-pr-to-release.yml
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
name: Check PR to Release
on:
pull_request:
types:
- opened
- synchronize
- reopened
branches:
- 'release/**'
jobs:
check_release_branch:
name: No Commits
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Fetch base branch
run: |
git fetch origin ${{ github.event.pull_request.base.ref }}
- name: Check base branch has no commits since merge base
env:
BASE_BRANCH_HEAD_SHA: ${{ github.event.pull_request.base.sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
set -x
MERGE_BASE=$(git merge-base $PR_HEAD_SHA $BASE_BRANCH_HEAD_SHA)
echo $MERGE_BASE
echo $BASE_BRANCH_HEAD_SHA
if [ $MERGE_BASE != $BASE_BRANCH_HEAD_SHA ]; then
echo "Base branch has commits since merge base"
exit 1
fi
check_source_branch:
name: Check source branch
runs-on: ubuntu-latest
steps:
- name: Assert source branch is RC branch
if: ${{ !startsWith(github.head_ref, 'rc/') }}
run: exit 1
check_release_version:
name: Check release version
needs: check_source_branch
runs-on: ubuntu-latest
steps:
- name: Checkout necessary files
uses: actions/checkout@v4
with:
sparse-checkout: |
package.json
.github/parse-version/action.yml
sparse-checkout-cone-mode: false
- name: Parse version
id: version
uses: ./.github/parse-version
- name: Assert release version is not pre-release
if: endsWith(steps.version.outputs.releaseVersion, '-pre')
run: exit 1
- name: Assert release version matches RC branch name
if: format('rc/v{0}', steps.version.outputs.releaseShort) != github.event.pull_request.head.ref
run: exit 1