-
Notifications
You must be signed in to change notification settings - Fork 2
138 lines (115 loc) · 4.18 KB
/
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: release
on:
push:
branches:
- 'release/*'
jobs:
check-existing-release:
runs-on: ubuntu-latest
outputs:
RELEASE_EXISTS: ${{ steps.current-pr.outputs.pr_found }}
permissions:
pull-requests: read
steps:
- name: Get current PR
uses: 8BitJonny/[email protected]
id: current-pr
get-release-version:
needs: check-existing-release
if: needs.check-existing-release.outputs.RELEASE_EXISTS == 'false'
runs-on: ubuntu-latest
outputs:
RELEASE_VERSION: ${{ steps.release-version.outputs.RELEASE_VERSION }}
steps:
- name: Extract version from branch name
id: release-version
run: |
VERSION=${GITHUB_REF##*/}
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_OUTPUT
create-release-pr:
needs: get-release-version
runs-on: ubuntu-latest
steps:
- name: Get app token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
- name: Checkout the repo
uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
- name: Get release version
run: |
echo "RELEASE_VERSION=${{ needs.get-release-version.outputs.RELEASE_VERSION }}" >> $GITHUB_ENV
- name: Get current date
run: |
echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Build changelog
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v4
with:
configurationJson: |
{
"categories": [
{
"title": "### Features",
"labels": ["type: feature"],
"exclude_labels": ["package: patch", "package: potts"]
},
{
"title": "#### Features: \\x60patch\\x60",
"labels": ["type: feature", "package: patch"],
"exclude_labels": ["package: potts"],
"exhaustive": true
},
{
"title": "#### Features: \\x60potts\\x60",
"labels": ["type: feature", "package: potts"],
"exclude_labels": ["package: patch"],
"exhaustive": true
},
{
"title": "### Bug fixes",
"labels": ["type: bug"]
},
{
"title": "### Tests",
"labels": ["type: test"]
},
{
"title": "### Documentation",
"labels": ["type: docs"]
},
{
"title": "### Admin",
"labels": ["type: admin"]
}
],
"template": "# [${{ env.RELEASE_VERSION }}](https://github.com/${{ github.repository }}/releases/tag/${{ env.RELEASE_VERSION }}) - ${{ env.CURRENT_DATE }}\n\n> Compare with [#{{FROM_TAG}}](https://github.com/${{ github.repository }}/compare/#{{FROM_TAG}}...${{ env.RELEASE_VERSION }})\n\n#{{CHANGELOG}}",
"pr_template": "- #{{TITLE}} by [@#{{AUTHOR}}](https://github.com/#{{AUTHOR}}) in [##{{NUMBER}}](#{{URL}})"
}
toTag: ${{ github.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update changelog
run: |
export CHANGELOG=docs/_changelog/${{ env.RELEASE_VERSION }}.md
printf -- "---\ntitle: ${{ env.RELEASE_VERSION}}\n---\n\n" > $CHANGELOG
printf "${{ steps.build_changelog.outputs.changelog }}" >> $CHANGELOG
a=$(< $CHANGELOG); printf '%s\n' "$a" > $CHANGELOG
- name: Commit changelog
uses: EndBug/add-and-commit@v9
with:
add: docs/_changelog/${{ env.RELEASE_VERSION}}.md
author_name: bagheri-lab-bot[bot]
author_email: bagheri-lab-bot[bot]@users.noreply.github.com
message: "Add changelog for ${{ env.RELEASE_VERSION }}"
default_author: github_actor
push: 'origin ${{ github.event.push.ref }}'
- name: Create pull request
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
shell: bash -l {0}
run: |
gh pr create --title "Release ${{ env.RELEASE_VERSION }}" --body ""