Skip to content

Commit 9db6a53

Browse files
authored
fix(workflow): 🐛 updated release workflow (#870)
1 parent 42e51ce commit 9db6a53

File tree

4 files changed

+65
-212
lines changed

4 files changed

+65
-212
lines changed

.github/workflows/release.yml

Lines changed: 18 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,15 @@ env:
2727
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
2828

2929
jobs:
30-
prepare:
30+
release:
3131
runs-on: ubuntu-latest
3232

33-
outputs:
34-
new-version: ${{ steps.version.outputs.version }}
35-
old-version: ${{ steps.old_version.outputs.previous_version }}
36-
changelog: ${{ steps.changelog.outputs.changes }}
37-
3833
steps:
3934
- name: Check out Git repository
4035
uses: actions/checkout@v4
4136
with:
4237
fetch-depth: 0
38+
token: ${{ env.PUSH_TOKEN }}
4339

4440
- uses: pnpm/action-setup@v4
4541

@@ -49,66 +45,6 @@ jobs:
4945
node-version: 18
5046
cache: 'pnpm'
5147

52-
- name: Install dependencies
53-
run: pnpm i
54-
55-
- name: Get the previous version
56-
id: old_version
57-
run: |
58-
export PRE_RELEASE=${{ inputs.pre-release }}
59-
if $PRE_RELEASE ; then
60-
export MVN_OLD_VERSION=$(git describe --tags $(git rev-list --tags --max-count=1))
61-
echo "previous_version=${MVN_OLD_VERSION:1}" >> $GITHUB_OUTPUT
62-
else
63-
export MVN_OLD_VERSION=$(node -pe "require('./package.json').version")
64-
echo "previous_version=${MVN_OLD_VERSION}" >> $GITHUB_OUTPUT
65-
fi
66-
67-
- name: Update pre-release version
68-
if: ${{ inputs.pre-release }}
69-
run: pnpm prerelease:${{ inputs.release-type }}
70-
71-
- name: Update release version
72-
if: ${{ ! inputs.pre-release }}
73-
run: pnpm release:${{ inputs.release-type }}
74-
75-
- name: Get the new version
76-
id: version
77-
run: |
78-
export MVN_VERSION=$(node -pe "require('./website/package.json').version")
79-
echo "version=$MVN_VERSION" >> $GITHUB_OUTPUT
80-
81-
- name: Generate Change log
82-
if: ${{ steps.version.outputs.version != null }}
83-
id: changelog
84-
run: |
85-
export CHANGELOG=$(pnpm --silent changelog --from v${{ steps.old_version.outputs.previous_version }} --next-version v${{ steps.version.outputs.version }})
86-
delimiter="$(openssl rand -hex 8)"
87-
echo "changes<<${delimiter}" >> "${GITHUB_OUTPUT}"
88-
echo "$CHANGELOG" >> "${GITHUB_OUTPUT}"
89-
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
90-
91-
- name: Print Changelog
92-
run: echo "${{ steps.changelog.outputs.changes }}"
93-
94-
- name: Upload updated version related files to artifacts
95-
uses: actions/upload-artifact@v4
96-
with:
97-
name: version-files-${{ github.run_id }}
98-
retention-days: 1
99-
path: |
100-
${{ github.workspace }}/lerna.json
101-
${{ github.workspace }}/website/package.json
102-
103-
release:
104-
runs-on: ubuntu-latest
105-
needs:
106-
- prepare
107-
108-
steps:
109-
- name: Check out Git repository
110-
uses: actions/checkout@v4
111-
11248
- name: Install Java and Maven
11349
uses: actions/setup-java@v4
11450
with:
@@ -122,8 +58,21 @@ jobs:
12258
path: ~/.m2/repository
12359
key: ${{ runner.os }}-maven-${{ github.sha }}
12460

125-
- name: Maven command to update release version
126-
run: mvn build-helper:parse-version versions:set -f core-java/pom.xml -DnewVersion=${{ needs.prepare.outputs.new-version }} versions:commit
61+
- name: Set Git Config
62+
run: |
63+
git config user.name "${GITHUB_ACTOR}"
64+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
65+
66+
- name: Install dependencies
67+
run: pnpm i
68+
69+
- name: Update pre-release version
70+
if: ${{ inputs.pre-release }}
71+
run: pnpm release:pre${{ inputs.release-type }}
72+
73+
- name: Update release version
74+
if: ${{ ! inputs.pre-release }}
75+
run: pnpm release:${{ inputs.release-type }}
12776

12877
- name: Release package to Maven central
12978
uses: WasiqB/maven-publish-action@v2
@@ -138,70 +87,6 @@ jobs:
13887
directory: ${{ github.workspace }}/core-java
13988
maven_args: -DskipTests -Dcheckstyle.skip
14089

141-
- name: Build the project JAR files
142-
run: mvn clean install -f core-java/pom.xml -DskipTests -Dcheckstyle.skip
143-
144-
- name: Upload target folder
145-
uses: actions/upload-artifact@v4
146-
with:
147-
name: target-${{ github.run_id }}
148-
retention-days: 1
149-
path: |
150-
${{ github.workspace }}/core-java/target
151-
152-
- name: Upload version files folder
153-
uses: actions/upload-artifact@v4
154-
with:
155-
name: version-pom-files-${{ github.run_id }}
156-
retention-days: 1
157-
path: ${{ github.workspace }}/core-java/pom.xml
158-
159-
push-pom:
160-
runs-on: ubuntu-latest
161-
needs:
162-
- prepare
163-
- release
164-
165-
steps:
166-
- name: Check out Git repository
167-
uses: actions/checkout@v4
168-
with:
169-
token: ${{ env.PUSH_TOKEN }}
170-
171-
- name: Download Version files
172-
uses: actions/download-artifact@v4
173-
with:
174-
name: version-files-${{ github.run_id }}
175-
176-
- name: Download Version pom files
177-
uses: actions/download-artifact@v4
178-
with:
179-
name: version-pom-files-${{ github.run_id }}
180-
path: ${{ github.workspace }}/core-java
181-
182-
- name: Update new version in README and Usage
183-
uses: jacobtomlinson/gha-find-replace@v3
184-
if: ${{ ! inputs.pre-release }}
185-
with:
186-
find: ${{ needs.prepare.outputs.old-version }}
187-
replace: ${{ needs.prepare.outputs.new-version }}
188-
include: |
189-
${{ github.workspace }}/README.md
190-
${{ github.workspace }}/website/docs/framework-docs/getting-started/usage.md
191-
192-
- name: Update new version in package.json
193-
uses: jacobtomlinson/gha-find-replace@v3
194-
if: ${{ ! inputs.pre-release }}
195-
with:
196-
find: '"version": "${{ needs.prepare.outputs.old-version }}"'
197-
replace: '"version": "${{ needs.prepare.outputs.new-version }}"'
198-
include: |
199-
${{ github.workspace }}/package.json
200-
201-
- name: Update Changelog file for v${{ needs.prepare.outputs.new-version }}
202-
run: |
203-
echo "${{ needs.prepare.outputs.changelog }}" > CHANGELOG.md
204-
20590
- name: Import GPG key
20691
uses: crazy-max/ghaction-import-gpg@v6
20792
with:
@@ -214,46 +99,7 @@ jobs:
21499
uses: EndBug/add-and-commit@v9
215100
with:
216101
message: |
217-
chore(Internal): :bookmark: released v${{ needs.prepare.outputs.new-version }} to maven central
102+
chore(Internal): :bookmark: released new version to maven central
218103
push: true
219104
default_author: user_info
220105
commit: --no-verify
221-
222-
github:
223-
runs-on: ubuntu-latest
224-
needs:
225-
- prepare
226-
- push-pom
227-
228-
steps:
229-
- name: Check out Git repository
230-
uses: actions/checkout@v4
231-
with:
232-
fetch-depth: 0
233-
234-
- name: Download target folder
235-
uses: actions/download-artifact@v4
236-
with:
237-
name: target-${{ github.run_id }}
238-
path: ${{ github.workspace }}/core-java/target
239-
240-
- name: Download Version files
241-
uses: actions/download-artifact@v4
242-
with:
243-
name: version-files-${{ github.run_id }}
244-
245-
- name: Create GitHub Release
246-
uses: softprops/action-gh-release@v2
247-
env:
248-
GITHUB_TOKEN: ${{ env.PUSH_TOKEN }}
249-
GITHUB_REPOSITORY: ${{ github.repository }}
250-
with:
251-
tag_name: v${{ needs.prepare.outputs.new-version }}
252-
name: Version ${{ needs.prepare.outputs.new-version }}
253-
prerelease: ${{ inputs.pre-release }}
254-
draft: false
255-
body: ${{ needs.prepare.outputs.changelog }}
256-
discussion_category_name: Announcements
257-
generate_release_notes: false
258-
files: |
259-
core-java/target/*.jar

.release-it.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,18 @@
1616
"github": {
1717
"release": true,
1818
"tokenRef": "PUSH_TOKEN",
19+
"assets": ["core-java/target/*.jar"],
1920
"comments": {
2021
"submit": true,
2122
"issue": ":rocket: _This issue has been resolved in v${version}. See [${releaseName}](${releaseUrl}) for release notes._",
2223
"pr": ":rocket: _This pull request is included in v${version}. See [${releaseName}](${releaseUrl}) for release notes._"
2324
}
2425
},
26+
"hooks": {
27+
"after:bump": [
28+
"mvn build-helper:parse-version versions:set -f core-java/pom.xml -DnewVersion=${version} versions:commit",
29+
"mvn clean install -f core-java/pom.xml -DskipTests -Dcheckstyle.skip"
30+
]
31+
},
2532
"npm": false
2633
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"@commitlint/config-conventional": "^19.2.2",
3434
"@lerna/child-process": "^7.4.2",
3535
"@release-it-plugins/lerna-changelog": "^7.0.0",
36-
"@types/node": "^20.14.12",
36+
"@types/node": "^22.0.0",
3737
"@typescript-eslint/eslint-plugin": "^7.17.0",
3838
"@typescript-eslint/parser": "^7.17.0",
3939
"commitlint": "^19.3.0",

0 commit comments

Comments
 (0)