Skip to content

Commit

Permalink
Merge pull request #59 from underctrl-io/master
Browse files Browse the repository at this point in the history
feat: github actions for `create-commandkit`
  • Loading branch information
notunderctrl authored Feb 2, 2024
2 parents af9a25c + a0df3cc commit be0022c
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Dev Build
name: (CommandKit) Publish Dev Build

on:
push:
Expand Down Expand Up @@ -39,7 +39,9 @@ jobs:
DEBIAN_FRONTEND: noninteractive

- name: 🚚 Publish
run: pnpm run deploy:package-dev
run: |
cd packages/commandkit
npm publish --access public --tag dev
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}

Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/dev-create-commandkit.yaml
Original file line number Diff line number Diff line change
@@ -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}}
3 changes: 3 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
- name: 🍳 Prepare
run: pnpm install

- name: 🧱 Build
run: pnpm --filter './packages/*' run build

- name: 🚚 Publish
run: pnpm run deploy:package
env:
Expand Down
3 changes: 1 addition & 2 deletions packages/commandkit/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "commandkit",
"description": "Beginner friendly command & event handler for Discord.js",
"version": "0.1.10",
"version": "0.1.11",
"license": "MIT",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand All @@ -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",
Expand Down
11 changes: 11 additions & 0 deletions packages/create-commandkit/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/node_modules
/src
/tests
/.github
/.vscode
/.git
/.turbo

.DS_Store
tsconfig.json
tsup.config.ts
6 changes: 4 additions & 2 deletions packages/create-commandkit/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit be0022c

Please sign in to comment.