Skip to content

Commit

Permalink
Merge pull request #2 from VisActor/feat-github-actions
Browse files Browse the repository at this point in the history
Feat GitHub actions
  • Loading branch information
da730 authored Jan 29, 2024
2 parents de0012c + ded540f commit 994f9bc
Show file tree
Hide file tree
Showing 23 changed files with 538 additions and 75 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This workflow will triage pull requests and apply a label based on the
# paths that are modified in the pull request.
#
# To use this workflow, you will need to set up a .github/labeler.yml
# file with configuration. For more information, see:
# https://github.com/actions/labeler

name: Labeler
on: [pull_request_target]

jobs:
label:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

steps:
- uses: actions/labeler@v4
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
29 changes: 29 additions & 0 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Check of pull request

# 这里业务方根据需求设置
on:
pull_request:
branches: ['develop', 'dev/**']
jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: './common/config/rush/pnpm-lock.yaml'

- uses: xile611/pr-type-check@main
with:
pull_request_body: |
${{ github.event.pull_request.body }}
pull_request_head: ${{ github.event.pull_request.head.ref }}
73 changes: 73 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Pre-release CI

on:
push:
branches:
- 'pre-release/[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+'
- 'pre-release/[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+'
- 'pre-release/[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+'
- 'pre-release/[0-9]+.[0-9]+.[0-9]+-hotfix.[0-9]+'

jobs:
build:
runs-on: macOS-latest

permissions:
contents: write

strategy:
matrix:
node-version: [18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: './common/config/rush/pnpm-lock.yaml'

# Install rush
- name: Install rush
run: node common/scripts/install-run-rush.js install --bypass-policy

- name: Parse semver version from branch name
id: semver_parser
uses: xile611/read-package-version-action@main
with:
path: packages/vmind
semver_string: ${{ github.ref_name }}
semver_pattern: '^pre-release/(.*)$' # ^v?(.*)$ by default

- name: Apply prereleaseName
run: node common/scripts/apply-prerelease-version.js ${{ steps.semver_parser.outputs.pre_release_name }} ${{ steps.semver_parser.outputs.main }}

- name: Build packages
env:
NODE_OPTIONS: '--max_old_space_size=4096'
run: node common/scripts/install-run-rush.js build --only tag:package

- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
NPM_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
run: node common/scripts/install-run-rush.js publish --publish --include-all --tag ${{ steps.semver_parser.outputs.pre_release_type }}

- name: Update shrinkwrap
run: node common/scripts/install-run-rush.js update

- name: Get npm version
id: package-version
uses: xile611/read-package-version-action@main
with:
path: packages/vmind

- name: Commit & Push changes
uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
message: 'build: prelease version ${{ steps.package-version.outputs.current_version }}'
branch: ${{ github.ref_name }}
author_name: ${{ github.actor }}
67 changes: 67 additions & 0 deletions .github/workflows/release-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Release changelog

on:
release:
types: [published]

jobs:
update-changelog-after-publish-a-release:
name: GitHub Actions Test
runs-on: macOS-latest

strategy:
matrix:
node-version: [18.x]

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v3
- run: |
git config user.name ${{ github.actor }}
git config user.email ${{ github.actor }}@users.noreply.github.com
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: './common/config/rush/pnpm-lock.yaml'

# Install rush
- name: Install rush
run: node common/scripts/install-run-rush.js install --bypass-policy

- name: Create branch
run: |
git status
git fetch origin develop:develop
git checkout develop
git status
git checkout -b docs/generate-changelog-${{ github.event.release.tag_name }}
- name: generate changelog
id: generate-changelog
uses: xile611/collect-release-changelog@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
folder: ./docs/assets/changelog
langs: 'en,zh'
tag_name: ${{github.event.release.tag_name}}
file_name: release.md

- name: Push branch
run: |
git add .
git commit -m "docs: generate changelog of release ${{ github.event.release.tag_name }}" -n
git push origin docs/generate-changelog-${{ github.event.release.tag_name }}
- name: Create Pull Request
uses: dustinirving/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: '[Auto changelog] changlog of ${{ github.event.release.tag_name }}'
base: develop
head: 'docs/generate-changelog-${{ github.event.release.tag_name }}'
labels: changelog
body: 'update changelog of ${{ github.event.release.tag_name }}'
109 changes: 109 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Release CI

on:
push:
branches:
- 'release/[0-9]+.[0-9]+.[0-9]+'

jobs:
build:
runs-on: macOS-latest
permissions:
contents: write
pull-requests: write

strategy:
matrix:
node-version: [18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- run: |
git config user.name ${{ github.actor }}
git config user.email ${{ github.actor }}@users.noreply.github.com
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: './common/config/rush/pnpm-lock.yaml'

# Install rush
- name: Install rush
run: node common/scripts/install-run-rush.js install --bypass-policy

- name: Parse semver version from branch name
id: semver_parser
uses: xile611/read-package-version-action@main
with:
path: packages/vmind
semver_string: ${{ github.ref_name }}
semver_pattern: '^release/(.*)$' # ^v?(.*)$ by default

- name: update nextBump of version policies
uses: xile611/set-next-bump-of-rush@main
with:
release_version: ${{ steps.semver_parser.outputs.full }}
write_next_bump: true

- name: Update version
run: node common/scripts/install-run-rush.js version --bump

- name: Build packages
env:
NODE_OPTIONS: '--max_old_space_size=4096'
run: node common/scripts/install-run-rush.js build --only tag:package

- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
NPM_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
run: node common/scripts/install-run-rush.js publish --publish --include-all --tag latest

- name: Update shrinkwrap
run: node common/scripts/install-run-rush.js update

- name: Get npm version
id: package-version
uses: xile611/read-package-version-action@main
with:
path: packages/vmind

- name: Commit & Push changes
run: |
git add .
git commit -m 'build: prelease version ${{ steps.package-version.outputs.current_version }}' -n
git push origin ${{ github.ref_name }}
- name: Collect changelog of rush
uses: xile611/collect-rush-changlog@main
id: changelog
with:
version: ${{ steps.package-version.outputs.current_version }}

- name: Create Release for Tag
id: release_tag
uses: ncipollo/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: v${{ steps.package-version.outputs.current_version }}
commit: main
prerelease: false
body: |
${{ steps.changelog.outputs.markdown }}
draft: true #

- name: Create Pull Request
uses: dustinirving/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: '[Auto release] release ${{ steps.package-version.outputs.current_version }}'
base: main
head: ${{ github.ref_name }}
labels: release # default labels, the action will throw error if not specified
reviewers: kkxxkk2019 # default reviewers, the action will throw error if not specified
body: |
${{ steps.changelog.outputs.markdown }}
35 changes: 35 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
#
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/actions/stale
name: Mark stale issues and pull requests

on:
schedule:
- cron: '20 4 * * *'

jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write

steps:
- uses: actions/stale@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-stale: 730
days-before-close: 7
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.'
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!'
close-issue-reason: 'not_planned'
stale-issue-label: 'stale_issue'
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.'
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.'
stale-pr-label: 'stale_pr'
exempt-issue-labels: 'High Priority'
exempt-all-milestones: true
operations-per-run: 500
ascending: true
Loading

0 comments on commit 994f9bc

Please sign in to comment.