Skip to content

Commit

Permalink
Push release to a branch due to branch protection rules
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed May 3, 2023
1 parent 0f2e59d commit 0c22f34
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
29 changes: 12 additions & 17 deletions .github/workflows/release.yml
Expand Up @@ -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

Expand All @@ -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); }'`
Expand All @@ -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 ]
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 }}
2 changes: 1 addition & 1 deletion parent/pom.xml
Expand Up @@ -178,7 +178,7 @@
<plugin>
<groupId>org.jreleaser</groupId>
<artifactId>jreleaser-maven-plugin</artifactId>
<version>1.5.0</version>
<version>1.6.0</version>
<inherited>false</inherited>
<configuration>
<gitRootSearch>true</gitRootSearch>
Expand Down

0 comments on commit 0c22f34

Please sign in to comment.