|
| 1 | +# The workflow to create PRs with release commits. |
| 2 | +name: Create release PR |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + release_version: |
| 7 | + description: "Release version '0.1.2' (without 'v')" |
| 8 | + required: true |
| 9 | + snapshot_version: |
| 10 | + description: "Snapshot version '0.2.0-SNAPSHOT' (without 'v')" |
| 11 | + required: true |
| 12 | + |
| 13 | +jobs: |
| 14 | + create_release_pr: |
| 15 | + name: Create release PR (job) |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Check versions |
| 19 | + run: | |
| 20 | + echo "Checking release version..." |
| 21 | + if echo ${{ github.event.inputs.release_version }} | grep --invert-match '^[0-9]\+\.[0-9]\+\.[0-9]\+$' > /dev/null; then |
| 22 | + echo "Release version is invalid" |
| 23 | + exit 1 |
| 24 | + fi |
| 25 | +
|
| 26 | + echo "Checking snapshot version..." |
| 27 | + if echo ${{ github.event.inputs.snapshot_version }} | grep --invert-match '^[0-9]\+\.[0-9]\+\.[0-9]\+-SNAPSHOT$' > /dev/null; then |
| 28 | + echo "Snapshot version is invalid" |
| 29 | + exit 1 |
| 30 | + fi |
| 31 | +
|
| 32 | + - name: Checkout master |
| 33 | + uses: actions/checkout@v2 |
| 34 | + with: |
| 35 | + ref: master |
| 36 | + fetch-depth: 0 |
| 37 | + |
| 38 | + - name: Create release commits |
| 39 | + run: | |
| 40 | + git config --local user.name "GitHub Action" |
| 41 | + git config --local user.email "[email protected]" |
| 42 | + sed -i -e "s/^version=.\+$/version=${{ github.event.inputs.release_version }}/g" gradle.properties |
| 43 | + git add gradle.properties |
| 44 | + git commit -m "Release version ${{ github.event.inputs.release_version }}" |
| 45 | + sed -i -e "s/^version=.\+$/version=${{ github.event.inputs.snapshot_version }}/g" gradle.properties |
| 46 | + git add gradle.properties |
| 47 | + git commit -m "Bump version to ${{ github.event.inputs.snapshot_version }}" |
| 48 | +
|
| 49 | + - name: Create Pull Request |
| 50 | + uses: peter-evans/create-pull-request@v3 |
| 51 | + with: |
| 52 | + branch: release-${{ github.event.inputs.release_version }} |
| 53 | + delete-branch: true |
| 54 | + draft: true |
| 55 | + title: Release version ${{ github.event.inputs.release_version }} |
| 56 | + body: | |
| 57 | + Proposed changelog: |
| 58 | + - *fill in* |
0 commit comments