Create New Stable Branch #9
This file contains 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 New Stable Branch | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Create new branch | |
env: | |
ENVIRONMENT: CI | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.RH_PERF_BOT_TOKEN }} | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'adopt' | |
java-version: 17 | |
- name: install yq | |
run: wget https://github.com/mikefarah/yq/releases/download/v4.2.0/yq_linux_amd64 -O ~/yq && chmod +x ~/yq | |
- name: Maven Version | |
run: mvn --version | |
# Retrieve current version from the root pom | |
- name: Get version | |
run: | | |
PROJECT_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:3.4.0:evaluate -Dexpression=project.version -q -DforceStdout) | |
echo PROJECT_VERSION=${PROJECT_VERSION} >> $GITHUB_ENV | |
echo CUR_VERSION=$(echo ${PROJECT_VERSION} | awk -F'.' '{print $1"."$2+0"."$3}' | sed s/[.]$//) >> $GITHUB_ENV | |
echo NEXT_VERSION=$(echo ${PROJECT_VERSION} | awk -F'.' '{print $1"."$2+1}' | sed s/[.]$//) >> $GITHUB_ENV | |
- name: Create branch ${{ env.CUR_VERSION }} | |
run: git branch ${{ env.CUR_VERSION }} master | |
- name: Bump next version ${{ env.NEXT_VERSION }}-SNAPSHOT | |
run: mvn -B -ntp versions:set -DnewVersion=${{ env.NEXT_VERSION }}-SNAPSHOT | |
- name: Set major version ${{ env.NEXT_VERSION }} | |
run: mvn -B -ntp versions:set-property -Dproperty=major-version -DnewVersion=${{ env.NEXT_VERSION }} | |
- name: Update main workflow | |
run: ~/yq -i e '.on.push.branches |= [ "master", '${{ env.CUR_VERSION }}' ]' .github/workflows/main.yml | |
- name: Update release branch | |
run: ~/yq -i e '.env.RELEASE_BRANCH |= '${{ env.NEXT_VERSION }} .github/workflows/release.yml | |
- name: Update Notify clients workflow | |
run: ~/yq -i e '.on.push.branches |= [ "master", '${{ env.CUR_VERSION }}' ]' .github/workflows/notify-clients.yaml | |
- name: Update backport workflow | |
run: ~/yq -i e '.jobs.backporting.steps[1].with.target-branch |= '${{ env.CUR_VERSION }} .github/workflows/backport.yml | |
- name: build new openapi.yaml | |
run: mvn -B -ntp clean package -DskipTests -DskipITs -pl horreum-api | |
- name: Configure git | |
run: | | |
git config --global user.name "rh-appservices-perf" | |
git config --global user.email "rh-appservices-perf@users.noreply.github.com" | |
- name: Commit main branch changes | |
run: | | |
git commit -a -m "Next is ${{ env.NEXT_VERSION }}" | |
- name: Update cur branch | |
run: | | |
git checkout ${{ env.CUR_VERSION }} | |
mvn -B -ntp versions:set -DnewVersion=${{ env.CUR_VERSION }}.0-SNAPSHOT | |
- name: Commit current release branch | |
run: | | |
git commit -a -m "Branching ${{ env.CUR_VERSION }}" | |
- name: push branches | |
run: | | |
git push origin ${{ env.CUR_VERSION }} | |
git push origin master |