Skip to content

Commit 0c2f14b

Browse files
use only one PR when running outer release action
1 parent cf6886c commit 0c2f14b

File tree

6 files changed

+125
-10
lines changed

6 files changed

+125
-10
lines changed

.github/actions/bump-build-version/action.yaml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,29 @@ runs:
4545
echo "New buildVersion in ${{ steps.filepath.outputs.build-config-file }} is ${{ steps.bump-version.outputs.new_version }}"
4646
shell: bash
4747

48+
- name: Get current branch
49+
id: current-branch
50+
run: |
51+
echo "branch=$(git branch --show-current)" >> $GITHUB_OUTPUT
52+
shell: bash
53+
4854
- name: Add and commit new build version
4955
if: ${{ inputs.commit == 'true' }}
5056
uses: EndBug/add-and-commit@v9
5157
with:
5258
message: "Update ${{ steps.filepath.outputs.build-config-file }} buildVersion to ${{ steps.bump-version.outputs.new_version }} [skip ci]"
53-
new_branch: release/${{ inputs.platform }}-${{ steps.bump-version.outputs.new_version }}
59+
pull: ${{ steps.current-branch.outputs.branch != format('build/{0}', inputs.platform) && format('origin {0}', steps.current-branch.outputs.branch) || '' }}
60+
push: --set-upstream origin ${{ steps.current-branch.outputs.branch }}
5461

5562
- name: Raise PR and merge
5663
if: ${{ inputs.commit == 'true' }}
5764
run: |
58-
gh pr create --base main --head release/${{ inputs.platform }}-${{ steps.bump-version.outputs.new_version }} --title "Update ${{ steps.filepath.outputs.build-config-file }} buildVersion to ${{ steps.bump-version.outputs.new_version }}" --body "Increment version"
59-
gh pr merge --merge --delete-branch release/${{ inputs.platform }}-${{ steps.bump-version.outputs.new_version }}
65+
CURRENT_BRANCH=${{ steps.current-branch.outputs.branch }}
66+
if [[ $CURRENT_BRANCH == build/* ]]
67+
then
68+
gh pr create --base main --head $CURRENT_BRANCH --title "Update ${{ inputs.platform }} build version to ${{ steps.bump-version.outputs.new_version }}" --body "Increment version"
69+
gh pr merge --merge --delete-branch $CURRENT_BRANCH
70+
fi
6071
env:
6172
GITHUB_TOKEN: ${{ inputs.token }}
6273
shell: bash

.github/workflows/cd-release-dmg.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ on:
1313
description: Github Release Version Number
1414
required: true
1515
type: string
16+
via-call:
17+
description: Determines if this workflow was called by another workflow
18+
required: false
19+
default: true
20+
type: boolean
21+
22+
env:
23+
VIA_CALL: ${{ inputs.via-call || false }}
1624

1725
jobs:
1826
build-dmg:
@@ -107,7 +115,23 @@ jobs:
107115
group: commit-build-version
108116
cancel-in-progress: false
109117
steps:
118+
- name: Get branch to checkout
119+
id: branch-to-update
120+
env:
121+
EVENT_NAME: ${{ github.event_name }}
122+
run: |
123+
if [[ ${{ env.VIA_CALL }} == 'true' ]]; then
124+
echo "branch=release/${{ inputs.release-version }}" >> $GITHUB_OUTPUT
125+
else
126+
echo "branch=build/dmg" >> $GITHUB_OUTPUT
127+
fi
128+
110129
- uses: actions/checkout@v3
130+
with:
131+
fetch-depth: 0
132+
133+
- name: Checkout correct branch
134+
run: git switch -C ${{ steps.branch-to-update.outputs.branch }}
111135

112136
- uses: ./.github/actions/bump-build-version
113137
with:

.github/workflows/cd-release-linux.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ on:
1313
description: Github Release Version Number
1414
required: true
1515
type: string
16+
via-call:
17+
description: Determines if this workflow was called by another workflow
18+
required: false
19+
default: true
20+
type: boolean
21+
22+
env:
23+
VIA_CALL: ${{ inputs.via-call || false }}
1624

1725
jobs:
1826
build-linux:
@@ -73,7 +81,23 @@ jobs:
7381
group: commit-build-version
7482
cancel-in-progress: false
7583
steps:
84+
- name: Get branch to checkout
85+
id: branch-to-update
86+
env:
87+
EVENT_NAME: ${{ github.event_name }}
88+
run: |
89+
if [[ ${{ env.VIA_CALL }} == 'true' ]]; then
90+
echo "branch=release/${{ inputs.release-version }}" >> $GITHUB_OUTPUT
91+
else
92+
echo "branch=build/linux" >> $GITHUB_OUTPUT
93+
fi
94+
7695
- uses: actions/checkout@v3
96+
with:
97+
fetch-depth: 0
98+
99+
- name: Checkout correct branch
100+
run: git switch -C ${{ steps.branch-to-update.outputs.branch }}
77101

78102
- uses: ./.github/actions/bump-build-version
79103
with:

.github/workflows/cd-release-mas.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ on:
1313
description: Github Release Version Number
1414
required: true
1515
type: string
16+
via-call:
17+
description: Determines if this workflow was called by another workflow
18+
required: false
19+
default: true
20+
type: boolean
21+
22+
env:
23+
VIA_CALL: ${{ inputs.via-call || false }}
1624

1725
jobs:
1826
build-mas:
@@ -100,7 +108,23 @@ jobs:
100108
group: commit-build-version
101109
cancel-in-progress: false
102110
steps:
111+
- name: Get branch to checkout
112+
id: branch-to-update
113+
env:
114+
EVENT_NAME: ${{ github.event_name }}
115+
run: |
116+
if [[ ${{ env.VIA_CALL }} == 'true' ]]; then
117+
echo "branch=release/${{ inputs.release-version }}" >> $GITHUB_OUTPUT
118+
else
119+
echo "branch=build/mas" >> $GITHUB_OUTPUT
120+
fi
121+
103122
- uses: actions/checkout@v3
123+
with:
124+
fetch-depth: 0
125+
126+
- name: Checkout correct branch
127+
run: git switch -C ${{ steps.branch-to-update.outputs.branch }}
104128

105129
- uses: ./.github/actions/bump-build-version
106130
with:

.github/workflows/cd-release-windows.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ on:
1313
description: Github Release Version Number
1414
required: true
1515
type: string
16+
via-call:
17+
description: Determines if this workflow was called by another workflow
18+
required: false
19+
default: true
20+
type: boolean
21+
22+
env:
23+
VIA_CALL: ${{ inputs.via-call || false }}
1624

1725
jobs:
1826
build-windows:
@@ -85,7 +93,21 @@ jobs:
8593
group: commit-build-version
8694
cancel-in-progress: false
8795
steps:
96+
- name: Get branch to checkout
97+
id: branch-to-update
98+
run: |
99+
if [[ ${{ env.VIA_CALL }} == 'true' ]]; then
100+
echo "branch=release/${{ inputs.release-version }}" >> $GITHUB_OUTPUT
101+
else
102+
echo "branch=build/win" >> $GITHUB_OUTPUT
103+
fi
104+
88105
- uses: actions/checkout@v3
106+
with:
107+
fetch-depth: 0
108+
109+
- name: Checkout correct branch
110+
run: git switch -C ${{ steps.branch-to-update.outputs.branch }}
89111

90112
- uses: ./.github/actions/bump-build-version
91113
with:

.github/workflows/cd-release.yaml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,6 @@ jobs:
5050
message: "Update web/package.json version to ${{ needs.format-version.outputs.version }} [skip ci]"
5151
new_branch: release/${{ needs.format-version.outputs.version }}
5252

53-
- name: Raise PR and merge
54-
run: |
55-
gh pr create --base main --head release/${{ needs.format-version.outputs.version }} --title "Update web/package.json version to ${{ needs.format-version.outputs.version }}" --body "Increment version"
56-
gh pr merge --merge --delete-branch release/${{ needs.format-version.outputs.version }}
57-
env:
58-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59-
6053
- name: Create Release
6154
id: create_release
6255
uses: dolthub/create-release@v1
@@ -119,3 +112,20 @@ jobs:
119112
with:
120113
release-version: ${{ needs.create-release.outputs.release_version }}
121114

115+
create-pr-and-merge:
116+
name: Create PR and merge
117+
needs: [create-release, build-mas, build-windows, build-dmg, build-linux]
118+
if: ${{ always() && needs.create-release.result == 'success' && !cancelled() }}
119+
runs-on: ubuntu-22.04
120+
steps:
121+
- uses: actions/checkout@v3
122+
123+
- name: Create PR and merge
124+
run: |
125+
gh pr create --base main --head release/${{ needs.create-release.outputs.release_version }} --title "Update versions for release ${{ needs.create-release.outputs.release_version }}" --body "Increment versions"
126+
gh pr merge --merge --delete-branch release/${{ needs.create-release.outputs.release_version }}
127+
env:
128+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
129+
130+
131+

0 commit comments

Comments
 (0)