From 4b32d5f0eca1f32a476dd325e688dd008b8080e0 Mon Sep 17 00:00:00 2001 From: Avraj Sahota Date: Fri, 2 Feb 2024 09:39:45 +0300 Subject: [PATCH] add: github actions for create-commandkit --- ...loy-dev-build.yaml => dev-commandkit.yaml} | 6 +- .github/workflows/dev-create-commandkit.yaml | 62 +++++++++++++++++++ packages/commandkit/package.json | 1 - packages/create-commandkit/.npmignore | 11 ++++ packages/create-commandkit/package.json | 6 +- 5 files changed, 81 insertions(+), 5 deletions(-) rename .github/workflows/{deploy-dev-build.yaml => dev-commandkit.yaml} (93%) create mode 100644 .github/workflows/dev-create-commandkit.yaml create mode 100644 packages/create-commandkit/.npmignore diff --git a/.github/workflows/deploy-dev-build.yaml b/.github/workflows/dev-commandkit.yaml similarity index 93% rename from .github/workflows/deploy-dev-build.yaml rename to .github/workflows/dev-commandkit.yaml index 59acbcf..730e1fc 100644 --- a/.github/workflows/deploy-dev-build.yaml +++ b/.github/workflows/dev-commandkit.yaml @@ -1,4 +1,4 @@ -name: Publish Dev Build +name: (CommandKit) Publish Dev Build on: push: @@ -39,7 +39,9 @@ jobs: DEBIAN_FRONTEND: noninteractive - name: 🚚 Publish - run: pnpm run deploy:package-dev + run: | + cd packages/create-commandkit + npm publish --access public --tag dev env: NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} diff --git a/.github/workflows/dev-create-commandkit.yaml b/.github/workflows/dev-create-commandkit.yaml new file mode 100644 index 0000000..daed2b0 --- /dev/null +++ b/.github/workflows/dev-create-commandkit.yaml @@ -0,0 +1,62 @@ +name: (Create CommandKit) Publish Dev Build + +on: + push: + branches: + - master + paths: + - 'packages/create-commandkit/**' + +jobs: + release: + name: 🚀 Publish Dev Build + runs-on: ubuntu-latest + steps: + - uses: pnpm/action-setup@v2 + with: + version: 8 + + - name: 📚 Checkout + uses: actions/checkout@v3 + + - name: 🟢 Node + uses: actions/setup-node@v2 + with: + node-version: 18 + registry-url: https://registry.npmjs.org + + - name: 🍳 Prepare + run: pnpm install + + - name: 🔢 Update Version + run: | + cd packages/create-commandkit + node -e "const pkg = require('./package.json'); \ + const newVersion = pkg.version + '-dev.' + new Date().toISOString().replace(/[:\-T]/g, '').substr(0,14); \ + pkg.version = newVersion; \ + require('fs').writeFileSync('./package.json', JSON.stringify(pkg, null, 2));" + env: + DEBIAN_FRONTEND: noninteractive + + - name: 🚚 Publish + run: | + cd packages/create-commandkit + npm publish --access public --tag dev + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} + + - name: 🚫 Deprecate Previous Dev Version + run: | + PACKAGE_NAME=$(node -e "console.log(require('./packages/create-commandkit/package.json').name);") + ALL_VERSIONS=$(npm info $PACKAGE_NAME versions -json) + VERSION_TO_DEPRECATE=$(echo $ALL_VERSIONS | node -e " + const versions = JSON.parse(require('fs').readFileSync('/dev/stdin', 'utf-8')); + const devVersions = versions.filter(v => v.includes('-dev.')); + const versionToDeprecate = devVersions[devVersions.length - 2]; + console.log(versionToDeprecate); + ") + echo Deprecating version $VERSION_TO_DEPRECATE + npm deprecate $PACKAGE_NAME@$VERSION_TO_DEPRECATE "Deprecated dev version." + + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} diff --git a/packages/commandkit/package.json b/packages/commandkit/package.json index 57a90c6..a969f36 100644 --- a/packages/commandkit/package.json +++ b/packages/commandkit/package.json @@ -28,7 +28,6 @@ "dev": "tsup --watch", "build": "tsup", "deploy": "npm publish", - "deploy-dev": "npm publish --access public --tag dev", "test": "vitest", "test:dev": "cd ./tests && node ../bin/index.mjs dev", "test:build": "cd ./tests && node ../bin/index.mjs build", diff --git a/packages/create-commandkit/.npmignore b/packages/create-commandkit/.npmignore new file mode 100644 index 0000000..173fdc2 --- /dev/null +++ b/packages/create-commandkit/.npmignore @@ -0,0 +1,11 @@ +/node_modules +/src +/tests +/.github +/.vscode +/.git +/.turbo + +.DS_Store +tsconfig.json +tsup.config.ts \ No newline at end of file diff --git a/packages/create-commandkit/package.json b/packages/create-commandkit/package.json index e0288e6..c2cd0b2 100644 --- a/packages/create-commandkit/package.json +++ b/packages/create-commandkit/package.json @@ -1,7 +1,7 @@ { "name": "create-commandkit", "description": "Effortlessly create a CommandKit project", - "version": "2.0.0", + "version": "1.1.4", "main": "./dist/index.js", "module": "./dist/index.js", "bin": "./dist/index.js", @@ -28,8 +28,10 @@ }, "homepage": "https://commandkit.js.org", "scripts": { + "lint": "tsc --noEmit", + "dev": "tsup --watch", "build": "tsup", - "lint": "tsc" + "deploy": "npm publish" }, "dependencies": { "@clack/prompts": "^0.7.0",