Skip to content

Create release PR

Create release PR #22

# The workflow to create PRs with release commits.
name: Create release PR
on:
workflow_dispatch:
inputs:
release_version:
description: "Release version '0.1.2' (without 'v')"
required: true
snapshot_version:
description: "Snapshot version '0.2.0-SNAPSHOT' (without 'v')"
required: true
permissions:
contents: write
pull-requests: write
issues: write
jobs:
create_release_pr:
name: Create release PR (job)
runs-on: ubuntu-latest
steps:
- name: Check versions
env:
RELEASE_VERSION: ${{ github.event.inputs.release_version }}
SNAPSHOT_VERSION: ${{ github.event.inputs.snapshot_version }}
run: |
echo "Checking release version..."
if echo $RELEASE_VERSION | grep --invert-match '^[0-9]\+\.[0-9]\+\.[0-9]\+$' > /dev/null; then
echo "Release version is invalid"
exit 1
fi
echo "Checking snapshot version..."
if echo $SNAPSHOT_VERSION | grep --invert-match '^[0-9]\+\.[0-9]\+\.[0-9]\+-SNAPSHOT$' > /dev/null; then
echo "Snapshot version is invalid"
exit 1
fi
- name: Checkout main
uses: actions/checkout@v3
with:
ref: main
fetch-depth: 0
- name: Create release commits
env:
RELEASE_VERSION: ${{ github.event.inputs.release_version }}
SNAPSHOT_VERSION: ${{ github.event.inputs.snapshot_version }}
run: |
git config --local user.name "GitHub Action"
git config --local user.email "action@github.com"
sed -i -e "s/^version=.\+$/version=$RELEASE_VERSION/g" gradle.properties
git add gradle.properties
git commit -m "Release version $RELEASE_VERSION"
sed -i -e "s/^version=.\+$/version=$SNAPSHOT_VERSION/g" gradle.properties
git add gradle.properties
git commit -m "Bump version to $SNAPSHOT_VERSION"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
branch: release-${{ github.event.inputs.release_version }}
delete-branch: true
draft: true
title: Release version ${{ github.event.inputs.release_version }}
body: |
Proposed changelog:
- *fill in*