-
Notifications
You must be signed in to change notification settings - Fork 23
72 lines (72 loc) · 2.96 KB
/
Copy pathcreate-release-branch.yaml
File metadata and controls
72 lines (72 loc) · 2.96 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
name: Create Release Branch
on:
workflow_dispatch:
inputs:
release_version:
description: 'Which version are we creating a release branch for?'
required: true
from_branch:
description: 'Which branch to source release branch from? (default: master)'
required: false
default: 'master'
jobs:
create-release-branch:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: validate version
run: echo "${{github.event.inputs.release_version}}" | grep -E 'v[0-9]+\.[0-9]+\.[0-9]+$'
- uses: actions/checkout@v3
with:
ref: ${{github.event.inputs.from_branch}}
- name: create branch
run: |
git remote -v
git checkout -b release-${{github.event.inputs.release_version}}
git push origin release-${{github.event.inputs.release_version}}
generate-release-changelog:
needs: create-release-branch
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
ref: release-${{github.event.inputs.release_version}}
fetch-depth: 0
- name: setup git
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
- name: install go
uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: install git-chglog
run: GOBIN=${GITHUB_WORKSPACE} go install github.com/git-chglog/git-chglog/cmd/git-chglog@v0.15.1
- name: generate release notes
run: |
git tag ${{github.event.inputs.release_version}}
${GITHUB_WORKSPACE}/git-chglog --tag-filter-pattern 'v\d+\.\d+\.\d+$' --output releases/CHANGELOG-${{github.event.inputs.release_version}}.md ${{github.event.inputs.release_version}}
git tag -d ${{github.event.inputs.release_version}}
git add releases/CHANGELOG-${{github.event.inputs.release_version}}.md
- name: remove git-chglog binary
run: rm -f ${GITHUB_WORKSPACE}/git-chglog
- name: create changelog branch
run: |
git commit -m "release: ${RELEASE_VER} CHANGELOG"
git checkout -b CHANGELOG-${RELEASE_VER}
git push origin CHANGELOG-${RELEASE_VER}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_VER: ${{github.event.inputs.release_version}}
- name: print create pr instructions
run: |
BASE=release-${RELEASE_VER}
TITLE="release: ${RELEASE_VER} CHANGELOG"
BODY="Add CHANGELOG for upcoming ${RELEASE_VER} release"
echo "Create PR from web UI: https://github.com/${GITHUB_REPOSITORY}/pull/new/CHANGELOG-${RELEASE_VER}"
echo "Create PR from GH CLI: > gh pr create -b \"${BASE}\" -t \"${TITLE}\" -b \"${BODY}\" -R ${GITHUB_REPOSITORY}"
env:
RELEASE_VER: ${{github.event.inputs.release_version}}