Skip to content

Commit 994f9bc

Browse files
authored
Merge pull request #2 from VisActor/feat-github-actions
Feat GitHub actions
2 parents de0012c + ded540f commit 994f9bc

23 files changed

+538
-75
lines changed

.github/workflows/labeler.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This workflow will triage pull requests and apply a label based on the
2+
# paths that are modified in the pull request.
3+
#
4+
# To use this workflow, you will need to set up a .github/labeler.yml
5+
# file with configuration. For more information, see:
6+
# https://github.com/actions/labeler
7+
8+
name: Labeler
9+
on: [pull_request_target]
10+
11+
jobs:
12+
label:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
pull-requests: write
17+
18+
steps:
19+
- uses: actions/labeler@v4
20+
with:
21+
repo-token: '${{ secrets.GITHUB_TOKEN }}'

.github/workflows/pr-check.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Check of pull request
2+
3+
# 这里业务方根据需求设置
4+
on:
5+
pull_request:
6+
branches: ['develop', 'dev/**']
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
strategy:
12+
matrix:
13+
node-version: [20.x]
14+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Use Node.js ${{ matrix.node-version }}
19+
uses: actions/setup-node@v3
20+
with:
21+
node-version: ${{ matrix.node-version }}
22+
cache: 'npm'
23+
cache-dependency-path: './common/config/rush/pnpm-lock.yaml'
24+
25+
- uses: xile611/pr-type-check@main
26+
with:
27+
pull_request_body: |
28+
${{ github.event.pull_request.body }}
29+
pull_request_head: ${{ github.event.pull_request.head.ref }}

.github/workflows/pre-release.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Pre-release CI
2+
3+
on:
4+
push:
5+
branches:
6+
- 'pre-release/[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+'
7+
- 'pre-release/[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+'
8+
- 'pre-release/[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+'
9+
- 'pre-release/[0-9]+.[0-9]+.[0-9]+-hotfix.[0-9]+'
10+
11+
jobs:
12+
build:
13+
runs-on: macOS-latest
14+
15+
permissions:
16+
contents: write
17+
18+
strategy:
19+
matrix:
20+
node-version: [18.x]
21+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
22+
23+
steps:
24+
- uses: actions/checkout@v3
25+
- name: Use Node.js ${{ matrix.node-version }}
26+
uses: actions/setup-node@v3
27+
with:
28+
node-version: ${{ matrix.node-version }}
29+
cache: 'npm'
30+
cache-dependency-path: './common/config/rush/pnpm-lock.yaml'
31+
32+
# Install rush
33+
- name: Install rush
34+
run: node common/scripts/install-run-rush.js install --bypass-policy
35+
36+
- name: Parse semver version from branch name
37+
id: semver_parser
38+
uses: xile611/read-package-version-action@main
39+
with:
40+
path: packages/vmind
41+
semver_string: ${{ github.ref_name }}
42+
semver_pattern: '^pre-release/(.*)$' # ^v?(.*)$ by default
43+
44+
- name: Apply prereleaseName
45+
run: node common/scripts/apply-prerelease-version.js ${{ steps.semver_parser.outputs.pre_release_name }} ${{ steps.semver_parser.outputs.main }}
46+
47+
- name: Build packages
48+
env:
49+
NODE_OPTIONS: '--max_old_space_size=4096'
50+
run: node common/scripts/install-run-rush.js build --only tag:package
51+
52+
- name: Publish to npm
53+
env:
54+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
55+
NPM_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
56+
run: node common/scripts/install-run-rush.js publish --publish --include-all --tag ${{ steps.semver_parser.outputs.pre_release_type }}
57+
58+
- name: Update shrinkwrap
59+
run: node common/scripts/install-run-rush.js update
60+
61+
- name: Get npm version
62+
id: package-version
63+
uses: xile611/read-package-version-action@main
64+
with:
65+
path: packages/vmind
66+
67+
- name: Commit & Push changes
68+
uses: actions-js/push@master
69+
with:
70+
github_token: ${{ secrets.GITHUB_TOKEN }}
71+
message: 'build: prelease version ${{ steps.package-version.outputs.current_version }}'
72+
branch: ${{ github.ref_name }}
73+
author_name: ${{ github.actor }}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Release changelog
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
update-changelog-after-publish-a-release:
9+
name: GitHub Actions Test
10+
runs-on: macOS-latest
11+
12+
strategy:
13+
matrix:
14+
node-version: [18.x]
15+
16+
steps:
17+
- name: Checkout
18+
id: checkout
19+
uses: actions/checkout@v3
20+
- run: |
21+
git config user.name ${{ github.actor }}
22+
git config user.email ${{ github.actor }}@users.noreply.github.com
23+
24+
- name: Use Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@v3
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
cache: 'npm'
29+
cache-dependency-path: './common/config/rush/pnpm-lock.yaml'
30+
31+
# Install rush
32+
- name: Install rush
33+
run: node common/scripts/install-run-rush.js install --bypass-policy
34+
35+
- name: Create branch
36+
run: |
37+
git status
38+
git fetch origin develop:develop
39+
git checkout develop
40+
git status
41+
git checkout -b docs/generate-changelog-${{ github.event.release.tag_name }}
42+
43+
- name: generate changelog
44+
id: generate-changelog
45+
uses: xile611/collect-release-changelog@main
46+
with:
47+
token: ${{ secrets.GITHUB_TOKEN }}
48+
folder: ./docs/assets/changelog
49+
langs: 'en,zh'
50+
tag_name: ${{github.event.release.tag_name}}
51+
file_name: release.md
52+
53+
- name: Push branch
54+
run: |
55+
git add .
56+
git commit -m "docs: generate changelog of release ${{ github.event.release.tag_name }}" -n
57+
git push origin docs/generate-changelog-${{ github.event.release.tag_name }}
58+
59+
- name: Create Pull Request
60+
uses: dustinirving/[email protected]
61+
with:
62+
token: ${{ secrets.GITHUB_TOKEN }}
63+
title: '[Auto changelog] changlog of ${{ github.event.release.tag_name }}'
64+
base: develop
65+
head: 'docs/generate-changelog-${{ github.event.release.tag_name }}'
66+
labels: changelog
67+
body: 'update changelog of ${{ github.event.release.tag_name }}'

.github/workflows/release.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Release CI
2+
3+
on:
4+
push:
5+
branches:
6+
- 'release/[0-9]+.[0-9]+.[0-9]+'
7+
8+
jobs:
9+
build:
10+
runs-on: macOS-latest
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
strategy:
16+
matrix:
17+
node-version: [18.x]
18+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
19+
20+
steps:
21+
- uses: actions/checkout@v3
22+
- run: |
23+
git config user.name ${{ github.actor }}
24+
git config user.email ${{ github.actor }}@users.noreply.github.com
25+
26+
- name: Use Node.js ${{ matrix.node-version }}
27+
uses: actions/setup-node@v3
28+
with:
29+
node-version: ${{ matrix.node-version }}
30+
cache: 'npm'
31+
cache-dependency-path: './common/config/rush/pnpm-lock.yaml'
32+
33+
# Install rush
34+
- name: Install rush
35+
run: node common/scripts/install-run-rush.js install --bypass-policy
36+
37+
- name: Parse semver version from branch name
38+
id: semver_parser
39+
uses: xile611/read-package-version-action@main
40+
with:
41+
path: packages/vmind
42+
semver_string: ${{ github.ref_name }}
43+
semver_pattern: '^release/(.*)$' # ^v?(.*)$ by default
44+
45+
- name: update nextBump of version policies
46+
uses: xile611/set-next-bump-of-rush@main
47+
with:
48+
release_version: ${{ steps.semver_parser.outputs.full }}
49+
write_next_bump: true
50+
51+
- name: Update version
52+
run: node common/scripts/install-run-rush.js version --bump
53+
54+
- name: Build packages
55+
env:
56+
NODE_OPTIONS: '--max_old_space_size=4096'
57+
run: node common/scripts/install-run-rush.js build --only tag:package
58+
59+
- name: Publish to npm
60+
env:
61+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
62+
NPM_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
63+
run: node common/scripts/install-run-rush.js publish --publish --include-all --tag latest
64+
65+
- name: Update shrinkwrap
66+
run: node common/scripts/install-run-rush.js update
67+
68+
- name: Get npm version
69+
id: package-version
70+
uses: xile611/read-package-version-action@main
71+
with:
72+
path: packages/vmind
73+
74+
- name: Commit & Push changes
75+
run: |
76+
git add .
77+
git commit -m 'build: prelease version ${{ steps.package-version.outputs.current_version }}' -n
78+
git push origin ${{ github.ref_name }}
79+
80+
- name: Collect changelog of rush
81+
uses: xile611/collect-rush-changlog@main
82+
id: changelog
83+
with:
84+
version: ${{ steps.package-version.outputs.current_version }}
85+
86+
- name: Create Release for Tag
87+
id: release_tag
88+
uses: ncipollo/[email protected]
89+
env:
90+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
with:
92+
tag: v${{ steps.package-version.outputs.current_version }}
93+
commit: main
94+
prerelease: false
95+
body: |
96+
${{ steps.changelog.outputs.markdown }}
97+
draft: true #
98+
99+
- name: Create Pull Request
100+
uses: dustinirving/[email protected]
101+
with:
102+
token: ${{ secrets.GITHUB_TOKEN }}
103+
title: '[Auto release] release ${{ steps.package-version.outputs.current_version }}'
104+
base: main
105+
head: ${{ github.ref_name }}
106+
labels: release # default labels, the action will throw error if not specified
107+
reviewers: kkxxkk2019 # default reviewers, the action will throw error if not specified
108+
body: |
109+
${{ steps.changelog.outputs.markdown }}

.github/workflows/stale.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
2+
#
3+
# You can adjust the behavior by modifying this file.
4+
# For more information, see:
5+
# https://github.com/actions/stale
6+
name: Mark stale issues and pull requests
7+
8+
on:
9+
schedule:
10+
- cron: '20 4 * * *'
11+
12+
jobs:
13+
stale:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
issues: write
17+
pull-requests: write
18+
19+
steps:
20+
- uses: actions/stale@v5
21+
with:
22+
repo-token: ${{ secrets.GITHUB_TOKEN }}
23+
days-before-stale: 730
24+
days-before-close: 7
25+
stale-issue-message: 'This issue has been automatically marked as stale because it did not have recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.'
26+
close-issue-message: 'This issue has been automatically closed because it did not have recent activity. If this remains to be a problem with the latest version of @VisActor/VMind, please open a new issue and link this to it. Thanks!'
27+
close-issue-reason: 'not_planned'
28+
stale-issue-label: 'stale_issue'
29+
stale-pr-message: 'This PR has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this PR. We are sorry for this but 2 years is a long time and the code base has been changed a lot. Thanks for your contribution anyway.'
30+
close-pr-message: 'This PR has been automatically closed because it has not had recent activity. Sorry for that and we are looking forward to your next contribution.'
31+
stale-pr-label: 'stale_pr'
32+
exempt-issue-labels: 'High Priority'
33+
exempt-all-milestones: true
34+
operations-per-run: 500
35+
ascending: true

0 commit comments

Comments
 (0)