generated from actions/typescript-action
-
-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (114 loc) · 5.29 KB
/
create_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
name: 'Create release'
on:
push:
branches:
- main
jobs:
skip:
name: Check release skip
runs-on: ubuntu-latest
if: "(! contains(github.event.head_commit.message, '[release skip]')) && (! contains(github.event.head_commit.message, 'Initial commit'))"
steps:
- run: echo "${{ github.event.head_commit.message }}"
create_release:
runs-on: ubuntu-latest
needs: [skip]
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/main'
- 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: 'Create release'
uses: softprops/action-gh-release@v1
with:
name: 'Release ${{ steps.calc.outputs.version }}'
tag_name: ${{ steps.calc.outputs.version }}
body: ${{steps.changelog.outputs.markdown}}
prepare_develop_branch:
runs-on: ubuntu-latest
needs: [skip, create_release]
steps:
- uses: actions/checkout@master
- name: 'Set git config'
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: 'Create or Switch develop branch'
run: |
git fetch
if [ `git branch -a --list origin/develop` ]; then
echo '> git switch develop'
git switch develop
else
echo '> git switch --create develop'
git switch --create develop
git push --set-upstream origin develop
fi
- name: 'Create empty commit'
run: |
git pull --no-edit
git commit --allow-empty -m "Create Pull Request"
git push origin develop
- name: 'Create Pull Request'
uses: repo-sync/pull-request@v2
with:
source_branch: 'develop'
destination_branch: 'main'
pr_title: 'Release'
pr_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.**"
pr_label: 'Release'
pr_draft: true
pr_allow_empty: true
github_token: ${{ secrets.GITHUB_TOKEN }}