Draft new release #19
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: Draft new release | |
on: | |
workflow_dispatch: | |
jobs: | |
draft-new-release: | |
name: Draft a new release | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/heads/develop') || startsWith(github.ref, 'refs/heads/hotfix/') | |
steps: | |
- name: Checkout source branch | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Dart | |
uses: dart-lang/[email protected] | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: '11' | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: 'stable' | |
architecture: x64 | |
- name: Install Melos | |
run: | | |
dart pub global activate melos 2.9.0 | |
# In order to make a commit, we need to initialize a user. | |
# You may choose to write something less generic here if you want, it doesn't matter functionality wise. | |
- name: Initialize mandatory git config | |
run: | | |
git config user.name "GitHub actions" | |
git config user.email [email protected] | |
# Calculate the next release version based on conventional semantic release | |
- name: Create release branch | |
id: create-release | |
run: | | |
source_branch_name=${GITHUB_REF##*/} | |
release_type=release | |
grep -q "hotfix/" <<< "${GITHUB_REF}" && release_type=hotfix-release | |
git fetch origin main | |
git fetch --tags origin | |
git merge origin/main | |
current_version=$(grep -A0 'version:' pubspec.yaml | tail -n1 | awk '{ print $2 }') | |
melos version -a --no-git-tag-version --no-changelog --yes | |
new_version=$(grep -A0 'version:' pubspec.yaml | tail -n1 | awk '{ print $2 }') | |
git reset --hard | |
branch_name="${release_type}/${new_version}" | |
echo "Source branch for new release is $source_branch_name" | |
echo "Current version is $current_version" | |
echo "Release type is $release_type" | |
echo "New version is $new_version" | |
echo "New release branch name is $branch_name" | |
git checkout -b "$branch_name" | |
git push --set-upstream origin "$branch_name" | |
echo "source_branch_name=$source_branch_name" >> $GITHUB_OUTPUT | |
echo "branch_name=$branch_name" >> $GITHUB_OUTPUT | |
echo "new_version=$new_version" >> $GITHUB_OUTPUT | |
echo "CURRENT_VERSION_VALUE=$current_version" >> $GITHUB_ENV | |
echo "NEW_VERSION_VALUE=$new_version" >> $GITHUB_ENV | |
- name: Update changelog & bump version | |
id: finish-release | |
run: | | |
echo "Current version: $CURRENT_VERSION_VALUE" | |
echo "New version: $NEW_VERSION_VALUE" | |
npx replace $CURRENT_VERSION_VALUE $NEW_VERSION_VALUE sonar-project.properties | |
git add sonar-project.properties | |
melos version -a --yes | |
- name: Push new versions in release branch | |
run: | | |
git add . | |
git commit --amend --no-edit | |
git for-each-ref refs/tags | |
git push origin --tags | |
git push --follow-tags | |
- name: Create pull request into main | |
uses: repo-sync/pull-request@v2 | |
with: | |
source_branch: ${{ steps.create-release.outputs.branch_name }} | |
destination_branch: 'main' | |
github_token: ${{ secrets.PAT }} | |
pr_title: 'chore(release): pulling ${{ steps.create-release.outputs.branch_name }} into main' | |
pr_body: ':crown: *An automated PR*' | |
pr_reviewer: 'bardisg,desusai7' |