4
4
push :
5
5
branches :
6
6
- main
7
+ pull_request :
8
+ types : [opened, synchronize, reopened, closed]
9
+ branches :
10
+ - main
7
11
8
12
concurrency :
9
13
group : release
@@ -24,27 +28,42 @@ jobs:
24
28
manifest-file : " .github/prerelease-manifest.json"
25
29
fork : false
26
30
token : ${{ secrets.GITHUB_TOKEN }}
27
-
31
+
32
+ update-manifest-in-pr :
33
+ runs-on : ubuntu-latest
34
+ needs : release-please
35
+ # Only run when a release PR is opened or updated, not when it's merged
36
+ if : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref == 'release-please--branches--main' && github.event.pull_request.closed == false }}
37
+ steps :
28
38
- name : Checkout PR branch
29
- if : ${{ steps.release.outputs.pr }}
30
39
uses : actions/checkout@v4
31
40
with :
32
- ref : release-please--branches--main
41
+ ref : ${{ github.event.pull_request.head.ref }}
33
42
token : ${{ secrets.GITHUB_TOKEN }}
34
-
35
- - name : Update prerelease manifest
36
- if : ${{ steps.release.outputs.pr }}
43
+
44
+ - name : Extract new version
45
+ id : extract-version
46
+ run : |
47
+ PR_TITLE="${{ github.event.pull_request.title }}"
48
+ if [[ $PR_TITLE =~ chore\(main\):[[:space:]]release[[:space:]]([0-9]+\.[0-9]+\.[0-9]+) ]]; then
49
+ echo "version=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT
50
+ else
51
+ echo "version=" >> $GITHUB_OUTPUT
52
+ fi
53
+
54
+ - name : Update prerelease manifest with new version
55
+ if : ${{ steps.extract-version.outputs.version != '' }}
37
56
env :
38
57
MANIFEST_PATH : .github/prerelease-manifest.json
39
- RELEASE_TAG : ${{ steps.release .outputs.tag_name }}
58
+ VERSION : ${{ steps.extract-version .outputs.version }}
40
59
run : |
41
- jq --arg tag "${RELEASE_TAG//v/} " '.["."] = $tag' $MANIFEST_PATH > temp.json \
60
+ jq --arg tag "$VERSION " '.["."] = $tag' $MANIFEST_PATH > temp.json \
42
61
&& mv temp.json $MANIFEST_PATH
43
62
44
63
git config user.name "github-actions[bot]"
45
64
git config user.email "github-actions[bot]@users.noreply.github.com"
46
65
git add $MANIFEST_PATH
47
- git commit -m "chore: sync release manifests "
66
+ git commit -m "chore: update prerelease manifest with version $VERSION "
48
67
git push
49
68
50
69
deploy-test :
@@ -97,6 +116,35 @@ jobs:
97
116
98
117
- name : Deploy
99
118
run : echo "Deploying to production!"
119
+
120
+ sync-after-release :
121
+ name : Sync Release Manifest
122
+ runs-on : ubuntu-latest
123
+ # Only run when a release is created and PR is merged (push to main)
124
+ if : ${{ github.event_name == 'push' && needs.release-please.outputs.releases_created == 'true' }}
125
+ needs : release-please
126
+ steps :
127
+ - name : Checkout main branch
128
+ uses : actions/checkout@v4
129
+ with :
130
+ token : ${{ secrets.RELEASE_TOKEN }} # Use a token with repo scope
131
+
132
+ - name : Update prerelease manifest
133
+ env :
134
+ MANIFEST_PATH : .github/prerelease-manifest.json
135
+ RELEASE_TAG : ${{ needs.release-please.outputs.tag_name }}
136
+ run : |
137
+ # Remove the 'v' prefix if present
138
+ VERSION="${RELEASE_TAG//v/}"
139
+
140
+ jq --arg tag "$VERSION" '.["."] = $tag' $MANIFEST_PATH > temp.json \
141
+ && mv temp.json $MANIFEST_PATH
142
+
143
+ git config user.name "github-actions[bot]"
144
+ git config user.email "github-actions[bot]@users.noreply.github.com"
145
+ git add $MANIFEST_PATH
146
+ git commit -m "chore: sync prerelease manifest with version $VERSION"
147
+ git push
100
148
101
149
publish :
102
150
name : Publish images
0 commit comments