Skip to content

Commit

Permalink
Automated Releases of stable revisions #601 - Update workflows with t…
Browse files Browse the repository at this point in the history
…ested 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.
  • Loading branch information
darksidemilk committed Aug 8, 2024
1 parent 914cdd4 commit bd21398
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 15 deletions.
13 changes: 11 additions & 2 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -50,14 +50,23 @@ 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
lastrevision=${tagversion##*.} # Extracts the last segment
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"
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/stable-releases-1_pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
26 changes: 21 additions & 5 deletions .github/workflows/stable-releases-2_test-validity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand All @@ -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
25 changes: 19 additions & 6 deletions .github/workflows/stable-releases-3_tag-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <tag> --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?

0 comments on commit bd21398

Please sign in to comment.