From bd2139850f91b8349cf22a4f66cfa67551e93247 Mon Sep 17 00:00:00 2001 From: JJ Fullmer Date: Thu, 8 Aug 2024 14:29:10 -0600 Subject: [PATCH] Automated Releases of stable revisions #601 - Update workflows with tested manual steps (tested in fork). Still working out the proper triggers. Planning to have a separate repo for install tests. If it's possible to have tests for capture/deploy that will also be a separate repo. --- .githooks/pre-commit | 13 ++++++++-- .../stable-releases-1_pull-request.yml | 11 ++++++-- .../stable-releases-2_test-validity.yml | 26 +++++++++++++++---- .../stable-releases-3_tag-and-release.yml | 25 +++++++++++++----- 4 files changed, 60 insertions(+), 15 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 3495970c33..ba2a630373 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -8,7 +8,7 @@ # To enable this hook, rename this file to "pre-commit". # # Exit on error -set -e +#set -e project_dir=$(git rev-parse --show-toplevel) @@ -50,7 +50,7 @@ verbegin="" channel="" case $branchon in - dev|stable) + dev) # Describe the tag and append the commit count correctly tagversion=$(git describe --tags ${gitcom}) baseversion=${tagversion%.*} # Retain everything before the last segment @@ -58,6 +58,15 @@ case $branchon in trunkversion="${baseversion}.${gitcount}" channel="Patches" ;; + stable) + # For stable, don't increment version, use what is being pulled from dev-branch + tagversion=$(git describe --tags ${gitcom}) + baseversion=${tagversion%.*} # Retain everything before the last segment + lastrevision=${tagversion##*.} # Extracts the last segment + gitcount=$(git rev-list master..dev-branch --count) #get the gitcount from dev-branch instead + trunkversion="${baseversion}.${gitcount}" + channel="Patches" + ;; working) # Generate a version number based on the branchend and commit count for the working branch verbegin="${branchend}.0-beta" diff --git a/.github/workflows/stable-releases-1_pull-request.yml b/.github/workflows/stable-releases-1_pull-request.yml index 4ee4a4a68b..583bf3670c 100644 --- a/.github/workflows/stable-releases-1_pull-request.yml +++ b/.github/workflows/stable-releases-1_pull-request.yml @@ -7,9 +7,16 @@ on: jobs: create-release-pull-request: runs-on: ubuntu-latest + if: github.ref == 'refs/heads/stable' steps: - uses: actions/checkout@v4 + with: + ref: dev-branch - name: create pull request - run: gh pr create -B stable -H dev-branch --title "Monthly Release PR - $(date '+%Y-%m-%d')" --body "Monthly pull request for creating the latest stable release from staged security fixes, bug fixes, and minor enhancements." + run: | + echo 'Get version to be released and create PR with that in the name' + system_file="$(git rev-parse --show-toplevel)/packages/web/lib/fog/system.class.php" + tag=$(grep "define('FOG_VERSION'" $system_file | sed "s/.*FOG_VERSION', '\([^']*\)');/\1/") + gh pr create -B stable -H dev-branch --title "Stable Release PR For ${tag} - $(date '+%Y-%m-%d')" --body "Pull Request for creating the latest stable release from staged security fixes, bug fixes, and minor enhancements in dev-branch. Created as needed or monthly on 15th of every month, released once tests are passing" env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/stable-releases-2_test-validity.yml b/.github/workflows/stable-releases-2_test-validity.yml index 4bcd1ed18c..633ce3e29c 100644 --- a/.github/workflows/stable-releases-2_test-validity.yml +++ b/.github/workflows/stable-releases-2_test-validity.yml @@ -2,14 +2,30 @@ name: Stable Release Step 2 - Validate PR on: workflow_dispatch: + # pull_request: + # types: + # - open + # branches: + # - dev-branch + # - stable jobs: - Confirm-All-Tests-Passed: + Merge-After-All-Tests-Passed: runs-on: ubuntu-latest + if: github.ref == 'refs/heads/stable' steps: - # - uses: actions/checkout@v4 - - name: 'placeholder for confirming tests passed' - run: return true; + - name: Check out code + uses: actions/checkout@v4 + - name: Merge The PR + run: | + echo 'Get the tag' + git fetch origin dev-branch + git checkout dev-branch + system_file="$(git rev-parse --show-toplevel)/packages/web/lib/fog/system.class.php" + tag=$(grep "define('FOG_VERSION'" $system_file | sed "s/.*FOG_VERSION', '\([^']*\)');/\1/") + git checkout stable + echo "merge the pull request bringing dev-branch into stable"; + gh pr merge dev-branch --squash --subject "Stable Release - ${tag}"; env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -18,4 +34,4 @@ jobs: # down the road-test various functions (deploy, capture, API) # Fix version if needed # merge pull request with generic commit -# maybe update version if not handled in hook +# maybe update version if not handled in hook \ No newline at end of file diff --git a/.github/workflows/stable-releases-3_tag-and-release.yml b/.github/workflows/stable-releases-3_tag-and-release.yml index 264e87b7d6..bd875957be 100644 --- a/.github/workflows/stable-releases-3_tag-and-release.yml +++ b/.github/workflows/stable-releases-3_tag-and-release.yml @@ -2,23 +2,36 @@ name: Stable Release Step 3 - Tag and Release on: workflow_dispatch: - + # pull_request: + # types: + # - closed + jobs: Tag-and-release: runs-on: ubuntu-latest + if: github.ref == 'refs/heads/stable' steps: - # - uses: actions/checkout@v4 - - name: 'placeholder for tag and release' + - name: Check-out code to release + uses: actions/checkout@v4 + - name: Tag and release run: | + echo 'Find the version to use for the tag, create the release, and sync the dev and stable branches' echo 'find the version to create as a tag' - echo 'create the tag and release probably like...' - echo 'gh release create --notes-from-tag --latest --generate-notes --target stable' + system_file="$(git rev-parse --show-toplevel)/packages/web/lib/fog/system.class.php" + tag=$(grep "define('FOG_VERSION'" $system_file | sed "s/.*FOG_VERSION', '\([^']*\)');/\1/") + echo 'create the tag and release...' + gh release create $tag --latest --generate-notes --target stable + echo 'sync dev-branch with stable branch (merge stable into dev-branch)...' + # git config core.hooksPath .githooks #custom githooks not working in github runner + gh pr create -B dev-branch -H stable --title "merge stable - ${tag} into dev" --body "Pull Request for syncing stable release commit back to dev after a release" + gh pr merge stable --merge --subject "merge stable - ${tag} into dev"; env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # on merge of monthly release pr # get/calculate current version # create tag of current version # create release of new tag # generate release notes -# send announcements? +# send announcements? \ No newline at end of file