create-release-pull-request #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: create-release-pull-request | |
on: | |
workflow_dispatch: | |
inputs: | |
major_versionup: | |
description: "major version up" | |
type: boolean | |
required: false | |
default: false | |
minor_versionup: | |
description: "minor version up" | |
type: boolean | |
required: false | |
default: false | |
patch_versionup: | |
description: "patch version up" | |
type: boolean | |
required: false | |
default: true | |
permissions: | |
contents: write | |
pull-requests: write | |
env: | |
NEW_VERSION: "" | |
BRANCH_NAME: "" | |
TAG_NAME: "" | |
VERSION_UP_TYPE: "" | |
PACKAGE_NAME: dcaspt2_input_generator | |
jobs: | |
release-pr: | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 5 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install hatch twine | |
- name: Update version | |
run: | | |
if ${{ github.event.inputs.major_versionup }}; then | |
python .github/scripts/versionup.py --major | |
echo "VERSION_UP_TYPE=major" >> $GITHUB_ENV | |
elif ${{ github.event.inputs.minor_versionup }}; then | |
python .github/scripts/versionup.py --minor | |
echo "VERSION_UP_TYPE=minor" >> $GITHUB_ENV | |
elif ${{ github.event.inputs.patch_versionup }}; then | |
python .github/scripts/versionup.py --patch | |
echo "VERSION_UP_TYPE=patch" >> $GITHUB_ENV | |
fi | |
- name: Get the NEW_VERSION | |
run: | | |
NEW_VERSION=$(hatch version) | |
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | |
echo "BRANCH_NAME=release-v$NEW_VERSION" >> $GITHUB_ENV | |
echo "TAG_NAME=v$NEW_VERSION" >> $GITHUB_ENV | |
- name: Create Pull request with release-v${{ env.NEW_VERSION }} tag | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git checkout -b "${{ env.BRANCH_NAME }}" | |
git add . | |
git commit -m "Release ${{ env.PACKAGE_NAME }} ${{ env.NEW_VERSION }}" | |
git push origin "${{ env.BRANCH_NAME }}" | |
gh pr create --title "Release ${{ env.PACKAGE_NAME }} ${{ env.NEW_VERSION }}" --body "Release ${{ env.PACKAGE_NAME }} ${{ env.NEW_VERSION }}" --label ${{ env.VERSION_UP_TYPE }} --label "release" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |