diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 9ceabbd..e2feeaa 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -1,6 +1,9 @@ name: check on: + push: + branches: + - main pull_request: branches: - main diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ae4efa3..2d28b82 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,18 +12,42 @@ jobs: build: runs-on: ubuntu-latest name: build and deploy + strategy: + matrix: + platform: [darwin, linux] + arch: [x64, arm64] steps: - uses: actions/checkout@v4 - uses: oven-sh/setup-bun@v1 - uses: pnpm/action-setup@v2 with: version: 8 - - name: install dependencies - run: bun install - - name: check prettier - run: bun run prettier - - name: add prepatch version - run: pnpm version prepatch --preid="pr-$GITHUB_RUN_ID" --no-git-tag-version + - run: bun install + - run: bun build . --target="bun-${{ matrix.platform }}-${{ matrix.arch }}" --outfile="bin/${{ matrix.platform }}-${{ matrix.arch }}" --compile + # upload the build artifact + - uses: actions/upload-artifact@v4 + with: + path: bin + name: ${{ matrix.platform }}-${{ matrix.arch }} + deploy: + runs-on: ubuntu-latest + name: deploy + needs: build + steps: + - uses: actions/checkout@v4 + - uses: oven-sh/setup-bun@v1 + - uses: pnpm/action-setup@v2 + with: + version: 8 + - uses: actions/cache/restore@v4 + with: + path: | + **/node_modules + key: ${{ runner.os }}-node-${{ hashFiles('**/bun.lockb') }} + - uses: actions/download-artifact@v4 + with: + path: bin + - run: pnpm version prepatch --preid="pr-$GITHUB_RUN_ID" --no-git-tag-version if: github.event_name == 'pull_request' - name: authenticate with npm run: echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc diff --git a/bin/moonx b/bin/moonx deleted file mode 100755 index 13ddcea..0000000 --- a/bin/moonx +++ /dev/null @@ -1,5 +0,0 @@ -#! /usr/bin/env bash - -echo "This is a placeholder for the moonx binary." -echo "Please run "bun run build" to build the moonx binary." -exit 1 diff --git a/bun.lockb b/bun.lockb index e04cb5a..abda2e2 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 96dee82..441b3bd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@maastrich/moonx", - "version": "0.1.3", + "version": "0.1.4", "description": "A CLI tool to help you with moon syntax", "keywords": [ "moon", @@ -17,32 +17,30 @@ "mx": "bin/moonx" }, "files": [ - "src", - "bin" + "bin", + "scripts/setup-binary.js" ], "scripts": { "build": "bun build --compile . --outfile=\"bin/moonx\"", - "postinstall": "bun run build", + "postinstall": "node scripts/setup-binary.js", "prettier": "prettier --write .", "semver-check": "bun run scripts/semver-check.ts", "sort": "bun x sort-package-json" }, - "dependencies": { - "@moonrepo/types": "^1.21.3", - "cac": "^6.7.14", - "chalk": "^5.3.0", - "node-emoji": "^2.1.0", - "nunjucks": "^3.2.4", - "yaml": "^2.3.4" - }, "devDependencies": { + "@moonrepo/types": "^1.21.3", "@trivago/prettier-plugin-sort-imports": "^4.2.1", "@types/nunjucks": "^3.2.6", "@types/semver": "^7.5.5", "@withfig/autocomplete-types": "^1.29.0", "bun-types": "^1.0.11", + "cac": "^6.7.14", + "chalk": "^5.3.0", + "node-emoji": "^2.1.0", + "nunjucks": "^3.2.4", "prettier": "^3.0.3", "semver": "^7.6.3", - "sort-package-json": "^2.6.0" + "sort-package-json": "^2.6.0", + "yaml": "^2.3.4" } } diff --git a/scripts/setup-binary.js b/scripts/setup-binary.js new file mode 100644 index 0000000..f118238 --- /dev/null +++ b/scripts/setup-binary.js @@ -0,0 +1,20 @@ +import { chmodSync, existsSync, renameSync } from "node:fs"; +import { join } from "node:path"; + +const { platform, arch } = process; + +const src = join( + process.cwd(), + "bin", + `${platform}-${arch}`, + `${platform}-${arch}`, +); +const dest = join(process.cwd(), "bin", "moonx"); + +if (!existsSync(src)) { + console.error(`Binary not found: ${src}`); + process.exit(0); +} + +renameSync(src, dest); +chmodSync(dest, 0o755); diff --git a/src/index.ts b/src/index.ts index 985e36c..adb0f3e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -62,7 +62,7 @@ for (const [name, workspaces] of commands) { return; } - return moon([filterd.map((ws) => `${name}:${ws}`), rest].flat(), { + return moon([filterd.map((ws) => `${ws}:${name}`), rest].flat(), { stdout: "inherit", stderr: "inherit", stdin: "inherit",