Skip to content

Commit 4324f46

Browse files
authored
chore(Internal): 🔖 new release (#475)
2 parents 9667d59 + a1d83b8 commit 4324f46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2648
-1633
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ root = true
44
end_of_line = lf
55
insert_final_newline = true
66

7-
[*.{js,json,yml}]
7+
[*.{ts,js,json,yml}]
88
charset = utf-8
99
indent_style = space
1010
indent_size = 2

.github/workflows/_create-pr.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Common Create PR workflow
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
source-branch:
7+
type: string
8+
description: Source Branch
9+
required: true
10+
target-branch:
11+
type: string
12+
description: Target Branch
13+
required: true
14+
title:
15+
type: string
16+
description: PR Title
17+
required: true
18+
is-feature:
19+
type: boolean
20+
description: Is this PR from a feature branch
21+
default: false
22+
secrets:
23+
token:
24+
required: true
25+
26+
jobs:
27+
create-pr:
28+
runs-on: ubuntu-latest
29+
name: Create pull request from ${{ inputs.source-branch }} to ${{ inputs.target-branch }}
30+
steps:
31+
- name: Check out Git repository
32+
uses: actions/checkout@v3
33+
34+
- name: Detect changes between ${{ inputs.source-branch }} and ${{ inputs.target-branch }}
35+
id: branch-changes
36+
uses: fjenik/[email protected]
37+
with:
38+
repo-token: ${{ secrets.token }}
39+
target-branch: ${{ inputs.target-branch }}
40+
source-branch: ${{ inputs.source-branch }}
41+
42+
- name: Detect changes output
43+
run: echo "Output of detect changes ${{ steps.branch-changes.outputs.is-source-branch-ahead }}"
44+
45+
- name: Check if pr already exists
46+
id: pr-exists
47+
if: steps.branch-changes.outputs.is-source-branch-ahead == 'true'
48+
uses: fjenik/[email protected]
49+
with:
50+
repo-token: ${{ secrets.token }}
51+
target-branch: ${{ inputs.target-branch }}
52+
source-branch: ${{ inputs.source-branch }}
53+
54+
- name: Print output
55+
run: echo "Output of pull request already exists ${{ steps.pr-exists.outputs.is-pr-already-created }}"
56+
57+
- name: Create pull request
58+
if: |
59+
steps.pr-exists.outputs.is-pr-already-created == 'false' &&
60+
inputs.is-feature == false
61+
uses: repo-sync/pull-request@v2
62+
with:
63+
github_token: ${{ secrets.token }}
64+
source_branch: ${{ inputs.source-branch }}
65+
destination_branch: ${{ inputs.target-branch }}
66+
pr_reviewer: boyka-core
67+
pr_title: ${{ inputs.title }}
68+
pr_draft: true
69+
pr_body: |
70+
_This PR was generated via github actions workflow_
71+
72+
**Don't squash merge this PR**
73+
74+
- name: Create feature pull request
75+
if: |
76+
steps.pr-exists.outputs.is-pr-already-created == 'false' &&
77+
inputs.is-feature
78+
uses: repo-sync/pull-request@v2
79+
with:
80+
github_token: ${{ secrets.token }}
81+
source_branch: ${{ inputs.source-branch }}
82+
destination_branch: ${{ inputs.target-branch }}
83+
pr_reviewer: boyka-core
84+
pr_title: ${{ inputs.title }}
85+
pr_template: '.github/pull_request_template.md'
86+
pr_draft: true

.github/workflows/_release.yml

Lines changed: 294 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,294 @@
1+
name: Common Release workflow for boyka-framework
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
node-version:
7+
type: string
8+
description: Node JS version
9+
default: 16
10+
java-version:
11+
type: string
12+
description: Java version
13+
default: 11
14+
pre-release:
15+
type: boolean
16+
description: Whether the release is pre-release?
17+
default: true
18+
secrets:
19+
pushToken:
20+
required: true
21+
gpgKey:
22+
required: true
23+
gpgPass:
24+
required: true
25+
nexusUser:
26+
required: true
27+
nexusPass:
28+
required: true
29+
30+
env:
31+
GITHUB_AUTH: ${{ secrets.pushToken }}
32+
PUSH_TOKEN: ${{ secrets.pushToken }}
33+
GPG_PRIVATE_KEY: ${{ secrets.gpgKey }}
34+
GPG_PASSPHRASE: ${{ secrets.gpgPass }}
35+
NEXUS_USERNAME: ${{ secrets.nexusUser }}
36+
NEXUS_PASSWORD: ${{ secrets.nexusPass }}
37+
38+
jobs:
39+
prepare:
40+
runs-on: ubuntu-latest
41+
42+
outputs:
43+
new-version: ${{ steps.version.outputs.version }}
44+
old-version: ${{ steps.old_version.outputs.previous_version }}
45+
46+
steps:
47+
- name: Check out Git repository
48+
uses: actions/checkout@v3
49+
with:
50+
fetch-depth: 0
51+
52+
- name: Setup Node v16
53+
uses: actions/setup-node@v3
54+
with:
55+
node-version: ${{ inputs.node-version }}
56+
cache: 'yarn'
57+
58+
- name: Install dependencies
59+
run: yarn install
60+
61+
- name: Get the previous version
62+
id: old_version
63+
run: |
64+
export PRE_RELEASE=${{ inputs.pre-release }}
65+
if $PRE_RELEASE ; then
66+
export MVN_OLD_VERSION=$(git describe --tags $(git rev-list --tags --max-count=1))
67+
echo "previous_version=${MVN_OLD_VERSION:1}" >> $GITHUB_OUTPUT
68+
else
69+
export MVN_OLD_VERSION=$(node -pe "require('./package.json').version")
70+
echo "previous_version=${MVN_OLD_VERSION}" >> $GITHUB_OUTPUT
71+
fi
72+
73+
- name: Update pre-release version
74+
if: inputs.pre-release
75+
run: yarn prerelease
76+
77+
- name: Update release version
78+
if: inputs.pre-release == false
79+
run: yarn release
80+
81+
- name: Get the new version
82+
id: version
83+
run: |
84+
export MVN_VERSION=$(node -pe "require('./website/package.json').version")
85+
echo "version=$MVN_VERSION" >> $GITHUB_OUTPUT
86+
87+
- name: Generate Change log
88+
if: steps.version.outputs.version != null
89+
run: |
90+
yarn changelog --from v${{ steps.old_version.outputs.previous_version }} --next-version v${{ steps.version.outputs.version }} > CHANGELOG.md
91+
92+
- name: Upload updated version related files to artifacts
93+
uses: actions/upload-artifact@v3
94+
with:
95+
name: version-files
96+
retention-days: 1
97+
path: |
98+
${{ github.workspace }}/CHANGELOG.md
99+
${{ github.workspace }}/lerna.json
100+
${{ github.workspace }}/website/package.json
101+
102+
release-snapshot:
103+
runs-on: ubuntu-latest
104+
needs: prepare
105+
if: needs.prepare.outputs.new-version != null
106+
steps:
107+
- name: Check out Git repository
108+
uses: actions/checkout@v3
109+
110+
- name: Install Java and Maven
111+
uses: actions/setup-java@v3
112+
with:
113+
java-version: ${{ inputs.java-version }}
114+
distribution: 'adopt'
115+
116+
- name: Restore local Maven repository
117+
uses: actions/cache@v3
118+
with:
119+
path: ~/.m2/repository
120+
key: ${{ runner.os }}-maven-${{ github.sha }}
121+
122+
- name: Maven command to update snapshot version
123+
run: mvn build-helper:parse-version versions:set -f core-java/pom.xml -DnewVersion=${{ needs.prepare.outputs.new-version }}-SNAPSHOT versions:commit
124+
125+
- name: Release snapshot to Maven central
126+
uses: samuelmeuli/action-maven-publish@v1
127+
with:
128+
gpg_private_key: ${{ secrets.gpgKey }}
129+
gpg_passphrase: ${{ secrets.gpgPass }}
130+
nexus_username: ${{ secrets.nexusUser }}
131+
nexus_password: ${{ secrets.nexusPass }}
132+
maven_profiles: release
133+
server_id: ossrh
134+
maven_args: --settings ${{ github.workspace }}/core-java/setting/settings.xml -f core-java/pom.xml -DskipTests -Dcheckstyle.skip -B
135+
136+
release:
137+
runs-on: ubuntu-latest
138+
needs:
139+
- prepare
140+
- release-snapshot
141+
142+
steps:
143+
- name: Check out Git repository
144+
uses: actions/checkout@v3
145+
146+
- name: Install Java and Maven
147+
uses: actions/setup-java@v3
148+
with:
149+
java-version: ${{ inputs.java-version }}
150+
distribution: 'adopt'
151+
152+
- name: Restore local Maven repository
153+
uses: actions/cache@v3
154+
with:
155+
path: ~/.m2/repository
156+
key: ${{ runner.os }}-maven-${{ github.sha }}
157+
158+
- name: Maven command to update release version
159+
run: mvn build-helper:parse-version versions:set -f core-java/pom.xml -DnewVersion=${{ needs.prepare.outputs.new-version }} versions:commit
160+
161+
- name: Release to Maven central
162+
uses: samuelmeuli/action-maven-publish@v1
163+
with:
164+
gpg_private_key: ${{ secrets.gpgKey }}
165+
gpg_passphrase: ${{ secrets.gpgPass }}
166+
nexus_username: ${{ secrets.nexusUser }}
167+
nexus_password: ${{ secrets.nexusPass }}
168+
maven_profiles: release
169+
server_id: ossrh
170+
maven_args: --settings ${{ github.workspace }}/core-java/setting/settings.xml -f core-java/pom.xml -DskipTests -Dcheckstyle.skip -B
171+
172+
- name: Build the project JAR files
173+
run: mvn clean install -f core-java/pom.xml -DskipTests -Dcheckstyle.skip
174+
175+
- name: Upload target folder
176+
uses: actions/upload-artifact@v3
177+
with:
178+
name: target
179+
retention-days: 1
180+
path: |
181+
${{ github.workspace }}/core-java/target
182+
183+
- name: Upload version files folder
184+
uses: actions/upload-artifact@v3
185+
with:
186+
name: version-files
187+
retention-days: 1
188+
path: |
189+
${{ github.workspace }}/core-java/pom.xml
190+
${{ github.workspace }}/CHANGELOG.md
191+
${{ github.workspace }}/lerna.json
192+
${{ github.workspace }}/website/package.json
193+
194+
push-pom:
195+
runs-on: ubuntu-latest
196+
needs:
197+
- prepare
198+
- release
199+
200+
steps:
201+
- name: Check out Git repository
202+
uses: actions/checkout@v3
203+
with:
204+
token: ${{ secrets.pushToken }}
205+
206+
- name: Download Version files
207+
uses: actions/download-artifact@v3
208+
with:
209+
name: version-files
210+
211+
- name: Update new version in README and Usage
212+
uses: jacobtomlinson/gha-find-replace@v3
213+
if: inputs.pre-release == false
214+
with:
215+
find: ${{ needs.prepare.outputs.old-version }}
216+
replace: ${{ needs.prepare.outputs.new-version }}
217+
regex: false
218+
include: |
219+
README.md
220+
website/docs/framework-docs/getting-started/usage.md
221+
222+
- name: Update new version in package.json
223+
uses: jacobtomlinson/gha-find-replace@v3
224+
if: inputs.pre-release == false
225+
with:
226+
find: '"version": "${{ needs.prepare.outputs.old-version }}"'
227+
replace: '"version": "${{ needs.prepare.outputs.new-version }}"'
228+
regex: false
229+
include: |
230+
package.json
231+
232+
- name: Import GPG key
233+
uses: crazy-max/ghaction-import-gpg@v5
234+
with:
235+
gpg_private_key: ${{ secrets.gpgKey }}
236+
passphrase: ${{ secrets.gpgPass }}
237+
git_user_signingkey: true
238+
git_commit_gpgsign: true
239+
240+
- name: Push updated version files
241+
uses: EndBug/add-and-commit@v9
242+
with:
243+
add: |
244+
core-java/pom.xml
245+
lerna.json
246+
CHANGELOG.md
247+
website/package.json
248+
README.md
249+
package.json
250+
website/docs/framework-docs/getting-started/usage.md
251+
message: |
252+
chore(Internal): :bookmark: released v${{ needs.prepare.outputs.old-version }} to maven central
253+
push: true
254+
default_author: user_info
255+
commit: --no-verify
256+
257+
github:
258+
runs-on: ubuntu-latest
259+
needs:
260+
- prepare
261+
- push-pom
262+
263+
steps:
264+
- name: Check out Git repository
265+
uses: actions/checkout@v3
266+
with:
267+
fetch-depth: 0
268+
269+
- name: Download target folder
270+
uses: actions/download-artifact@v3
271+
with:
272+
name: target
273+
path: ${{ github.workspace }}/core-java/target
274+
275+
- name: Download Version files
276+
uses: actions/download-artifact@v3
277+
with:
278+
name: version-files
279+
280+
- name: Create GitHub Release
281+
uses: softprops/action-gh-release@v1
282+
env:
283+
GITHUB_TOKEN: ${{ secrets.pushToken }}
284+
GITHUB_REPOSITORY: ${{ github.repository }}
285+
with:
286+
tag_name: v${{ needs.prepare.outputs.new-version }}
287+
name: Version ${{ needs.prepare.outputs.new-version }}
288+
prerelease: ${{ inputs.pre-release }}
289+
draft: false
290+
body_path: CHANGELOG.md
291+
discussion_category_name: Announcements
292+
generate_release_notes: false
293+
files: |
294+
core-java/target/*.jar

0 commit comments

Comments
 (0)