diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..cf67dd5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,65 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Lint with Biome + run: npx biome check . + + typecheck: + name: Type check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Type check + run: npx tsc --build + + build: + name: Build CLI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Build CLI + run: npm run build:cli + + - name: Verify build output + run: test -f packages/cli/dist/index.js diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..912834b --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,72 @@ +name: Publish to npm + +on: + release: + types: [published] + +jobs: + validate: + name: Validate release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Check tag matches package version + run: | + TAG="${GITHUB_REF#refs/tags/v}" + PKG_VERSION=$(node -p "require('./packages/cli/package.json').version") + echo "Git tag version: $TAG" + echo "Package version: $PKG_VERSION" + if [ "$TAG" != "$PKG_VERSION" ]; then + echo "::error::Tag v$TAG does not match packages/cli/package.json version ($PKG_VERSION)" + exit 1 + fi + + - name: Lint + run: npx biome check . + + - name: Type check + run: npx tsc --build + + - name: Build CLI + run: npm run build:cli + + - name: Verify build output + run: test -f packages/cli/dist/index.js + + publish: + name: Publish to npm + needs: validate + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: npm + registry-url: 'https://registry.npmjs.org' + + - name: Install dependencies + run: npm ci + + - name: Build CLI + run: npm run build:cli + + - name: Publish to npm + run: npm publish -w @plexusui/cli --access public --provenance + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}