Create Release #48
Workflow file for this run
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 | |
on: | |
workflow_dispatch: | |
inputs: | |
release-type: | |
required: true | |
type: choice | |
description: What type of release | |
options: | |
- major | |
- minor | |
- patch | |
jobs: | |
determine-next-versions: | |
name: Determine Next Version | |
runs-on: ubuntu-latest | |
outputs: | |
next-major: ${{ steps.nexttag.outputs.major }} | |
next-minor: ${{ steps.nexttag.outputs.minor }} | |
next-patch: ${{ steps.nexttag.outputs.patch }} | |
branch-major: ${{ steps.branchnames.outputs.major-branch }} | |
branch-minor: ${{ steps.branchnames.outputs.minor-branch }} | |
branch-patch: ${{ steps.branchnames.outputs.patch-branch }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Get Previous Tag | |
id: previoustag | |
uses: "WyriHaximus/github-action-get-previous-tag@v1" | |
with: | |
fallback: 0.0.0 | |
- name: Get Next Versions | |
id: nexttag | |
uses: "WyriHaximus/github-action-next-semvers@v1" | |
with: | |
version: ${{ steps.previoustag.outputs.tag }} | |
- name: Build Branch Names | |
id: branchnames | |
run: | | |
echo "major-branch=release-major-v${{ steps.nexttag.outputs.major }}" >> $GITHUB_OUTPUT | |
echo "minor-branch=release-minor-v${{ steps.nexttag.outputs.minor }}" >> $GITHUB_OUTPUT | |
echo "patch-branch=release-patch-v${{ steps.nexttag.outputs.patch }}" >> $GITHUB_OUTPUT | |
create-release-branch: | |
name: Create Release Branch | |
runs-on: ubuntu-latest | |
needs: determine-next-versions | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Create major release branch | |
if: ${{ github.event.inputs.release-type == 'major' }} | |
run: | | |
git checkout -b ${{ needs.determine-next-versions.outputs.branch-major }} | |
git push origin ${{ needs.determine-next-versions.outputs.branch-major }} | |
- name: Create minor release branch | |
if: ${{ github.event.inputs.release-type == 'minor' }} | |
run: | | |
git checkout -b ${{ needs.determine-next-versions.outputs.branch-minor }} | |
git push origin ${{ needs.determine-next-versions.outputs.branch-minor }} | |
- name: Create patch release branch | |
if: ${{ github.event.inputs.release-type == 'patch' }} | |
run: | | |
git checkout -b ${{ needs.determine-next-versions.outputs.branch-patch }} | |
git push origin ${{ needs.determine-next-versions.outputs.branch-patch }} | |
bump-version: | |
name: Bump the Version | |
runs-on: ubuntu-latest | |
needs: [determine-next-versions, create-release-branch] | |
steps: | |
- name: Check out code - major release | |
uses: actions/checkout@v3 | |
if: ${{ github.event.inputs.release-type == 'major' }} | |
with: | |
ref: ${{ needs.determine-next-versions.outputs.branch-major }} | |
- name: Check out code - minor release | |
uses: actions/checkout@v3 | |
if: ${{ github.event.inputs.release-type == 'minor' }} | |
with: | |
ref: ${{ needs.determine-next-versions.outputs.branch-minor }} | |
- name: Check out code - patch release | |
uses: actions/checkout@v3 | |
if: ${{ github.event.inputs.release-type == 'patch' }} | |
with: | |
ref: ${{ needs.determine-next-versions.outputs.branch-patch }} | |
- name: Update major version | |
if: ${{ github.event.inputs.release-type == 'major' }} | |
run: | | |
new_version=${{ needs.determine-next-versions.outputs.next-major }} | |
current_version_code=$(grep 'versionCode ' passage/build.gradle | awk '{print $2}') | |
new_version_code=$((current_version_code + 1)) | |
sed -i "s/versionName \".*\"/versionName \"$new_version\"/" passage/build.gradle | |
sed -i "s/^version = \".*\"/version = \"$new_version\"/" passage/build.gradle | |
sed -i "s/versionCode .*/versionCode $new_version_code/" passage/build.gradle | |
echo "Updated to major version $new_version with version code $new_version_code" | |
- name: Update minor version | |
if: ${{ github.event.inputs.release-type == 'minor' }} | |
run: | | |
new_version=${{ needs.determine-next-versions.outputs.next-minor }} | |
current_version_code=$(grep 'versionCode ' passage/build.gradle | awk '{print $2}') | |
new_version_code=$((current_version_code + 1)) | |
sed -i "s/versionName \".*\"/versionName \"$new_version\"/" passage/build.gradle | |
sed -i "s/^version = \".*\"/version = \"$new_version\"/" passage/build.gradle | |
sed -i "s/versionCode .*/versionCode $new_version_code/" passage/build.gradle | |
echo "Updated to minor version $new_version with version code $new_version_code" | |
- name: Update patch version | |
if: ${{ github.event.inputs.release-type == 'patch' }} | |
run: | | |
new_version=${{ needs.determine-next-versions.outputs.next-patch }} | |
current_version_code=$(grep 'versionCode ' passage/build.gradle | awk '{print $2}') | |
new_version_code=$((current_version_code + 1)) | |
sed -i "s/versionName \".*\"/versionName \"$new_version\"/" passage/build.gradle | |
sed -i "s/^version = \".*\"/version = \"$new_version\"/" passage/build.gradle | |
sed -i "s/versionCode .*/versionCode $new_version_code/" passage/build.gradle | |
echo "Updated to patch version $new_version with version code $new_version_code" | |
- name: Update version in README - major release | |
if: ${{ github.event.inputs.release-type == 'major' }} | |
run: | | |
new_version=${{ needs.determine-next-versions.outputs.next-major }} | |
sed -i "s/implementation 'id\.passage\.android:passage:[0-9]*\.[0-9]*\.[0-9]*'/implementation 'id.passage.android:passage:$new_version'/" README.md | |
echo "Updated README to version $new_version" | |
- name: Update version in README - minor release | |
if: ${{ github.event.inputs.release-type == 'minor' }} | |
run: | | |
new_version=${{ needs.determine-next-versions.outputs.next-minor }} | |
sed -i "s/implementation 'id\.passage\.android:passage:[0-9]*\.[0-9]*\.[0-9]*'/implementation 'id.passage.android:passage:$new_version'/" README.md | |
echo "Updated README to version $new_version" | |
- name: Update version in README - patch release | |
if: ${{ github.event.inputs.release-type == 'patch' }} | |
run: | | |
new_version=${{ needs.determine-next-versions.outputs.next-patch }} | |
sed -i "s/implementation 'id\.passage\.android:passage:[0-9]*\.[0-9]*\.[0-9]*'/implementation 'id.passage.android:passage:$new_version'/" README.md | |
echo "Updated README to version $new_version" | |
- name: Commit major version change | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
if: ${{ github.event.inputs.release-type == 'major' }} | |
with: | |
commit_message: "Bumped version to ${{ needs.determine-next-versions.outputs.next-major }}" | |
branch: ${{ needs.determine-next-versions.outputs.branch-major }} | |
- name: Commit minor version change | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
if: ${{ github.event.inputs.release-type == 'minor' }} | |
with: | |
commit_message: "Bumped version to ${{ needs.determine-next-versions.outputs.next-minor }}" | |
branch: ${{ needs.determine-next-versions.outputs.branch-minor }} | |
- name: Commit patch version change | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
if: ${{ github.event.inputs.release-type == 'patch' }} | |
with: | |
commit_message: "Bumped version to ${{ needs.determine-next-versions.outputs.next-patch }}" | |
branch: ${{ needs.determine-next-versions.outputs.branch-patch }} | |
create-github-release: | |
name: Create GitHub Release | |
runs-on: ubuntu-latest | |
needs: [determine-next-versions, create-release-branch, bump-version] | |
steps: | |
- name: Check out code - major release | |
uses: actions/checkout@v3 | |
if: ${{ github.event.inputs.release-type == 'major' }} | |
- name: Check out code - minor release | |
uses: actions/checkout@v3 | |
if: ${{ github.event.inputs.release-type == 'minor' }} | |
- name: Check out code - patch release | |
uses: actions/checkout@v3 | |
if: ${{ github.event.inputs.release-type == 'patch' }} | |
- name: Create Release - major | |
uses: ncipollo/release-action@v1 | |
if: ${{ github.event.inputs.release-type == 'major' }} | |
with: | |
tag: "v${{ needs.determine-next-versions.outputs.next-major }}" | |
generateReleaseNotes: true | |
draft: false | |
- name: Create Release - minor | |
uses: ncipollo/release-action@v1 | |
if: ${{ github.event.inputs.release-type == 'minor' }} | |
with: | |
tag: "v${{ needs.determine-next-versions.outputs.next-minor }}" | |
generateReleaseNotes: true | |
draft: false | |
- name: Create Release - patch | |
uses: ncipollo/release-action@v1 | |
if: ${{ github.event.inputs.release-type == 'patch' }} | |
with: | |
tag: "v${{ needs.determine-next-versions.outputs.next-patch }}" | |
generateReleaseNotes: true | |
draft: false | |
create-pull-request: | |
name: Create Pull Request | |
runs-on: ubuntu-latest | |
needs: [create-github-release] | |
steps: | |
- name: Check out code - major release | |
uses: actions/checkout@v3 | |
if: ${{ github.event.inputs.release-type == 'major' }} | |
with: | |
ref: ${{ needs.determine-next-versions.outputs.branch-major }} | |
- name: Check out code - minor release | |
uses: actions/checkout@v3 | |
if: ${{ github.event.inputs.release-type == 'minor' }} | |
with: | |
ref: ${{ needs.determine-next-versions.outputs.branch-minor }} | |
- name: Check out code - patch release | |
uses: actions/checkout@v3 | |
if: ${{ github.event.inputs.release-type == 'patch' }} | |
with: | |
ref: ${{ needs.determine-next-versions.outputs.branch-patch }} | |
- name: Create pull request for major release into main | |
uses: peter-evans/create-pull-request@v3 | |
if: ${{ github.event.inputs.release-type == 'major' }} | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
head: ${{ needs.determine-next-versions.outputs.branch-major }} | |
base: main | |
title: v${{ needs.determine-next-versions.outputs.next-major }} into main | |
body: | | |
This PR was created by the create-release-branch workflow. | |
New Release: v${{ needs.determine-next-versions.outputs.next-major }} | |
I've updated the version name and code commit. | |
- name: Create pull request for minor release into main | |
uses: peter-evans/create-pull-request@v3 | |
if: ${{ github.event.inputs.release-type == 'minor' }} | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
head: ${{ needs.determine-next-versions.outputs.branch-minor }} | |
base: main | |
title: v${{ needs.determine-next-versions.outputs.next-minor }} into main | |
body: | | |
This PR was created by the create-release-branch workflow. | |
New Release: v${{ needs.determine-next-versions.outputs.next-minor }} | |
I've updated the version name and code commit. | |
- name: Create pull request for patch release into main | |
uses: peter-evans/create-pull-request@v3 | |
if: ${{ github.event.inputs.release-type == 'patch' }} | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
head: ${{ needs.determine-next-versions.outputs.branch-patch }} | |
base: PSG-3979 | |
title: v${{ needs.determine-next-versions.outputs.next-patch }} into main | |
body: | | |
This PR was created by the create-release-branch workflow. | |
New Release: v${{ needs.determine-next-versions.outputs.next-patch }} | |
I've updated the version name and code commit. |