diff --git a/.github/workflows/_auto-prod.yml b/.github/workflows/_auto-prod.yml index 8b69a38..8566c7e 100644 --- a/.github/workflows/_auto-prod.yml +++ b/.github/workflows/_auto-prod.yml @@ -1,22 +1,37 @@ -############################# -## Merge Release into Main ## -############################# +##################################### +## Auto Merge PR to Main - GitOps ## +##################################### -# Triggered on tag 'auto-prod' push +# Part of 'release-me' Git Ops Process: User Br -> release -> main -# export tt='auto-prod' +# Triggers on pushed auto-prod-* tags + +# EG +# export tt='auto-prod-1.3.0' +# OR +# export tt='auto-prod-1.2.1-dev' # git tag -d "$tt"; git push --delete origin "$tt"; git tag "$tt" && git push origin "$tt" #### Does the following: -# 1. Triggers 'Release' Stress Tests -# 2. if Tests and Code Review OK -# 3. Merge PR 'Release' --> 'Main' +# 1. Derives a Git Tag to make an RC Tag +# 2. Tags commit on release branch with RC Tag #### + on: push: tags: - auto-prod-* +# jobs: +# # please add 'main' Rule Required Checks, before running this job +# auto_merge_pr_to_main: +# uses: boromir674/automated-workflows/.github/workflows/go-auto-merge-main.yml@test +# with: +# main_branch: ${{ vars.GIT_MAIN_BRANCH || 'main' }} +# release_branch: ${{ vars.GIT_RELEASE_BRANCH || 'release' }} +# commit_message: 'Automated Workflows' +# secrets: +# pat_token: ${{ secrets.GA_WORKFLOWS_CI_PR_RW_AND_ACTIONS_RW }} jobs: merge_release_into_main: @@ -25,7 +40,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} RELEASE_BR: 'release' MAIN_BR: ${{ vars.GIT_MAIN_BRANCH || 'main' }} - COMMIT_MSG_ON_RELEASE_BR: 'Release Candidate - CI Pipeline' + COMMIT_MSG_ON_RELEASE_BR: 'Automated Workflows' steps: - uses: actions/checkout@v4 with: @@ -47,19 +62,6 @@ jobs: name: "Exit if '${{ github.ref }}' NOT on '${{ env.RELEASE_BR }}' branch" run: echo "Tag '${{ github.ref }}' on '${{ env.RELEASE_BR }}' = ${{ steps.tag_on_release.outputs.retval }}" && exit 1 - # Parse SOURCE Sem Ver - # - run: echo SEMVER=$(grep -E -o '^version\s*=\s*\".*\"' pyproject.toml | cut -d'"' -f2) >> $GITHUB_OUTPUT - # id: sem_ver - - # Find latest tag on MAIN_BR and derive Sem Ver - - name: "Search tags on MAIN_BR, filter out those not matching v* and find latest" - run: | - LATEST_PROD_GIT_TAG=$(git tag -l "v*" | sort -V | tail -n 1) - echo "[INFO]: Latest Prod Git Tag: $LATEST_PROD_GIT_TAG" - - LATEST_PROD_SEM_VER=${LATEST_PROD_GIT_TAG:1}" - echo "**Discovered Sem Ver, previously published: $LATEST_PROD_SEM_VER**" >> $GITHUB_STEP_SUMMARY - # READ NEW SEM VER from pushed git tag, ie '1.2.0' from 'auto-prod-1.2.0' - name: Read New Sem Ver from Tag id: sem_ver @@ -79,29 +81,27 @@ jobs: echo "PROD_OR_DEV=PROD" >> $GITHUB_OUTPUT fi - # Derive Git Tag that will trigger 'Release Candidate - CI Pipeline' - - name: 'Create Git Tag, by appending -rc to PROD Sem Ver' + # ie 1.0.1-> v1.0.1-rc + - name: 'Derive RC Git Tag from PROD Release: prepend v and append -rc to Sem Ver' if: ${{ steps.prod_or_dev.outputs.PROD_OR_DEV == 'PROD' }} run: 'echo RC_TAG="v${{ steps.sem_ver.outputs.SEMVER }}-rc" >> $GITHUB_ENV' - - name: 'Create Git Tag, using DEV Sem Ver' + # ie 1.0.1-dev-> v1.0.1-rc + - name: 'Derive RC Git Tag from DEV Release: prepend v, use part from Sem Ver and append -rc' if: ${{ steps.prod_or_dev.outputs.PROD_OR_DEV == 'DEV' }} - run: 'echo RC_TAG="v${{ steps.sem_ver.outputs.SEMVER }}" >> $GITHUB_ENV' + # run: 'echo RC_TAG="v${{ steps.sem_ver.outputs.SEMVER }}" >> $GITHUB_ENV' + run: 'echo RC_TAG="v$(echo ${{ steps.sem_ver.outputs.SEMVER }} | grep -oP "^\d+\.\d+\.\d+")-rc" >> $GITHUB_ENV' - - name: "Trigger Release Candidate - Stress Tests" + # potentially trigger Deployment into Staging/Test + - name: "Create and Push RC Tag ${{ env.RC_TAG }}" run: | - echo "[STEP]: Tag Local: ${RC_TAG}" - git tag -d "$RC_TAG" || echo "Ensured Local Tag $RC_TAG does not exist" + git tag -d "$RC_TAG" || true git tag "$RC_TAG" - echo - echo "[STEP]: Tag Remote: ${RC_TAG}" - git push --delete origin "$RC_TAG" || echo "Ensured Remote Tag $RC_TAG does not exist" + git push --delete origin "$RC_TAG" || true git push origin "$RC_TAG" - echo + + echo "Tag ${{ env.RC_TAG }} was **pushed to remote**" >> $GITHUB_STEP_SUMMARY echo " -> Pushed tag $RC_TAG" - echo - echo "## TRIGGERED RELEASE CANDIDATE - TESTS ##" - echo # Derive Commit subject for PR Merge, based on PROD or DEV - name: 'Create Commit Message: [NEW] ${{ env.COMMIT_MSG_ON_RELEASE_BR }} v${{ steps.sem_ver.outputs.SEMVER }} Release' @@ -115,6 +115,8 @@ jobs: # LABEL PR for Auto Deploy, to trigger 'Tag Prod' Workflow after merge - name: "Label PR for Auto Deploy" run: gh pr edit "${{ env.RELEASE_BR }}" --add-label "auto-deploy" + env: + GH_TOKEN: ${{ secrets.GA_WORKFLOWS_CI_PR_RW_AND_ACTIONS_RW }} ### Merge PR, when CI Pass + Human Review OK ### - name: "Merge PR 'head': ${{ env.RELEASE_BR }} --> 'base': ${{ env.MAIN_BR }}" diff --git a/.github/workflows/_tag-prod.yml b/.github/workflows/_tag-prod.yml index cf6d95c..b2a64a7 100644 --- a/.github/workflows/_tag-prod.yml +++ b/.github/workflows/_tag-prod.yml @@ -44,7 +44,7 @@ jobs: # if tag ends with '-rc' strip it and store remaining string if [[ $LATEST_GIT_TAG == *"-rc" ]]; then - PROD_SEM_VER=${LATEST_GIT_TAG:1:${#LATEST_GIT_TAG}-3} + PROD_SEM_VER=${LATEST_GIT_TAG:1:${#LATEST_GIT_TAG}-4} # else if dev substring is found then store as it is elif [[ $LATEST_GIT_TAG == *"dev"* ]]; then PROD_SEM_VER=$LATEST_GIT_TAG diff --git a/.github/workflows/go-auto-merge-main.yml b/.github/workflows/go-auto-merge-main.yml index c3f1d88..710d7b6 100644 --- a/.github/workflows/go-auto-merge-main.yml +++ b/.github/workflows/go-auto-merge-main.yml @@ -84,7 +84,7 @@ jobs: - name: Read New Sem Ver from Tag id: sem_ver run: | - NEW_SEMVER=$(echo "${{ github.ref }}" | cut -d'-' -f3) + NEW_SEMVER=$(echo "${{ github.ref }}" | grep -oP '(?<=auto-prod-).+') echo "[INFO]: New Sem Ver: $NEW_SEMVER" echo "**New Sem Ver: $NEW_SEMVER**" >> $GITHUB_STEP_SUMMARY echo SEMVER=$NEW_SEMVER >> $GITHUB_OUTPUT @@ -110,23 +110,22 @@ jobs: if: ${{ steps.prod_or_dev.outputs.PROD_OR_DEV == 'PROD' }} run: 'echo RC_TAG="v${{ steps.sem_ver.outputs.SEMVER }}-rc" >> $GITHUB_ENV' - # ie 1.0.1-dev-> v1.0.1-dev - - name: 'Derive RC Git Tag from DEV Release: prepend v and use rest of Sem Ver' + # ie 1.0.1-dev-> v1.0.1-rc + - name: 'Derive RC Git Tag from DEV Release: prepend v, use part from Sem Ver and append -rc' if: ${{ steps.prod_or_dev.outputs.PROD_OR_DEV == 'DEV' }} - run: 'echo RC_TAG="v${{ steps.sem_ver.outputs.SEMVER }}0" >> $GITHUB_ENV' + # run: 'echo RC_TAG="v${{ steps.sem_ver.outputs.SEMVER }}" >> $GITHUB_ENV' + run: 'echo RC_TAG="v$(echo ${{ steps.sem_ver.outputs.SEMVER }} | grep -oP "^\d+\.\d+\.\d+")-rc" >> $GITHUB_ENV' - - name: "Push RC Tag - potentially triggering Deployment into Staging" + # potentially trigger Deployment into Staging/Test + - name: "Create and Push RC Tag ${{ env.RC_TAG }}" run: | - echo "[STEP]: Tag Local: ${RC_TAG}" - git tag -d "$RC_TAG" || echo "Ensured Local Tag $RC_TAG does not exist" + git tag -d "$RC_TAG" || true git tag "$RC_TAG" - echo - echo "[STEP]: Tag Remote: ${RC_TAG}" - git push --delete origin "$RC_TAG" || echo "Ensured Remote Tag $RC_TAG does not exist" + git push --delete origin "$RC_TAG" || true git push origin "$RC_TAG" - echo + + echo "Tag ${{ env.RC_TAG }} was **pushed to remote**" >> $GITHUB_STEP_SUMMARY echo " -> Pushed tag $RC_TAG" - echo # Derive Commit subject for PR Merge, based on PROD or DEV diff --git a/CHANGELOG.md b/CHANGELOG.md index 9612541..472f3e6 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/). + +## 1.7.2 (2024-09-17) + +### Changes + +#### Feature + +- convert -dev tags into -rc when running Auto Prod Workflow + +#### Fix +- correctly name tag on main and improve Auto Prod + +#### Docs +- mention that Release Me Phase 2 creates an RC Tag on release branch + + ## 1.7.1 (2024-09-16) ### Changes diff --git a/docs/guides/gitops/run/guide_run_gitops_release_me_process.md b/docs/guides/gitops/run/guide_run_gitops_release_me_process.md index 29963f7..4a3a268 100644 --- a/docs/guides/gitops/run/guide_run_gitops_release_me_process.md +++ b/docs/guides/gitops/run/guide_run_gitops_release_me_process.md @@ -56,15 +56,28 @@ This is a `how-to` Guide, with everything you need, to "run" the 2. Wait for PR to open against *base* `main` branch, from *head* `release` branch -3. Derive new Sem Ver +3. Sync `release` branch to local checkout + + ```sh + export release=release + ``` + + ```sh + git fetch + git branch --track $release "origin/${release}" || true + git checkout "${release}" + git pull origin "${release}" + ``` + +4. Derive new Sem Ver {% include 'diagram-sem-ver-derivation-process.md' %} -4. Update Changelog (1) +5. Update Changelog (1) -5. If you maintain the Sem Ver in your source files, **update Sem Ver in sources** +6. If you maintain the Sem Ver in your source files, **update Sem Ver in sources** -6. Fire-up a `auto-prod-` git tag event (ie `auto-prod-1.2.0`) +7. Fire-up a `auto-prod-` git tag event (ie `auto-prod-1.2.0`) ```sh export _SEM_VER=... @@ -76,7 +89,7 @@ This is a `how-to` Guide, with everything you need, to "run" the git tag "$_tag" && git push origin "$_tag" ``` -7. If, you have setup `Human Approval`, give the Release a **green light**, by approving a Code Review. +8. If, you have setup `Human Approval`, give the Release a **green light**, by approving a Code Review. @@ -102,6 +115,7 @@ Your changes should now be merged into `main`. checkout release merge "User Br" id: "Merge" type: HIGHLIGHT + commit id: "CHANGELOG.md" tag: "v2.1.0-rc" checkout main merge release id: "[NEW] 2.1.0" type: HIGHLIGHT diff --git a/docs/topics/gitops/release-me-process.md b/docs/topics/gitops/release-me-process.md index ca9cc9f..ed4f97d 100644 --- a/docs/topics/gitops/release-me-process.md +++ b/docs/topics/gitops/release-me-process.md @@ -32,7 +32,12 @@ A typical **Release** `User Journey` for a single-Developer/Contributor project, ## Phase 1 -**On-demand trigger** by pushing the `release-me` git tag to remote. +- **On-demand trigger** by pushing the `release-me` git tag to remote. + +In this phase we say + + **Our `head` branch has all the code changes to be released** + ``` export tt='release-me' @@ -40,8 +45,8 @@ git tag -d "$tt"; git push --delete origin "$tt" git tag "$tt" && git push origin "$tt" ``` -1. Open `PR` 'User Br' --> 'release', and merge if *PR OK* -2. Open `PR` 'release' --> 'main' +1. Opens a `PR` 'User Br' --> 'release', and auto merges if *PR OK* +2. Opens a `PR` 'release' --> 'main' ```mermaid @@ -62,9 +67,25 @@ git tag "$tt" && git push origin "$tt" merge "User Br" id: "Merge" type: HIGHLIGHT ``` +## Manual Phase + +Typically, the Developer should take care of doing the necessary *Release chores*, +which include make changes to the source files. + +- Adding a new Release Entry in source Changelog + ## Phase 2 -**On-demand trigger** by pushing a `auto-prod-` git tag to remote. +- **On-demand trigger** by pushing a `auto-prod-` git tag to remote. + +!!! Tip + + Typically, the Developer should take care of doing the necessary *Release chores*, which include make changes to the source files, on the `release` branch: + + - **Updating Changelog**, by adding a Release Entry corresponding to the new Sem Ver + - **Updating Sem Ver in Sources**, by bumping all references of Version maintained in the Sources + + Example: ```