Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 32 additions & 10 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ jobs:

steps:
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0 # ensure the full history is fetched so we can compare changes

- uses: azure/setup-helm@v4
with:
Expand All @@ -34,21 +36,41 @@ jobs:
echo "Labels: $LABELS"
if echo "$LABELS" | grep -q "release-apply"; then
echo "Label 'release-apply' found."
echo "release_apply=true" >>$GITHUB_OUTPUT
# PRs with label "release-label" are created at the end of this workflow and we don't want infinite loops
echo "The pull request is merged and has the 'release-apply' label. Nothing to do. Exiting with success"
echo "continue=false" >>$GITHUB_OUTPUT
exit 0
else
echo "Label 'release-apply' not found."
echo "release_apply=false" >>$GITHUB_OUTPUT
echo "continue=true" >>$GITHUB_OUTPUT
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: early exit if release-apply is not present
if: steps.check_label.outputs.release_apply == 'true'
- name: check for changes in helm-chart directory
id: check_changes
run: |
echo "The pull request is merged and has the 'release-apply' label. Exiting with success"
exit 0
# fetch all
git fetch -all

# get the base commit (before the merge)
BASE_COMMIT=$(git merge-base HEAD origin/main)

# get the list of files changed in the pull request
CHANGED_FILES=$(git diff --name-only $BASE_COMMIT HEAD)

# check if any files in the helm-chart/ directory have changed
if echo "$CHANGED_FILES" | grep -q "^helm-chart/"; then
echo "Changes detected in the helm-chart/ directory."
echo "continue=true" >> $GITHUB_OUTPUT
else
echo "No changes detected in the helm-chart/ directory. Exiting."
echo "continue=false" >> $GITHUB_OUTPUT
exit 0
fi

- name: determine version increment
if: steps.check_label.outputs.continue == 'true' && steps.check_changes.outputs.continue == 'true'
id: determine-version
run: |
PR_TITLE=$(echo "${{ github.event.pull_request.title }}" | tr '[:upper:]' '[:lower:]')
Expand Down Expand Up @@ -128,10 +150,10 @@ jobs:
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'release eoapi chart to ${{ env.new_version }}'
title: 'release for ${{ github.ref }}@${{ github.sha }}'
commit-message: 'release eoapi chart to v${{ env.new_version }}'
title: 'release v${{ env.new_version }} for ${{ github.ref }}@${{ github.sha }}'
body: |
this PR contains the version bumps for the eoapi chart ${{ env.new_version }}
this PR contains the version bumps for the eoapi chart v${{ env.new_version }}
base: main
branch: apply-${{ github.head_ref }}
labels: release-apply
36 changes: 36 additions & 0 deletions docs/release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
### Release Workflow

1. PRs that include changes in the `helm-chart/` directory with a base of `main` should also choose a PR
title that decides if the chart's version bumps will be major, minor or patch according to semantic versioning.
All they need to do is prefix `major: `, `minor: ` or `patch: ` to the PR title


2. All PRs merged against the base `main` will kick off a "pre-release" workflow that does the following:

1. detect if there are changes in the `helm-chart/` directory and if not the "pre-release.yaml" workflow exits gracefully

2. sniff the PR title to determine major, minor or patch bumps

3. increment the helm chart's `version` and `appVersion` accordingly

4. create a new PR with these changes with a title called
`'release ${{ env.new_version }} for ${{ github.ref }}@${{ github.sha }}'` and body listing the new chart version


4. The releaser should find this PR, review and merge accordingly


5. Then the releaser should go to the Github release UI/UX and kick off a new release by doing the following:

1. click "Draft New Release"

2. create a new tag for the branch `main` with the chart version listed in the previous PR's body and title

3. click the "Generate release notes"

4. review the release notes and clean up

5. click the "Publish release"

6. This last step then kicks off another workflow called "release.yaml" which publishes the helm chart to the
`gh-pages` branch
79 changes: 0 additions & 79 deletions helm-chart/eoapi/CHANGELOG.md

This file was deleted.