|
| 1 | +name: Bump Version |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + new_version: |
| 7 | + description: 'New version to bump to (e.g., 3.7.0)' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + create_pr: |
| 11 | + description: 'Create a pull request with the changes' |
| 12 | + required: false |
| 13 | + type: boolean |
| 14 | + default: true |
| 15 | + |
| 16 | +jobs: |
| 17 | + bump-version: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout repository |
| 22 | + uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 25 | + fetch-depth: 0 |
| 26 | + |
| 27 | + - name: Setup Git |
| 28 | + run: | |
| 29 | + git config --local user.email "[email protected]" |
| 30 | + git config --local user.name "Kondal Kolipaka" |
| 31 | +
|
| 32 | + - name: Validate and get current version |
| 33 | + id: version |
| 34 | + run: | |
| 35 | + if [[ ! "${{ github.event.inputs.new_version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 36 | + echo "Error: Version must be in format X.Y.Z (e.g., 3.7.0)" |
| 37 | + exit 1 |
| 38 | + fi |
| 39 | + |
| 40 | + CURRENT_VERSION=$(grep -o 'espressif-ide-release-version>[^<]*' releng/com.espressif.idf.configuration/pom.xml | cut -d'>' -f2) |
| 41 | + echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT |
| 42 | + echo "new=${{ github.event.inputs.new_version }}" >> $GITHUB_OUTPUT |
| 43 | + echo "Current: $CURRENT_VERSION → New: ${{ github.event.inputs.new_version }}" |
| 44 | +
|
| 45 | + - name: Update version in files |
| 46 | + run: | |
| 47 | + CURRENT_VERSION="${{ steps.version.outputs.current }}" |
| 48 | + NEW_VERSION="${{ steps.version.outputs.new }}" |
| 49 | + |
| 50 | + sed -i "s/Bundle-Version: ${CURRENT_VERSION}\.qualifier/Bundle-Version: ${NEW_VERSION}.qualifier/g" bundles/com.espressif.idf.branding/META-INF/MANIFEST.MF |
| 51 | + sed -i "s/version=\"${CURRENT_VERSION}\.qualifier\"/version=\"${NEW_VERSION}.qualifier\"/g" features/com.espressif.idf.feature/feature.xml |
| 52 | + sed -i "s/<espressif-ide-release-version>${CURRENT_VERSION}<\/espressif-ide-release-version>/<espressif-ide-release-version>${NEW_VERSION}<\/espressif-ide-release-version>/g" releng/com.espressif.idf.configuration/pom.xml |
| 53 | + sed -i "s/version=\"${CURRENT_VERSION}\"/version=\"${NEW_VERSION}\"/g" releng/com.espressif.idf.product/idf.product |
| 54 | +
|
| 55 | + - name: Verify changes |
| 56 | + run: | |
| 57 | + NEW_VERSION="${{ steps.version.outputs.new }}" |
| 58 | + |
| 59 | + for file in "bundles/com.espressif.idf.branding/META-INF/MANIFEST.MF:Bundle-Version: ${NEW_VERSION}.qualifier" \ |
| 60 | + "features/com.espressif.idf.feature/feature.xml:version=\"${NEW_VERSION}.qualifier\"" \ |
| 61 | + "releng/com.espressif.idf.configuration/pom.xml:<espressif-ide-release-version>${NEW_VERSION}</espressif-ide-release-version>" \ |
| 62 | + "releng/com.espressif.idf.product/idf.product:version=\"${NEW_VERSION}\""; do |
| 63 | + IFS=':' read -r filepath pattern <<< "$file" |
| 64 | + if ! grep -q "$pattern" "$filepath"; then |
| 65 | + echo "✗ Failed to update $filepath" |
| 66 | + exit 1 |
| 67 | + fi |
| 68 | + echo "✓ Updated $filepath" |
| 69 | + done |
| 70 | +
|
| 71 | + - name: Create Pull Request |
| 72 | + if: github.event.inputs.create_pr == 'true' |
| 73 | + run: | |
| 74 | + NEW_VERSION="${{ steps.version.outputs.new }}" |
| 75 | + BRANCH_NAME="bump-version-${NEW_VERSION}" |
| 76 | + |
| 77 | + git checkout -b "$BRANCH_NAME" |
| 78 | + git add bundles/com.espressif.idf.branding/META-INF/MANIFEST.MF features/com.espressif.idf.feature/feature.xml releng/com.espressif.idf.configuration/pom.xml releng/com.espressif.idf.product/idf.product |
| 79 | + git commit -m "chore: bump version to v${NEW_VERSION} |
| 80 | +
|
| 81 | + - Updated Bundle-Version in MANIFEST.MF |
| 82 | + - Updated version in feature.xml |
| 83 | + - Updated espressif-ide-release-version in pom.xml |
| 84 | + - Updated version in idf.product |
| 85 | + |
| 86 | + Automated by GitHub Actions workflow" |
| 87 | + |
| 88 | + git push origin "$BRANCH_NAME" |
| 89 | + |
| 90 | + gh pr create \ |
| 91 | + --title "chore: bump version to v${NEW_VERSION}" \ |
| 92 | + --body "This PR automatically bumps the version to v${NEW_VERSION}. |
| 93 | +
|
| 94 | + **Files updated:** |
| 95 | + - \`bundles/com.espressif.idf.branding/META-INF/MANIFEST.MF\` |
| 96 | + - \`features/com.espressif.idf.feature/feature.xml\` |
| 97 | + - \`releng/com.espressif.idf.configuration/pom.xml\` |
| 98 | + - \`releng/com.espressif.idf.product/idf.product\` |
| 99 | +
|
| 100 | + **Changes:** |
| 101 | + - Bundle-Version: \`${NEW_VERSION}.qualifier\` |
| 102 | + - Feature version: \`${NEW_VERSION}.qualifier\` |
| 103 | + - Release version: \`${NEW_VERSION}\` |
| 104 | + - Product version: \`${NEW_VERSION}\` |
| 105 | +
|
| 106 | + This PR was created automatically by the GitHub Actions workflow." \ |
| 107 | + --head "$BRANCH_NAME" \ |
| 108 | + --base "master" |
| 109 | + env: |
| 110 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 111 | + |
| 112 | + - name: Commit directly to master |
| 113 | + if: github.event.inputs.create_pr == 'false' |
| 114 | + run: | |
| 115 | + NEW_VERSION="${{ steps.version.outputs.new }}" |
| 116 | + |
| 117 | + git add bundles/com.espressif.idf.branding/META-INF/MANIFEST.MF features/com.espressif.idf.feature/feature.xml releng/com.espressif.idf.configuration/pom.xml releng/com.espressif.idf.product/idf.product |
| 118 | + git commit -m "chore: bump version to v${NEW_VERSION} |
| 119 | +
|
| 120 | + - Updated Bundle-Version in MANIFEST.MF |
| 121 | + - Updated version in feature.xml |
| 122 | + - Updated espressif-ide-release-version in pom.xml |
| 123 | + - Updated version in idf.product |
| 124 | + |
| 125 | + Automated by GitHub Actions workflow" |
| 126 | + |
| 127 | + git push origin master |
0 commit comments