Skip to content
Merged
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
119 changes: 81 additions & 38 deletions .github/workflows/release-tool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,88 +6,131 @@ on:
version:
description: 'New version number (e.g., v2.2.0)'
required: true
type: string

jobs:
create-target-release-branch:
name: create target release branch
validate-and-prepare:
name: Validate Version and Prepare Variables
runs-on: ubuntu-latest
outputs:
release_branch: ${{ steps.set-branch.outputs.branch }}
version_without_v: ${{ steps.set-version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Validate version format
run: |
if ! [[ ${{ github.event.inputs.version }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version format. Please use vX.Y.Z"
exit 1
fi

- name: Set up Git
- name: Set version without 'v' prefix
id: set-version
run: |
git config user.name "GitHub Actions Bot"
git config user.email "actions@github.com"
VERSION="${{ github.event.inputs.version }}"
VERSION_WITHOUT_V="${VERSION#v}"
echo "version=${VERSION_WITHOUT_V}" >> $GITHUB_OUTPUT

- name: Create release branch
- name: Set branch name
id: set-branch
run: |
git checkout -b release-${{ github.event.inputs.version }}
git push --set-upstream origin release-${{ github.event.inputs.version }}
create-work-release-branch:
VERSION="${{ github.event.inputs.version }}"
VERSION_WITHOUT_V="${VERSION#v}"
if [[ $VERSION_WITHOUT_V =~ ^([0-9]+\.[0-9]+)\.0$ ]]; then
# If version ends with .0, use X.Y format
BRANCH="release-${BASH_REMATCH[1]}"
else
# Otherwise use full X.Y.Z format
BRANCH="release-${VERSION_WITHOUT_V}"
fi
echo "branch=${BRANCH}" >> $GITHUB_OUTPUT

create-branches:
name: Create Release Branches
needs: validate-and-prepare
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Git
- name: Configure Git
run: |
git config user.name "GitHub Actions Bot"
git config user.email "actions@github.com"

- name: Create release branch
- name: Create target release branch
run: |
git checkout -b release-${{ github.event.inputs.version }}-work
git push --set-upstream origin release-${{ github.event.inputs.version }}-work
git checkout -b ${{ needs.validate-and-prepare.outputs.release_branch }}
git push --set-upstream origin ${{ needs.validate-and-prepare.outputs.release_branch }}

create-release-pr:
name: create release pr
- name: Create work branch
run: |
git checkout -b ${{ needs.validate-and-prepare.outputs.release_branch }}-work
git push --set-upstream origin ${{ needs.validate-and-prepare.outputs.release_branch }}-work

update-versions:
name: Update Version References
needs: [validate-and-prepare, create-branches]
runs-on: ubuntu-latest
needs: [create-target-release-branch, create-work-release-branch]
if: always()
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: release-${{ github.event.inputs.version }}-work
ref: ${{ needs.validate-and-prepare.outputs.release_branch }}-work

- name: Set up Git
- name: Configure Git
run: |
git config user.name "GitHub Actions Bot"
git config user.email "actions@github.com"

- name: Update version in manifests
run: |
sed -i 's/fluent-operator:latest/fluent-operator:${{ github.event.inputs.version }}/' manifests/setup/fluent-operator-deployment.yaml
sed -i 's/fluent-operator:latest/fluent-operator:${{ github.event.inputs.version }}/' manifests/setup/setup.yaml

- name: Update version in values.yaml
- name: Update manifest files
run: |
sed -i '/repository: "kubesphere\/fluent-operator"/!b;n;s/tag: "latest"/tag: "${{ github.event.inputs.version }}"/' charts/fluent-operator/values.yaml
# Update deployment manifests
files=(
"manifests/setup/fluent-operator-deployment.yaml"
"manifests/setup/setup.yaml"
)
for file in "${files[@]}"; do
if [ -f "$file" ]; then
sed -i 's/fluent-operator:latest/fluent-operator:v${{ needs.validate-and-prepare.outputs.version_without_v }}/' "$file"
else
echo "Warning: File $file not found"
exit 1
fi
done

- name: Update version
- name: Update Helm chart values
run: |
echo ${{ github.event.inputs.version }} > VERSION
if [ -f "charts/fluent-operator/values.yaml" ]; then
sed -i '/repository: "kubesphere\/fluent-operator"/!b;n;s/tag: "latest"/tag: "v${{ needs.validate-and-prepare.outputs.version_without_v }}"/' charts/fluent-operator/values.yaml
else
echo "Error: values.yaml not found"
exit 1
fi

- name: Commit & Push changes
- name: Update VERSION file
run: |
git add manifests/setup/fluent-operator-deployment.yaml manifests/setup/setup.yaml charts/fluent-operator/values.yaml VERSION
git commit -m "Bump version to ${{ github.event.inputs.version }}"
echo "v${{ needs.validate-and-prepare.outputs.version_without_v }}" > VERSION

- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
title: "Release ${{ github.event.inputs.version }}"
commit-message: "Bump version to v${{ needs.validate-and-prepare.outputs.version_without_v }}"
signoff: true
title: "Release v${{ needs.validate-and-prepare.outputs.version_without_v }}"
body: |
This PR updates the version to ${{ github.event.inputs.version }} in the following files:
## Release v${{ needs.validate-and-prepare.outputs.version_without_v }}

This PR updates version references for the v${{ needs.validate-and-prepare.outputs.version_without_v }} release.

### Changes
The following files have been updated:
- manifests/setup/fluent-operator-deployment.yaml
- manifests/setup/setup.yaml
- charts/fluent-operator/values.yaml
- VERSION

Please review and merge to release the new version.
branch: release-${{ github.event.inputs.version }}-work
base: release-${{ github.event.inputs.version }}
Please review the changes carefully before merging.
branch: ${{ needs.validate-and-prepare.outputs.release_branch }}-work
base: ${{ needs.validate-and-prepare.outputs.release_branch }}
labels: |
release