From aa0391949f0f3eafab1e3d81371009b35338c17f Mon Sep 17 00:00:00 2001 From: Andres Almiray Date: Wed, 3 May 2023 08:55:59 +0200 Subject: [PATCH] Push release to a branch due to branch protection rules --- .github/workflows/release.yml | 29 ++++++++++++----------------- parent/pom.xml | 2 +- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 920446c..0dee36b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,11 +33,6 @@ env: jobs: version: runs-on: ubuntu-latest - outputs: - HEAD: ${{ steps.version.outputs.HEAD }} - RELEASE_VERSION: ${{ steps.version.outputs.RELEASE_VERSION }} - PLAIN_VERSION: ${{ steps.version.outputs.PLAIN_VERSION }} - NEXT_VERSION: ${{ steps.version.outputs.NEXT_VERSION }} steps: - uses: actions/checkout@v3 @@ -51,6 +46,7 @@ jobs: - name: Set release version id: version run: | + BRANCH="moditect-${{ github.event.inputs.version }}" RELEASE_VERSION=${{ github.event.inputs.version }} NEXT_VERSION=${{ github.event.inputs.next }} PLAIN_VERSION=`echo ${RELEASE_VERSION} | awk 'match($0, /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)/) { print substr($0, RSTART, RLENGTH); }'` @@ -59,16 +55,16 @@ jobs: then NEXT_VERSION=$COMPUTED_NEXT_VERSION fi + git checkout -b $BRANCH ./mvnw -ntp -B versions:set versions:commit -DnewVersion=$RELEASE_VERSION -pl :moditect-parent git config --global user.email "moditect-release-bot@moditect.org" git config --global user.name "moditect-release-bot" git commit -a -m "Releasing version $VERSION" - git push origin HEAD:main - HEAD=$(git rev-parse HEAD) - echo "HEAD=$HEAD" >> $GITHUB_OUTPUT - echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT - echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_OUTPUT - echo "PLAIN_VERSION=$PLAIN_VERSION" >> $GITHUB_OUTPUT + git push origin $BRANCH + echo "BRANCH=$BRANCH" >> $GITHUB_ENV + echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV + echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV + echo "PLAIN_VERSION=$PLAIN_VERSION" >> $GITHUB_ENV release: needs: [ version ] @@ -77,7 +73,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 with: - ref: ${{ needs.version.outputs.HEAD }} + ref: ${{ env.BRANCH }} fetch-depth: 0 - name: Setup Java @@ -106,6 +102,7 @@ jobs: - name: Release to GitHub env: JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + JRELEASER_BRANCH: ${{ env.BRANCH }} run: | ./mvnw -B --file pom.xml -pl :moditect-parent -Pjreleaser jreleaser:release @@ -119,11 +116,9 @@ jobs: parent/target/jreleaser/output.properties - name: Set next version - env: - NEXT_VERSION: ${{ needs.version.outputs.NEXT_VERSION }} run: | - ./mvnw -ntp -B versions:set versions:commit -DnewVersion=$NEXT_VERSION -pl :moditect-parent + ./mvnw -ntp -B versions:set versions:commit -DnewVersion=${{ env.NEXT_VERSION }} -pl :moditect-parent git config --global user.email "moditect-release-bot@moditect.org" git config --global user.name "moditect-release-bot" - git commit -a -m "Next version $NEXT_VERSION" - git push origin HEAD:main + git commit -a -m "Next version ${{ env.NEXT_VERSION }}" + git push origin ${{ env.BRANCH }} diff --git a/parent/pom.xml b/parent/pom.xml index 9ebc2ad..6b6dd8e 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -178,7 +178,7 @@ org.jreleaser jreleaser-maven-plugin - 1.5.0 + 1.6.0 false true