feat: absorb caozhiyuan/copilot-api upstream changes #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [master] | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| workflow_dispatch: | |
| jobs: | |
| verify: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Run linter | |
| run: bun run lint:all | |
| - name: Run type check | |
| run: bun run typecheck | |
| - name: Run tests | |
| run: bun test | |
| - name: Build | |
| run: bun run build | |
| build-binary: | |
| name: Build Binary (${{ matrix.platform_name }}) | |
| needs: verify | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform_name: linux-x64 | |
| bun_target: bun-linux-x64-baseline | |
| install_os: linux | |
| install_cpu: x64 | |
| binary_ext: "" | |
| - platform_name: darwin-arm64 | |
| bun_target: bun-darwin-arm64 | |
| install_os: darwin | |
| install_cpu: arm64 | |
| binary_ext: "" | |
| - platform_name: windows-x64 | |
| bun_target: bun-windows-x64-baseline | |
| install_os: win32 | |
| install_cpu: x64 | |
| binary_ext: ".exe" | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies for target platform | |
| run: bun install --frozen-lockfile --os=${{ matrix.install_os }} --cpu=${{ matrix.install_cpu }} | |
| - name: Read package metadata | |
| id: meta | |
| env: | |
| PLATFORM_NAME: ${{ matrix.platform_name }} | |
| run: | | |
| VERSION="$(bun -e 'const pkg = JSON.parse(await Bun.file("package.json").text()); process.stdout.write(pkg.version)')" | |
| PACKAGE_DIR="Copilot-DirectAPI_v${VERSION}_${PLATFORM_NAME}" | |
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | |
| echo "package_dir=${PACKAGE_DIR}" >> "$GITHUB_OUTPUT" | |
| - name: Compile standalone binary | |
| env: | |
| BUN_TARGET: ${{ matrix.bun_target }} | |
| BINARY_EXT: ${{ matrix.binary_ext }} | |
| PACKAGE_DIR: ${{ steps.meta.outputs.package_dir }} | |
| run: | | |
| mkdir -p "dist/${PACKAGE_DIR}" | |
| bun build --compile --target="${BUN_TARGET}" ./src/main.ts --outfile "dist/${PACKAGE_DIR}/Copilot-DirectAPI${BINARY_EXT}" | |
| if [ -z "${BINARY_EXT}" ]; then | |
| chmod +x "dist/${PACKAGE_DIR}/Copilot-DirectAPI" | |
| fi | |
| cp README.md LICENSE "dist/${PACKAGE_DIR}/" | |
| - name: Smoke test Linux binary | |
| if: matrix.platform_name == 'linux-x64' | |
| env: | |
| PACKAGE_DIR: ${{ steps.meta.outputs.package_dir }} | |
| run: | | |
| chmod +x "dist/${PACKAGE_DIR}/Copilot-DirectAPI" | |
| "./dist/${PACKAGE_DIR}/Copilot-DirectAPI" debug --json >/dev/null | |
| - name: Package artifact | |
| id: package | |
| env: | |
| PACKAGE_DIR: ${{ steps.meta.outputs.package_dir }} | |
| run: | | |
| tar -C dist -czf "dist/${PACKAGE_DIR}.tar.gz" "${PACKAGE_DIR}" | |
| echo "asset=dist/${PACKAGE_DIR}.tar.gz" >> "$GITHUB_OUTPUT" | |
| echo "asset_name=${PACKAGE_DIR}.tar.gz" >> "$GITHUB_OUTPUT" | |
| - name: Upload platform artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ${{ steps.package.outputs.asset_name }} | |
| path: ${{ steps.package.outputs.asset }} | |
| if-no-files-found: error | |
| retention-days: 14 |