From 5b76357bd183ee52d96b86a87e338abb6293d4e2 Mon Sep 17 00:00:00 2001 From: jzhangdev Date: Thu, 11 Jan 2024 10:39:47 +0800 Subject: [PATCH] ci: config github actions --- .github/workflows/ci.yml | 80 ++++++++++++ .yamllint | 10 ++ beachball.config.ts | 48 ++++++++ ...-628e40b4-d688-45a4-9199-725d70f17573.json | 7 ++ package.json | 7 +- pnpm-lock.yaml | 114 ++++++++++++++++++ 6 files changed, 264 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .yamllint create mode 100644 beachball.config.ts create mode 100644 change/verdaccio-package-diff-628e40b4-d688-45a4-9199-725d70f17573.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..324a73c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,80 @@ +name: CI +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + install: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v2 + - uses: actions/setup-node@v4 + with: + node-version-file: .node-version + cache: pnpm + - run: pnpm install + + test: + needs: install + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v2 + - uses: actions/setup-node@v4 + with: + node-version-file: .node-version + cache: pnpm + - run: pnpm install + + - name: Lint + run: pnpm run lint + + check-workflow-files: + needs: install + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: docker://rhysd/actionlint:1.6.26 + with: + args: -color + + publish: + if: ${{ always() && !failure() && !cancelled() }} + needs: [test, check-workflow-files] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: pnpm/action-setup@v2 + - uses: actions/setup-node@v4 + with: + node-version-file: .node-version + cache: pnpm + - run: pnpm install + - run: pnpm run build + + - name: Publish (development) + if: github.event.pull_request.head.repo.full_name == 'RightCapitalHQ/verdaccio-package-diff' && github.base_ref == github.event.repository.default_branch + env: + NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + HEAD_REF: ${{ github.head_ref }} + run: | + npm config set //registry.npmjs.org/:_authToken "${NPM_TOKEN}" + preid="${HEAD_REF//\//-}".${{ github.run_number }}.${{ github.run_attempt }} + pnpm exec npm --no-git-tag-version version prerelease --preid="${preid}" + pnpm publish --no-git-checks --access public --tag development + + - name: Publish (main) + if: github.repository == 'RightCapitalHQ/verdaccio-package-diff' && github.event_name == 'push' && github.ref_name == github.event.repository.default_branch + env: + NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + run: | + npm config set //registry.npmjs.org/:_authToken "${NPM_TOKEN}" + git config --local user.email "npm-publisher@rightcapital.com" + git config --local user.name "GitHub Actions[bot]" + git remote set-url origin "https://${{ secrets.REPO_AUTOMATION_TOKEN }}@github.com/${{ github.repository }}.git" + pnpm beachball publish --yes -m 'chore(release): applying package updates' diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..caa1a33 --- /dev/null +++ b/.yamllint @@ -0,0 +1,10 @@ +--- +extends: default + +rules: + comments: + require-starting-space: false + min-spaces-from-content: 1 + document-start: + present: false + line-length: false diff --git a/beachball.config.ts b/beachball.config.ts new file mode 100644 index 0000000..1257cd2 --- /dev/null +++ b/beachball.config.ts @@ -0,0 +1,48 @@ +import type { BeachballConfig } from 'beachball'; + +const config: BeachballConfig = { + access: 'public', + registry: 'https://registry.npmjs.org', + ignorePatterns: [ + '.*ignore', + '.yamllint', + '.eslintrc.cjs', + '.pnpm-store/**', + '.vscode/**', + 'prettier.config.cjs', + 'pnpm-lock.yaml', + ], + changelog: { + customRenderers: { + // eslint-disable-next-line @typescript-eslint/require-await + async renderChangeTypeHeader(changeType, renderInfo) { + const changelogDate = renderInfo.newVersionChangelog.date + .toLocaleDateString('zh-CN') + .replace(/\//g, '-'); + const heading = + changeType === 'major' || changeType === 'minor' ? '##' : '###'; + return `${heading} [${ + renderInfo.newVersionChangelog.version + }](https://github.com/RightCapitalHQ/verdaccio-package-diff/tree/${encodeURIComponent( + renderInfo.newVersionChangelog.tag, + )}) (${changelogDate})`; + }, + // Original template: https://github.com/microsoft/beachball/blob/aefbc1ac37ee85961cc787133c827f1fd3925550/src/changelog/renderPackageChangelog.ts#L93 + // eslint-disable-next-line @typescript-eslint/require-await + async renderEntry(entry) { + if (entry.author === 'beachball') { + return `- ${entry.comment}`; + } + // Imitate GitHub's commit format https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/autolinked-references-and-urls#commit-shas + return `- ${entry.comment} ([${entry.commit.substring( + 0, + 7, + )}](https://github.com/RightCapitalHQ/verdaccio-package-diff/commit/${ + entry.commit + }))`; + }, + }, + }, +}; + +export default config; diff --git a/change/verdaccio-package-diff-628e40b4-d688-45a4-9199-725d70f17573.json b/change/verdaccio-package-diff-628e40b4-d688-45a4-9199-725d70f17573.json new file mode 100644 index 0000000..0654f4b --- /dev/null +++ b/change/verdaccio-package-diff-628e40b4-d688-45a4-9199-725d70f17573.json @@ -0,0 +1,7 @@ +{ + "type": "major", + "comment": "build: release package", + "packageName": "verdaccio-package-diff", + "email": "zhangjie9477@gmail.com", + "dependentChangeType": "patch" +} diff --git a/package.json b/package.json index 4db62b3..a72c7b4 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "verdaccio-package-diff", + "name": "@rightcapital/verdaccio-package-diff", "version": "0.0.1", "description": "A package diff plugin for Verdaccio", "main": "dist/index.js", @@ -21,7 +21,9 @@ "eslint:fix": "eslint --max-warnings=0 --fix .", "prettier:lint": "prettier --check .", "prettier:fix": "prettier --write -l .", - "prepare": "husky install" + "prepare": "husky install", + "change": "beachball change --no-commit", + "check": "beachball check" }, "keywords": [ "verdaccio", @@ -45,6 +47,7 @@ "@types/express": "4.17.21", "@types/node": "20", "@verdaccio/types": "10.8.0", + "beachball": "2.39.0", "commitizen": "4.3.0", "eslint": "8.56.0", "husky": "8.0.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 99d878d..64884bf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -37,6 +37,9 @@ devDependencies: '@verdaccio/types': specifier: 10.8.0 version: 10.8.0 + beachball: + specifier: 2.39.0 + version: 2.39.0(typescript@5.3.3) commitizen: specifier: 4.3.0 version: 4.3.0(@types/node@20.10.7)(typescript@5.3.3) @@ -622,6 +625,10 @@ packages: resolution: {integrity: sha512-FuJyCRFPdy+gqCi0v29dE1xKn99Ztq6fuY9fb7ezeP1SRbUL/hgDaNkpjYvSIMCyb+dLFKOFBeZPyIUBLOSdlA==} dev: true + /@yarnpkg/lockfile@1.1.0: + resolution: {integrity: sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==} + dev: true + /JSONStream@1.3.5: resolution: {integrity: sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==} hasBin: true @@ -756,6 +763,27 @@ packages: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} dev: true + /beachball@2.39.0(typescript@5.3.3): + resolution: {integrity: sha512-YyhL16twP3sa0Pd+auXDzG2xqIPBLF+9GIsMEXMRpSjk9eYpzqSY/BOKbwzy+VqsUlQxWfVIFxijbUEQZYIwUQ==} + engines: {node: '>=14.0.0'} + hasBin: true + dependencies: + cosmiconfig: 8.3.6(typescript@5.3.3) + execa: 5.1.1 + fs-extra: 11.2.0 + lodash: 4.17.21 + minimatch: 3.1.2 + p-limit: 3.1.0 + prompts: 2.4.2 + semver: 7.5.4 + toposort: 2.0.2 + uuid: 9.0.1 + workspace-tools: 0.36.4 + yargs-parser: 21.1.1 + transitivePeerDependencies: + - typescript + dev: true + /bl@4.1.0: resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==} dependencies: @@ -1708,6 +1736,15 @@ packages: engines: {node: '>= 0.6'} dev: false + /fs-extra@11.2.0: + resolution: {integrity: sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==} + engines: {node: '>=14.14'} + dependencies: + graceful-fs: 4.2.11 + jsonfile: 6.1.0 + universalify: 2.0.1 + dev: true + /fs-extra@9.1.0: resolution: {integrity: sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==} engines: {node: '>=10'} @@ -1783,6 +1820,19 @@ packages: through2: 4.0.2 dev: true + /git-up@7.0.0: + resolution: {integrity: sha512-ONdIrbBCFusq1Oy0sC71F5azx8bVkvtZtMJAsv+a6lz5YAmbNnLD6HAB4gptHZVLPR8S2/kVN6Gab7lryq5+lQ==} + dependencies: + is-ssh: 1.4.0 + parse-url: 8.1.0 + dev: true + + /git-url-parse@13.1.1: + resolution: {integrity: sha512-PCFJyeSSdtnbfhSNRw9Wk96dDCNx+sogTe4YNXeXSJxt7xz5hvXekuRn9JX7m+Mf4OscCu8h+mtAl3+h5Fo8lQ==} + dependencies: + git-up: 7.0.0 + dev: true + /glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -2174,6 +2224,12 @@ packages: call-bind: 1.0.5 dev: true + /is-ssh@1.4.0: + resolution: {integrity: sha512-x7+VxdxOdlV3CYpjvRLBv5Lo9OJerlYanjwFrPR9fuGPjCiNiCzFgAWpiLAohSbsnH4ZAys3SBh+hq5rJosxUQ==} + dependencies: + protocols: 2.0.1 + dev: true + /is-stream@2.0.1: resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==} engines: {node: '>=8'} @@ -2240,6 +2296,10 @@ packages: hasBin: true dev: true + /jju@1.4.0: + resolution: {integrity: sha512-8wb9Yw966OSxApiCt0K3yNJL8pnNeIv+OEq2YMidz4FKP6nonSRoOXc80iXY4JaN2FC11B9qsNmDsm+ZOfMROA==} + dev: true + /js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} dev: true @@ -2300,6 +2360,11 @@ packages: engines: {node: '>=0.10.0'} dev: true + /kleur@3.0.3: + resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==} + engines: {node: '>=6'} + dev: true + /levn@0.4.1: resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} engines: {node: '>= 0.8.0'} @@ -2696,6 +2761,18 @@ packages: engines: {node: '>=0.10.0'} dev: true + /parse-path@7.0.0: + resolution: {integrity: sha512-Euf9GG8WT9CdqwuWJGdf3RkUcTBArppHABkO7Lm8IzRQp0e2r/kkFnmhu4TSK30Wcu5rVAZLmfPKSBBi9tWFog==} + dependencies: + protocols: 2.0.1 + dev: true + + /parse-url@8.1.0: + resolution: {integrity: sha512-xDvOoLU5XRrcOZvnI6b8zA6n9O9ejNk/GExuz1yBuWUGn9KA97GI6HTs6u02wKara1CeVmZhH+0TZFdWScR89w==} + dependencies: + parse-path: 7.0.0 + dev: true + /parseurl@1.3.3: resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==} engines: {node: '>= 0.8'} @@ -2745,6 +2822,18 @@ packages: hasBin: true dev: true + /prompts@2.4.2: + resolution: {integrity: sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==} + engines: {node: '>= 6'} + dependencies: + kleur: 3.0.3 + sisteransi: 1.0.5 + dev: true + + /protocols@2.0.1: + resolution: {integrity: sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q==} + dev: true + /proxy-addr@2.0.7: resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==} engines: {node: '>= 0.10'} @@ -3040,6 +3129,10 @@ packages: resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} dev: true + /sisteransi@1.0.5: + resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} + dev: true + /slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} @@ -3214,6 +3307,10 @@ packages: engines: {node: '>=0.6'} dev: false + /toposort@2.0.2: + resolution: {integrity: sha512-0a5EOkAUp8D4moMi2W8ZF8jcga7BgZd91O/yabJCFY8az+XSzeGyTKs0Aoo897iV1Nj6guFq8orWDS96z91oGg==} + dev: true + /trim-newlines@3.0.1: resolution: {integrity: sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw==} engines: {node: '>=8'} @@ -3354,6 +3451,11 @@ packages: engines: {node: '>= 0.4.0'} dev: false + /uuid@9.0.1: + resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==} + hasBin: true + dev: true + /validate-npm-package-license@3.0.4: resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==} dependencies: @@ -3413,6 +3515,18 @@ packages: engines: {node: '>=0.10.0'} dev: true + /workspace-tools@0.36.4: + resolution: {integrity: sha512-v0UFVvw9BjHtRu2Dau5PEJKkuG8u4jPlpXZQWjSz9XgbSutpPURqtO2P0hp3cVmQVATh8lkMFCewFgJuDnyC/w==} + dependencies: + '@yarnpkg/lockfile': 1.1.0 + fast-glob: 3.3.2 + git-url-parse: 13.1.1 + globby: 11.1.0 + jju: 1.4.0 + js-yaml: 4.1.0 + micromatch: 4.0.5 + dev: true + /wrap-ansi@6.2.0: resolution: {integrity: sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==} engines: {node: '>=8'}