Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push release to a branch due to branch protection rules #196

Merged
merged 1 commit into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 12 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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