diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..99fc97f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,40 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x, 20.x, 22.x] + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Type check + run: npm run typecheck + + - name: Run tests + run: npm test + + - name: Build + run: npm run build + + - name: Build web frontend + run: npm run build:web diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1dd9c74 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,128 @@ +name: Build and Release + +on: + push: + tags: + - 'v*' + workflow_dispatch: + inputs: + version: + description: 'Version to release (e.g., 0.1.0)' + required: false + +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + registry-url: 'https://registry.npmjs.org' + + - name: Install dependencies + run: npm ci + + - name: Run tests + run: npm test + + - name: Build TypeScript + run: npm run build + + - name: Build web frontend + run: npm run build:web + + - name: Create distribution package + run: | + mkdir -p release + cp -r dist release/ + cp -r node_modules release/ + cp package.json release/ + cp README.md release/ + # Create wrapper script + cat > release/fabric << 'SCRIPT' + #!/usr/bin/env node + require('./dist/cli.js'); + SCRIPT + chmod +x release/fabric + + - name: Create archives + run: | + cd release + tar -czvf ../fabric-linux-x64.tar.gz . + zip -r ../fabric-linux-x64.zip . + + - name: Get version + id: version + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.version }}" ]; then + echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT + else + echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + fi + + - name: Create Release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ steps.version.outputs.VERSION }} + name: FABRIC v${{ steps.version.outputs.VERSION }} + body: | + ## FABRIC v${{ steps.version.outputs.VERSION }} + + Flow Analysis & Bead Reporting Interface Console + + ### Installation + + ```bash + # Download and extract + curl -L https://github.com/jedarden/FABRIC/releases/download/v${{ steps.version.outputs.VERSION }}/fabric-linux-x64.tar.gz | tar xz + + # Run + ./fabric tui # Terminal UI + ./fabric web # Web dashboard + ``` + + ### Requirements + - Node.js >= 18.0.0 + + files: | + fabric-linux-x64.tar.gz + fabric-linux-x64.zip + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # Optional: Publish to npm + publish-npm: + runs-on: ubuntu-latest + needs: build + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + registry-url: 'https://registry.npmjs.org' + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: Publish to npm + run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}