|
| 1 | +name: Create Release PR |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + bump_type: |
| 7 | + description: "Type of version bump to apply" |
| 8 | + required: true |
| 9 | + type: choice |
| 10 | + options: |
| 11 | + - patch |
| 12 | + - minor |
| 13 | + - major |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: create-release-pr |
| 17 | + cancel-in-progress: false |
| 18 | + |
| 19 | +jobs: |
| 20 | + create-release-pr: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + permissions: |
| 23 | + contents: write |
| 24 | + pull-requests: write |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Generate GitHub App token |
| 28 | + id: generate_token |
| 29 | + uses: actions/create-github-app-token@v2 |
| 30 | + with: |
| 31 | + app-id: ${{ secrets.RELEASE_APP_ID }} |
| 32 | + private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} |
| 33 | + owner: sourcebot-dev |
| 34 | + repositories: sourcebot-helm-chart |
| 35 | + |
| 36 | + - name: Checkout repository |
| 37 | + uses: actions/checkout@v4 |
| 38 | + with: |
| 39 | + token: ${{ steps.generate_token.outputs.token }} |
| 40 | + |
| 41 | + - name: Setup Node.js |
| 42 | + uses: actions/setup-node@v4 |
| 43 | + with: |
| 44 | + node-version: '22' |
| 45 | + |
| 46 | + - name: Install semver |
| 47 | + run: npm install -g semver |
| 48 | + |
| 49 | + - name: Calculate new version |
| 50 | + id: calculate_version |
| 51 | + run: | |
| 52 | + CURRENT_VERSION=$(grep '^version:' charts/sourcebot/Chart.yaml | cut -d ' ' -f 2) |
| 53 | + echo "Current chart version: $CURRENT_VERSION" |
| 54 | +
|
| 55 | + NEW_VERSION=$(semver -i ${{ inputs.bump_type }} $CURRENT_VERSION) |
| 56 | + echo "New chart version: $NEW_VERSION" |
| 57 | +
|
| 58 | + echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT |
| 59 | + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT |
| 60 | +
|
| 61 | + - name: Check if version already exists |
| 62 | + run: | |
| 63 | + VERSION=${{ steps.calculate_version.outputs.new_version }} |
| 64 | + if grep -q "## \[$VERSION\]" CHANGELOG.md; then |
| 65 | + echo "Error: Version $VERSION already exists in CHANGELOG.md" |
| 66 | + exit 1 |
| 67 | + fi |
| 68 | +
|
| 69 | + - name: Update Chart.yaml version |
| 70 | + run: | |
| 71 | + sed -i "s/^version: .*/version: ${{ steps.calculate_version.outputs.new_version }}/" charts/sourcebot/Chart.yaml |
| 72 | +
|
| 73 | + - name: Update CHANGELOG.md |
| 74 | + run: | |
| 75 | + VERSION=${{ steps.calculate_version.outputs.new_version }} |
| 76 | + DATE=$(date +%Y-%m-%d) |
| 77 | +
|
| 78 | + # Insert the new version header after the [Unreleased] line |
| 79 | + sed -i "/## \[Unreleased\]/a\\ |
| 80 | + \\ |
| 81 | + ## [$VERSION] - $DATE" CHANGELOG.md |
| 82 | +
|
| 83 | + echo "Updated CHANGELOG.md with version $VERSION" |
| 84 | + cat CHANGELOG.md | head -n 20 |
| 85 | +
|
| 86 | + - name: Install helm-docs |
| 87 | + run: | |
| 88 | + cd /tmp |
| 89 | + curl -L https://github.com/norwoodj/helm-docs/releases/download/v1.14.2/helm-docs_1.14.2_Linux_x86_64.tar.gz | tar xz |
| 90 | + sudo mv helm-docs /usr/local/bin/ |
| 91 | +
|
| 92 | + - name: Update README.md |
| 93 | + run: | |
| 94 | + cd charts/sourcebot |
| 95 | + helm-docs |
| 96 | +
|
| 97 | + - name: Create Pull Request |
| 98 | + uses: peter-evans/create-pull-request@v8 |
| 99 | + with: |
| 100 | + token: ${{ steps.generate_token.outputs.token }} |
| 101 | + commit-message: | |
| 102 | + chore: release chart v${{ steps.calculate_version.outputs.new_version }} |
| 103 | +
|
| 104 | + - Bump chart version from ${{ steps.calculate_version.outputs.current_version }} to ${{ steps.calculate_version.outputs.new_version }} |
| 105 | + - Update CHANGELOG.md |
| 106 | + - Update generated documentation |
| 107 | + title: "chore: release chart v${{ steps.calculate_version.outputs.new_version }}" |
| 108 | + body: | |
| 109 | + ## Summary |
| 110 | + Release chart version ${{ steps.calculate_version.outputs.new_version }} (${{ inputs.bump_type }} bump). |
| 111 | +
|
| 112 | + ## Changes |
| 113 | + - 📦 Bump chart version from ${{ steps.calculate_version.outputs.current_version }} to ${{ steps.calculate_version.outputs.new_version }} |
| 114 | + - 📝 Update CHANGELOG.md |
| 115 | + - 📝 Update generated documentation |
| 116 | +
|
| 117 | + --- |
| 118 | + **Bump type**: `${{ inputs.bump_type }}` |
| 119 | + branch: release-chart-v${{ steps.calculate_version.outputs.new_version }} |
| 120 | + delete-branch: true |
| 121 | + reviewers: | |
| 122 | + brendan-kellam |
| 123 | + msukkari |
| 124 | + labels: | |
| 125 | + release |
0 commit comments