generated from slime-hatena/template
-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (74 loc) · 3.38 KB
/
update_pull_request_for_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
name: 'Update pull request for release'
on:
pull_request:
types:
- opened
- reopened
- edited
- synchronize
jobs:
update_pull_requests:
if: contains(github.event.pull_request.labels.*.name, 'Release')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: 'Get latest name'
uses: pozetroninc/github-action-get-latest-release@master
id: get-latest
continue-on-error: true
with:
repository: ${{ github.repository }}
excludes: 'prerelease, draft'
- name: Check first release
id: check-latest
run: |
if [ -n "${{ steps.get-latest.outputs.release }}" ];then
echo "::set-output name=version::${{ steps.get-latest.outputs.release }}";
echo "::set-output name=from::${{ steps.get-latest.outputs.release }}";
echo "::set-output name=skip::false";
else
echo "::set-output name=version::1.0.0";
echo "::set-output name=from::4b825dc642cb6eb9a060e54bf8d69288fbee4904";
echo "::set-output name=skip::true";
fi
- name: 'Generate changelog'
uses: 'slime-hatena/lerna-changelog-action@main'
id: changelog
with:
GITHUB_AUTH: '${{ secrets.GITHUB_TOKEN }}'
tag_from: '${{ steps.check-latest.outputs.from }}'
tag_to: 'origin/develop'
- name: Judge the next version
id: judge-next-version
run: |
echo "::set-output name=major::false";
echo "::set-output name=minor::false";
echo "::set-output name=patch::false";
if [ "${{ steps.check-latest.outputs.skip }}" = "false" ]; then
if [ -n "`echo "${{ steps.changelog.outputs.markdown }}" | grep 'Breaking Change';`" ] ; then
echo "::set-output name=major::true";
elif [ -n "`echo "${{ steps.changelog.outputs.markdown }}" | grep 'Feature'`" ] ; then
echo "::set-output name=minor::true";
else
echo "::set-output name=patch::true";
fi
fi
- name: 'Calc next version'
uses: 'slime-hatena/semantic-versioning-calculator-action@main'
id: calc
with:
version: '${{ steps.check-latest.outputs.version }}'
increment_major: '${{ steps.judge-next-version.outputs.major }}'
increment_minor: '${{ steps.judge-next-version.outputs.minor }}'
increment_patch: '${{ steps.judge-next-version.outputs.patch }}'
- name: 'Create tag test'
run: |
git tag ${{ steps.calc.outputs.version }}
git tag -d ${{ steps.calc.outputs.version }}
- name: 'Update pull requests'
uses: riskledger/update-pr-description@v2
with:
body: "This is a pull request for the next release.\nIf you approve it, the release will be created.\nPlease merge your changes into this branch.\n\n**Do not attach anything other than a release tag to this request.\nUnexpected versions and content may be released.**\n\n### Next version\n\nNext version: `${{ steps.calc.outputs.version }}`\nAutomatically set based on the contents of the release notes.\n\n### Release note\n\nGenerated range: `${{ steps.check-latest.outputs.from }}...origin/develop`\n\n```md\n${{steps.changelog.outputs.markdown}}\n```"
token: ${{ secrets.GITHUB_TOKEN }}