Skip to content

Next release

Next release #35

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 }}