As a follow up to the semantic versioning tutorial/intro, here's how DreamStack utilizes automated release branch management on certain projects.
To automate the process of cutting a release branch every Friday at 3pm EST from the latest develop
branch, you can use GitHub Actions. The following is a step-by-step guide on how to set this up:
Step 1: Create a New GitHub Action Workflow
In your repository, create a new file under .github/workflows
directory, say cut_release_branch.yml
.
Step 2: Define the Workflow
In the cut_release_branch.yml
file, paste the following workflow:
name: Cut Release Branch
on:
schedule:
# This schedule is in UTC, 3pm EST is 7pm UTC during daylight saving time and 8pm UTC otherwise.
# Adjust accordingly if needed.
- cron: '0 19 * * 5'
jobs:
cut_release:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Configure Git
run: |
git config --global user.name 'GitHub Actions Bot'
git config --global user.email 'actions@github.com'
- name: Cut Release Branch
run: |
# Assuming versioning format is x.y.z and you want to bump the z part.
# Adjust accordingly if your versioning is different.
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
NEW_TAG=${LATEST_TAG%.*}.$((${LATEST_TAG##*.} + 1))
git checkout develop
git checkout -b release/$NEW_TAG
git push origin release/$NEW_TAG
- name: Print New Release Branch
run: echo "New release branch is release/$NEW_TAG"
Step 3: Commit and Push the Workflow
After adding the workflow file, commit and push it to your repository:
git add .github/workflows/cut_release_branch.yml
git commit -m "Add GitHub Action to cut release branch"
git push origin main # or your default branch name if it's not 'main'
Step 4: Monitoring the Action
After pushing the action, you can monitor its progress directly from the GitHub web interface. Go to the "Actions" tab of your repository. Here you will see a list of all the workflow runs. The workflow should trigger every Friday at 3pm EST.
Please note that the above script assumes:
- Your versioning format is
x.y.z
. - You want to bump the
z
part for the release branch. - Your development branch is named
develop
.
Adjustments might be needed based on the specifics of your project.