Skip to content

Commit 3611538

Browse files
committed
Update Release Workflow
1 parent a1bd400 commit 3611538

2 files changed

Lines changed: 44 additions & 5 deletions

File tree

.github/workflows/checkstyle.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Run Checkstyle
22

33
on:
44
push:
5+
pull_request_target:
6+
branches: [ master ]
57

68
jobs:
79
run_checkstyle:
@@ -12,7 +14,7 @@ jobs:
1214
- uses: actions/checkout@v3
1315

1416
- name: Set up Java 16
15-
uses: actions/setup-java@v2
17+
uses: actions/setup-java@v3
1618
with:
1719
java-version: '16'
1820
distribution: 'adopt'

.github/workflows/release.yml

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ on:
55
branches: [ master ]
66

77
jobs:
8-
release:
8+
Prepare-and-Release:
9+
name: Prepare and Release
910
runs-on: ubuntu-latest
1011

1112
steps:
1213
- name: Checkout
1314
uses: actions/checkout@v3
1415

1516
- name: Set up Java 16
16-
uses: actions/setup-java@v2
17+
uses: actions/setup-java@v3
1718
with:
1819
java-version: '16'
1920
distribution: 'adopt'
@@ -25,12 +26,48 @@ jobs:
2526
git config --global committer.name "GitHub Release Workflow"
2627
git config --global author.email "${GITHUB_ACTOR}@users.noreply.github.com"
2728
git config --global author.name "${GITHUB_ACTOR}"
29+
2830
- name: Get Maven version
2931
run: |
3032
export MAVEN_VERSION=$( mvn help:evaluate -Dexpression=project.version -q -DforceStdout | sed "s/-SNAPSHOT$//" )
3133
echo "Retreived Maven Version: $MAVEN_VERSION"
3234
echo "MAVEN_VERSION=$MAVEN_VERSION" >> $GITHUB_ENV
33-
- name: Release Maven Artifact
35+
36+
- name: Prepare & Release Maven Artifact
3437
env:
3538
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36-
run: mvn -B release:prepare release:perform
39+
run: |
40+
git checkout -B "MiSim-${{env.MAVEN_VERSION}}"
41+
mvn -B release:prepare release:perform
42+
git clean -f
43+
44+
- name: Create Pull Request to Master
45+
id: open-pr
46+
uses: repo-sync/pull-request@v2
47+
with:
48+
source_branch: "MiSim-${{env.MAVEN_VERSION}}"
49+
pr_title: "Prepare Release ${{env.MAVEN_VERSION}}"
50+
pr_body: "This pull request updates the MiSim pom for version ${{env.MAVEN_VERSION}} and prepares the next Snapshot.<br>It will be merged automatically."
51+
# pr_assignee: "LitschiW"
52+
pr_allow_empty: false
53+
pr_label: "automerge"
54+
github_token: ${{ secrets.PUBLISHER_TOKEN }}
55+
56+
- name: Automerge Pull Request
57+
id: automerge
58+
env:
59+
PULL_REQUEST: ${{steps.open-pr.outputs.pr_number}}
60+
MERGE_COMMIT_MESSAGE: 'Update to ${{env.MAVEN_VERSION}} and prepare next SNAPSHOT'
61+
MERGE_DELETE_BRANCH: true
62+
MERGE_RETRIES: 5
63+
MERGE_RETRY_SLEEP: '60000'
64+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
65+
uses: "pascalgn/automerge-action@v0.15.5"
66+
67+
- name: Check Merge Result
68+
if: ${{ steps.automerge.outputs.mergeResult != 'merged' }}
69+
run: |
70+
echo "Merge of Pull Request ${{steps.open-pr.outputs.pr_number}} failed."
71+
echo "Expected state 'merged', but found '${{steps.automerge.outputs.mergeResult}}'."
72+
echo "See ${{steps.open-pr.outputs.pr_url}} for further info."
73+
exit 1

0 commit comments

Comments
 (0)