Create Release Pull Request #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Create Release Pull Request | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'New version number (e.g., v2.2.0)' | |
| required: true | |
| type: string | |
| jobs: | |
| 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: 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 version without 'v' prefix | |
| id: set-version | |
| run: | | |
| VERSION="${{ github.event.inputs.version }}" | |
| VERSION_WITHOUT_V="${VERSION#v}" | |
| echo "version=${VERSION_WITHOUT_V}" >> $GITHUB_OUTPUT | |
| - name: Set branch name | |
| id: set-branch | |
| run: | | |
| 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: Configure Git | |
| run: | | |
| git config user.name "GitHub Actions Bot" | |
| git config user.email "actions@github.com" | |
| - name: Create target release branch | |
| run: | | |
| git checkout -b ${{ needs.validate-and-prepare.outputs.release_branch }} | |
| git push --set-upstream origin ${{ needs.validate-and-prepare.outputs.release_branch }} | |
| - 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 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.validate-and-prepare.outputs.release_branch }}-work | |
| - name: Configure Git | |
| run: | | |
| git config user.name "GitHub Actions Bot" | |
| git config user.email "actions@github.com" | |
| - name: Update manifest files | |
| run: | | |
| # 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 Helm chart values | |
| run: | | |
| 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: Update VERSION file | |
| run: | | |
| echo "v${{ needs.validate-and-prepare.outputs.version_without_v }}" > VERSION | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| 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: | | |
| ## 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 the changes carefully before merging. | |
| branch: ${{ needs.validate-and-prepare.outputs.release_branch }}-work | |
| base: ${{ needs.validate-and-prepare.outputs.release_branch }} | |
| labels: | | |
| release |