Skip to content

Commit 0c22f34

Browse files
committed
Push release to a branch due to branch protection rules
1 parent 0f2e59d commit 0c22f34

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

.github/workflows/release.yml

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ env:
3333
jobs:
3434
version:
3535
runs-on: ubuntu-latest
36-
outputs:
37-
HEAD: ${{ steps.version.outputs.HEAD }}
38-
RELEASE_VERSION: ${{ steps.version.outputs.RELEASE_VERSION }}
39-
PLAIN_VERSION: ${{ steps.version.outputs.PLAIN_VERSION }}
40-
NEXT_VERSION: ${{ steps.version.outputs.NEXT_VERSION }}
4136
steps:
4237
- uses: actions/checkout@v3
4338

@@ -51,6 +46,7 @@ jobs:
5146
- name: Set release version
5247
id: version
5348
run: |
49+
BRANCH="moditect-${{ github.event.inputs.version }}"
5450
RELEASE_VERSION=${{ github.event.inputs.version }}
5551
NEXT_VERSION=${{ github.event.inputs.next }}
5652
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:
5955
then
6056
NEXT_VERSION=$COMPUTED_NEXT_VERSION
6157
fi
58+
git checkout -b $BRANCH
6259
./mvnw -ntp -B versions:set versions:commit -DnewVersion=$RELEASE_VERSION -pl :moditect-parent
6360
git config --global user.email "[email protected]"
6461
git config --global user.name "moditect-release-bot"
6562
git commit -a -m "Releasing version $VERSION"
66-
git push origin HEAD:main
67-
HEAD=$(git rev-parse HEAD)
68-
echo "HEAD=$HEAD" >> $GITHUB_OUTPUT
69-
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT
70-
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_OUTPUT
71-
echo "PLAIN_VERSION=$PLAIN_VERSION" >> $GITHUB_OUTPUT
63+
git push origin $BRANCH
64+
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
65+
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
66+
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV
67+
echo "PLAIN_VERSION=$PLAIN_VERSION" >> $GITHUB_ENV
7268
7369
release:
7470
needs: [ version ]
@@ -77,7 +73,7 @@ jobs:
7773
- name: Checkout
7874
uses: actions/checkout@v3
7975
with:
80-
ref: ${{ needs.version.outputs.HEAD }}
76+
ref: ${{ env.BRANCH }}
8177
fetch-depth: 0
8278

8379
- name: Setup Java
@@ -106,6 +102,7 @@ jobs:
106102
- name: Release to GitHub
107103
env:
108104
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105+
JRELEASER_BRANCH: ${{ env.BRANCH }}
109106
run: |
110107
./mvnw -B --file pom.xml -pl :moditect-parent -Pjreleaser jreleaser:release
111108
@@ -119,11 +116,9 @@ jobs:
119116
parent/target/jreleaser/output.properties
120117
121118
- name: Set next version
122-
env:
123-
NEXT_VERSION: ${{ needs.version.outputs.NEXT_VERSION }}
124119
run: |
125-
./mvnw -ntp -B versions:set versions:commit -DnewVersion=$NEXT_VERSION -pl :moditect-parent
120+
./mvnw -ntp -B versions:set versions:commit -DnewVersion=${{ env.NEXT_VERSION }} -pl :moditect-parent
126121
git config --global user.email "[email protected]"
127122
git config --global user.name "moditect-release-bot"
128-
git commit -a -m "Next version $NEXT_VERSION"
129-
git push origin HEAD:main
123+
git commit -a -m "Next version ${{ env.NEXT_VERSION }}"
124+
git push origin ${{ env.BRANCH }}

parent/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
<plugin>
179179
<groupId>org.jreleaser</groupId>
180180
<artifactId>jreleaser-maven-plugin</artifactId>
181-
<version>1.5.0</version>
181+
<version>1.6.0</version>
182182
<inherited>false</inherited>
183183
<configuration>
184184
<gitRootSearch>true</gitRootSearch>

0 commit comments

Comments
 (0)