-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from VisActor/chore/34-chore-pre-release-workflow
chore: add pre-release
- Loading branch information
Showing
8 changed files
with
1,332 additions
and
933 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Pre-release CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- pre-release/* | ||
|
||
jobs: | ||
build: | ||
runs-on: macOS-latest # 如果用了electron,记得改成 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: Build packages | ||
run: node common/scripts/install-run-rush.js build --only tag:package | ||
|
||
- name: Parse semver version from branch name | ||
id: semver_parser | ||
uses: release-kit/semver@v2 | ||
with: | ||
string: ${{ github.ref_name }} | ||
pattern: '^pre-release/(.*)$' # ^v?(.*)$ by default | ||
|
||
- name: Apply prereleaseName | ||
run: node common/scripts/install-run-rush.js publish --apply --prerelease-name ${{ steps.semver_parser.outputs.prerelease }} --partial-prerelease | ||
|
||
- 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.prerelease }} | ||
|
||
- name: Update shrinkwrap | ||
run: node common/scripts/install-run-rush.js update | ||
|
||
- name: Get package version | ||
id: package-version | ||
uses: culshaw/read-package-node-version-actions@v1 | ||
with: | ||
path: './packages/vtable' # 各项目需要修改一下 | ||
|
||
- name: Commit & Push changes | ||
uses: actions-js/push@master | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
message: 'build: prelease version ${{ steps.package-version.outputs.version }}' | ||
branch: ${{ github.ref_name }} | ||
author_name: ${{ github.actor }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: Release CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- release/* | ||
|
||
jobs: | ||
build: | ||
runs-on: macOS-latest # 如果用了electron,记得改成 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: Build packages | ||
run: node common/scripts/install-run-rush.js version --bump | ||
|
||
- 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 | ||
|
||
- name: Update shrinkwrap | ||
run: node common/scripts/install-run-rush.js update | ||
|
||
- name: Get package version | ||
id: package-version | ||
uses: culshaw/read-package-node-version-actions@v1 | ||
with: | ||
path: './packages/vtable' # 各项目修改一下 | ||
|
||
- name: Commit & Push changes | ||
uses: actions-js/push@master | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
message: 'build: prelease version ${{ steps.package-version.outputs.version }}' | ||
branch: ${{ github.ref_name }} | ||
|
||
- name: Create Release for Tag | ||
id: release_tag | ||
# See more about this action: https://github.com/actions/create-release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: v${{ steps.package-version.outputs.version }} | ||
release_name: Release v${{ steps.package-version.outputs.version }} | ||
prerelease: false # | ||
|
||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
base: main | ||
branch: ${{ github.ref_name }} | ||
title: '[Auto release] release ${{ steps.package-version.outputs.version }}' | ||
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import path from 'path'; | ||
import chalk from 'chalk'; | ||
import minimist, { ParsedArgs } from 'minimist'; | ||
import { spawnSync } from 'child_process'; | ||
|
||
interface RunScriptArgv extends ParsedArgs { | ||
message?: string; | ||
type?: string; | ||
} | ||
|
||
function run() { | ||
const commitLineConfigPath = path.resolve(__dirname, './commitlint.config.js'); | ||
const commitLintBinPath = path.resolve(__dirname, './node_modules/.bin/commitlint'); | ||
const argv: RunScriptArgv = minimist(process.argv.slice(2)); | ||
const message = argv.message; | ||
let bumpType = argv.type; | ||
|
||
if (message) { | ||
const result = spawnSync( | ||
'sh', | ||
['-c', `echo ${message} | ${commitLintBinPath} --config ${commitLineConfigPath}`], | ||
{ | ||
stdio: 'inherit' | ||
} | ||
); | ||
|
||
if (result.status !== 0) { | ||
process.exit(1); | ||
} | ||
|
||
if (!bumpType) { | ||
console.log(chalk.green(`[Notice] no bumpType is supplied, we'll use default bumpType: ${chalk.red.bold('patch')}`)); | ||
bumpType = 'patch'; | ||
} | ||
|
||
spawnSync('sh', ['-c', `rush change --bulk --bump-type '${bumpType}' --message '${message}'`], { | ||
stdio: 'inherit', | ||
shell: false, | ||
}); | ||
} | ||
} | ||
|
||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.