Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: add release config #6

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .changeset/README.md

This file was deleted.

11 changes: 0 additions & 11 deletions .changeset/config.json

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/dirty-dingos-visit.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/gentle-knives-dress.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/nervous-eels-hear.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/sour-bees-argue.md

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI

on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]

jobs:
build:

runs-on: ubuntu-latest

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

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm install --force
- run: npm run build
- run: npm run ci:test
82 changes: 82 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Publish

on:
pull_request:
types:
- opened
- reopened
pull_request_review:
types:
- submitted
check_suite:
types:
- completed
status: {}

jobs:
autoApprove:
if: startsWith(github.head_ref, 'release-auto-')
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: hmarr/auto-approve-action@v4
with:
review-message: 'Auto approve sync PRs to auto merge them'
publish:
if: startsWith(github.head_ref, 'release-auto-')
needs: [autoApprove]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci --force
- name: Publish
if: startsWith(github.head_ref, 'release-auto-v')
run: |
git config user.name github-actions
git config user.email [email protected]
npm run pub
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish-next
if: startsWith(github.head_ref, 'release-auto-next-v')
run: |
git config user.name github-actions
git config user.email [email protected]
npm run pub-next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Read package.json
id: read-version
uses: notiz-dev/github-action-json-property@release
with:
path: 'package.json'
prop_path: 'version'
- name: send message to webhook
uses: joelwmale/webhook-action@master
with:
url: 'https://hook-rc.pingcode.com/api/flow/w/http/357bdd4f00f34bfab2f878ad3b9e8b48'
body: '{ "version": "${{ steps.read-version.outputs.prop }}", "name": "ai-table" }'
autoMerge:
if: startsWith(github.head_ref, 'release-auto-')
needs: [publish]
runs-on: ubuntu-latest
steps:
- id: autoMerge
name: autoMerge
uses: 'pascalgn/[email protected]'
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
MERGE_LABELS: ''
MERGE_FORKS: 'false'
MERGE_RETRIES: '20'
MERGE_RETRY_SLEEP: '60000'
16 changes: 16 additions & 0 deletions .wpmrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
allowBranch: ['main', 'release-auto-*'],
bumpFiles: ['package.json', 'package-lock.json', 'packages/grid/package.json'],
skip: {
confirm: true
},
// backward compatibility changelog
// because we didn't use tag prefix(v) when create tag before
// should set tagPrefix as empty (default is 'v')
// otherwise, the changelog will rebuild, and will be lost past versions
tagPrefix: '',
hooks: {
prepublish: 'npm run build',
prereleaseBranch: 'node ./scripts/pre-release.js {{version}}'
}
};
Empty file added CHANGELOG.md
Empty file.
5 changes: 2 additions & 3 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,12 @@
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "packages/grid/test.ts",
"main": "packages/grid/src/test.ts",
"tsConfig": "packages/grid/tsconfig.spec.json",
"karmaConfig": "packages/grid/karma.conf.js",
"codeCoverage": true,
"codeCoverageExclude": [
"packages/grid/testing/**/*",
"packages/core/test/**/*"
"packages/grid/testing/**/*"
]
}
},
Expand Down
19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@
"start": "ng serve",
"build": "npm run build:grid",
"build:grid": "ng build grid && cpx \"./packages/grid/src/**/*.scss\" ./dist/grid/",
"release": "wpm release --release-branch-format release-auto-v{{version}}",
"release-next": "wpm release --release-branch-format release-auto-next-v{{version}}",
"release-manual": "wpm release",
"release-next-manual": "wpm release --release-branch-format release-next-v{{version}}",
"watch": "ng build --watch --configuration development",
"test": "ng test"
"pub": "cd dist/grid && npm publish",
"test": "ng test grid"
},
"private": true,
"dependencies": {
Expand All @@ -23,18 +28,14 @@
"@angular/platform-browser": "^18.0.0",
"@angular/platform-browser-dynamic": "^18.0.0",
"@angular/router": "^18.0.0",
"@changesets/cli": "^2.27.5",
"@tethys/cdk": "^17.0.8",
"@tethys/icons": "^1.4.62",
"cpx": "^1.5.0",
"immer": "^10.0.3",
"date-fns": "^3.6.0",
"ng-packagr": "^18.0.0",
"ngx-tethys": "^17.0.8",
"npm": "^10.8.1",
"rxjs": "~7.8.0",
"tslib": "^2.6.3",
"y-websocket": "^2.0.3",
"yjs": "^13.6.16",
"zone.js": "~0.14.3"
},
"devDependencies": {
Expand All @@ -49,6 +50,10 @@
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"prettier": "^3.3.2",
"typescript": "~5.4.2"
"typescript": "~5.4.2",
"ng-packagr": "^18.0.0",
"cpx": "^1.5.0",
"@worktile/pkg-manager": "^0.1.0",
"chalk": "^2.4.2"
}
}
9 changes: 9 additions & 0 deletions packages/grid/src/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files

import 'zone.js';
import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';

// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), { teardown: { destroyAfterEach: true } });
19 changes: 19 additions & 0 deletions scripts/pre-release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const chalk = require('chalk');

const command = process.env.npm_lifecycle_event;
const args = process.argv;
const version = args[2];

if (version.includes('next') && !command.includes('next')) {
console.log(
chalk.bgRed.black('[ERROR]'),
chalk.red(`✘ Publish the next version, please use ${chalk.blue('npm run release-next')}`),
);
process.exit(1);
} else if (!version.includes('next') && command.includes('next')) {
console.log(
chalk.bgRed.black('[ERROR]'),
chalk.red(`✘ Publish the latest version, please use ${chalk.blue('npm run release')}`),
);
process.exit(1);
}