-
Notifications
You must be signed in to change notification settings - Fork 47
66 lines (60 loc) · 1.96 KB
/
publish-a-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
name: Publish Release to GitHub
on:
pull_request:
branches:
- master
types:
- closed
jobs:
publish-a-release:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
steps:
- name: Extract version from branch name
run: |
set -x
branchName="${{ github.event.pull_request.head.ref }}"
version=${branchName#release/}
if [[ "$version" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(-rc\.([0-9]+))?$ ]]; then
echo "TAG=$version" >> $GITHUB_ENV
else
echo "$version is not a supported semver." >&2
exit 1
fi
- name: Create Release to GitHub
uses: actions/github-script@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
const { owner, repo } = context.repo;
const target_commitish = context.sha;
github.rest.repos.createRelease({
owner,
repo,
tag_name: process.env.TAG,
target_commitish,
name: `v${process.env.TAG}`,
generate_release_notes: true,
draft: process.env.TAG.includes('-rc'),
prerelease: false
});
- name: Create a PR to merge master back into develop branch
uses: actions/github-script@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
const { owner, repo } = context.repo;
const title = `Merge master into develop after publishing release ${process.env.TAG}`;
const body = 'Created by GitHub Actions';
const base = 'develop';
const head = 'master';
github.rest.pulls.create({
owner,
repo,
title,
body,
base,
head
});