Skip to content

Update az_quickstart repository for new 2.12.x minor release branch. #29

Update az_quickstart repository for new 2.12.x minor release branch.

Update az_quickstart repository for new 2.12.x minor release branch. #29

name: Prepare repository for new minor release
run-name: Update az_quickstart repository for new `${{ inputs.release_branch_name }}` minor release branch.
on:
workflow_dispatch:
inputs:
release_branch_name:
description: The name of the new release branch (e.g. 2.9.x) to create.
required: true
jobs:
print_inputs:
runs-on: ubuntu-latest
steps:
- name: Print inputs
run: |
echo "release_branch_name: ${{ inputs.release_branch_name }}"
branch_name_prep:
timeout-minutes: 10
runs-on: ubuntu-latest
outputs:
next_minor_release: ${{ steps.define-version-variables.outputs.NEXT_MINOR_RELEASE }}
next_release_branch_alias_constraint: ${{ steps.define-version-variables.outputs.NEXT_RELEASE_VERSION_CONSTRAINT }}
this_release_branch_alias_constraint: ${{ steps.define-version-variables.outputs.THIS_RELEASE_VERSION_CONSTRAINT }}
main_branch_alias: ${{ steps.define-version-variables.outputs.MAIN_BRANCH_ALIAS }}
steps:
- name: Define version variables
id: define-version-variables
run: |
delimiter=.
version_parts=($(echo ${{ inputs.release_branch_name }} | tr $delimiter '\n'))
version_parts[1]=$((version_parts[1]+1))
NEXT_MINOR_RELEASE=$(IFS=$delimiter ; echo "${version_parts[*]}" | sed 's/\(.*\)\.x/\1/')
NEXT_RELEASE_VERSION_CONSTRAINT="~${NEXT_MINOR_RELEASE}"
echo "NEXT_MINOR_RELEASE=${NEXT_MINOR_RELEASE}" >> $GITHUB_OUTPUT
echo "NEXT_RELEASE_VERSION_CONSTRAINT=${NEXT_RELEASE_VERSION_CONSTRAINT}" >> $GITHUB_OUTPUT
echo "Next minor release: $NEXT_MINOR_RELEASE" >> $GITHUB_STEP_SUMMARY
echo "Next release version constraint: $NEXT_RELEASE_VERSION_CONSTRAINT" >> $GITHUB_STEP_SUMMARY
THIS_RELEASE_VERSION_CONSTRAINT=$(echo ${{ inputs.release_branch_name }} | sed 's/\(.*\)\.x/~\1/')
echo "THIS_RELEASE_VERSION_CONSTRAINT=${THIS_RELEASE_VERSION_CONSTRAINT}" >> $GITHUB_OUTPUT
echo "This release version constraint: $THIS_RELEASE_VERSION_CONSTRAINT" >> $GITHUB_STEP_SUMMARY
MAIN_BRANCH_ALIAS="${NEXT_MINOR_RELEASE}.x-dev"
echo "MAIN_BRANCH_ALIAS=${MAIN_BRANCH_ALIAS}" >> $GITHUB_OUTPUT
echo "Main branch alias: $MAIN_BRANCH_ALIAS" >> $GITHUB_STEP_SUMMARY
dispatch:
needs: branch_name_prep
strategy:
matrix:
repo:
- az-digital/az-quickstart-scaffolding
runs-on: ubuntu-latest
steps:
- name: Notify dependencies
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.REPO_DISPATCH_TOKEN }}
repository: ${{ matrix.repo }}
event-type: az_quickstart_prep_for_minor_release
client-payload: '{"release_branch_name": "${{ inputs.release_branch_name }}" , "this_release_branch_alias_constraint": "${{needs.branch_name_prep.outputs.this_release_branch_alias_constraint}}", "main_branch_alias": "${{needs.branch_name_prep.outputs.main_branch_alias}}", "next_release_branch_alias_constraint": "${{needs.branch_name_prep.outputs.next_release_branch_alias_constraint}}"}'
prepare_for_new_minor_release:
name: Prepare for a new minor release
runs-on: ubuntu-latest
needs: branch_name_prep
steps:
- name: Checkout az_quickstart
uses: actions/checkout@v4
with:
repository: az-digital/az_quickstart
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create and check out release branch
run: |
git checkout -b ${{ inputs.release_branch_name }}
- name: Set up git
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Push new release branch to GitHub
run: |
git commit --allow-empty -m "Prepare for new minor release ${{ inputs.release_branch_name }}"
git push origin -u ${{ inputs.release_branch_name }}
- name: Update DDev config in release branch
run: |
NEW_VERSION=${{ inputs.release_branch_name }}
sed -i "0,/main/s//$NEW_VERSION/" .ddev/commands/web/install
- name: Update Security workflow yml in release branch
run: |
NEW_VERSION=${{ inputs.release_branch_name }}
sed -i "s/SCAFFOLD_BRANCH=main/SCAFFOLD_BRANCH=$NEW_VERSION/g" .github/workflows/security.yml
- name: Update Create Release workflow yml in release branch
run: |
NEW_VERSION=${{ inputs.release_branch_name }}
sed -i "s|git clone https://github.com/az-digital/az-quickstart-scaffolding.git az_quickstart|git clone -b $NEW_VERSION https://github.com/az-digital/az-quickstart-scaffolding.git az_quickstart|" .github/workflows/create-release.yml
- name: Update Lando config in release branch
run: |
sed -i 's|SCAFFOLD_BRANCH="main"|SCAFFOLD_BRANCH="${{ inputs.release_branch_name }}"|g' .lando.yml
- name: Update Probo config in release branch
run: |
NEW_VERSION=${{ inputs.release_branch_name }}
sed -i "s/SCAFFOLD_BRANCH=main/SCAFFOLD_BRANCH=$NEW_VERSION/g" .probo.yaml
- name: Setup PHP with composer v2
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: composer:v2
- name: Update dev branch alias via Composer
run: |
composer config extra.branch-alias.dev-main ${{ needs.branch_name_prep.outputs.next_minor_release }}.x-dev
- name: Create pull request for new release branch updates
uses: peter-evans/create-pull-request@v7
with:
title: Prepare repository for new minor release branch ${{ inputs.release_branch_name }}
commit-message: Prepare repository for new minor release branch ${{ inputs.release_branch_name }}
branch: prepare-${{ inputs.release_branch_name }}-for-minor-release
base: ${{ inputs.release_branch_name }}
delete-branch: true
token: ${{ secrets.REPO_DISPATCH_TOKEN }}
labels: |
${{ inputs.release_branch_name }} only
add-paths: |
.ddev/commands/web/install
.github/workflows/security.yml
.github/workflows/create-release.yml
.lando.yml
.probo.yaml
composer.json
update_previous_release_branches:
needs: [prepare_for_new_minor_release, branch_name_prep]
runs-on: ubuntu-latest
name: Update `${{ matrix.previous_version }}` release branch.
strategy:
matrix:
previous_version:
- 2.0.x
- 2.1.x
- 2.2.x
- 2.3.x
- 2.4.x
- 2.5.x
- 2.6.x
- 2.7.x
- 2.8.x
- 2.9.x
- 2.10.x
steps:
- name: Update previous release branch `${{ matrix.previous_version }}`
uses: actions/checkout@v4
with:
ref: ${{ matrix.previous_version }}
token: ${{ secrets.REPO_DISPATCH_TOKEN }}
- name: Set up Git
run: |
git config user.name "GitHub Action"
git config user.email "[email protected]"
- name: Update dev branch alias via Composer
run: |
composer config extra.branch-alias.dev-main ${{ needs.branch_name_prep.outputs.next_minor_release }}.x-dev
- name: Create pull request for previous release branch updates
uses: peter-evans/create-pull-request@v7
with:
title: Prepare ${{ matrix.previous_version }} branch for new minor release branch ${{ inputs.release_branch_name }}
commit-message: Prepare ${{ matrix.previous_version }} branch for new minor release branch ${{ inputs.release_branch_name }}
branch: update-${{ matrix.previous_version }}-for-${{ inputs.release_branch_name }}
base: ${{ matrix.previous_version }}
delete-branch: true
token: ${{ secrets.REPO_DISPATCH_TOKEN }}
labels: |
${{ matrix.previous_version }} only
add-paths: |
composer.json
update_composer_dev_branch_alias_on_main_branch:
needs: [prepare_for_new_minor_release, branch_name_prep]
runs-on: ubuntu-latest
name: Update the composer dev branch alias on the `main` branch.
steps:
- name: Update `main` branch with new minor release branch alias.
uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.REPO_DISPATCH_TOKEN }}
- name: Set up Git
run: |
git config user.name "GitHub Action"
git config user.email "[email protected]"
- name: Update dev branch alias via Composer
run: |
composer config extra.branch-alias.dev-main ${{ needs.branch_name_prep.outputs.next_minor_release }}.x-dev
- name: Create pull request for main branch updates
uses: peter-evans/create-pull-request@v7
with:
title: Prepare `main` branch for new minor release branch ${{ inputs.release_branch_name }}
commit-message: Prepare `main` branch for new minor release branch ${{ inputs.release_branch_name }}
branch: update-main-for-${{ inputs.release_branch_name }}
base: main
labels: |
task
delete-branch: true
token: ${{ secrets.REPO_DISPATCH_TOKEN }}
add-paths: |
composer.json