Skip to content

Commit

Permalink
Merge pull request #53 from a5r0n/add-ci-version-bump
Browse files Browse the repository at this point in the history
ci: Add workflow to automate chart version bump & release
  • Loading branch information
a5r0n authored Oct 17, 2024
2 parents e43aef6 + 191ae1c commit 758e7ff
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 1 deletion.
70 changes: 70 additions & 0 deletions .github/workflows/ci-version-bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: CI Version Bump

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
version-bump:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install semver
run: |
pip install semver
- name: Bump version
id: bump-version
run: |
CURRENT_VERSION=$(grep -oP '^version: \K.*' n8n/Chart.yaml)
N8N_VERSION=$(grep -oP '^appVersion: "\K.*(?=")' n8n/Chart.yaml)
TEMPLATE_CHANGED=$(git diff --name-only HEAD~1 HEAD | grep -E 'n8n/templates/.*\.yaml' || true)
if [[ $TEMPLATE_CHANGED ]]; then
NEW_VERSION=$(python -c "import semver; print(semver.VersionInfo.parse('$CURRENT_VERSION').bump_minor())")
else
NEW_VERSION=$(python -c "import semver; print(semver.VersionInfo.parse('$CURRENT_VERSION').bump_patch())")
fi
echo "New version: $NEW_VERSION"
sed -i "s/^version: .*/version: $NEW_VERSION/" n8n/Chart.yaml
echo "::set-output name=NEW_VERSION::$NEW_VERSION"
- name: Commit changes
if: github.ref == 'refs/heads/main'
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add n8n/Chart.yaml
git commit -m "ci: bump chart version to $NEW_VERSION"
git push
- name: Create release
if: github.ref == 'refs/heads/main'
uses: actions/create-release@v1
with:
tag_name: ${{ steps.bump-version.outputs.NEW_VERSION }}
release_name: Release ${{ steps.bump-version.outputs.NEW_VERSION }}
body: |
Automated release for version ${{ steps.bump-version.outputs.NEW_VERSION }}
draft: false
prerelease: false

- name: Comment on PR
if: github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v3
with:
comment_tag: next_version
message: |
Next version to publish after this PR is merged: `${{ steps.bump-version.outputs.NEW_VERSION }}`
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,24 @@ ingress:
```
see [values.yaml](./n8n/values.yaml)
## CI Version Bump Workflow
A new workflow has been added to automate chart version bump and release. The workflow is defined in the `.github/workflows/ci-version-bump.yml` file and performs the following actions:

* Bumps patch version on n8n major/minor and patch for n8n patch versions.
* Bumps minor version for template changes.
* Only pushes version changes on main branch runs.
* Comments on the next version to publish after a PR merge.

The workflow is triggered on push and pull request events to the `main` branch. It performs the following steps:

1. Checks out the code.
2. Sets up Python environment.
3. Installs `python semver`.
4. Bumps the chart version based on changes.
5. Commits the changes.
6. Creates a release.
7. Comments on the next version to publish after a PR merge.

The version bumping is done for the Helm chart version, not for a Node.js package.
18 changes: 17 additions & 1 deletion renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,21 @@
]
}
],
"bumpVersion": "patch"
"bumpVersion": "patch",
"packageRules": [
{
"matchDatasources": ["docker"],
"matchPackageNames": ["ghcr.io/n8n-io/n8n"],
"versioning": "semver",
"bumpVersion": "patch"
},
{
"matchPaths": ["n8n/templates/**/*.yaml"],
"bumpVersion": "minor"
},
{
"matchPaths": ["n8n/Chart.yaml"],
"bumpVersion": "patch"
}
]
}

0 comments on commit 758e7ff

Please sign in to comment.