codeflash/.github/workflows/build-binaries.yml
2026-01-21 05:28:03 +05:30

165 lines
4.1 KiB
YAML

name: Build Binaries
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to build (e.g., 1.0.0)'
required: false
default: 'dev'
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: linux-x64
artifact_name: codeflash-linux-x64
- os: macos-13
target: darwin-x64
artifact_name: codeflash-darwin-x64
- os: macos-14
target: darwin-arm64
artifact_name: codeflash-darwin-arm64
- os: windows-latest
target: win-x64
artifact_name: codeflash-win-x64.exe
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyinstaller
pip install -e .
- name: Build binary
run: |
pyinstaller codeflash.spec --noconfirm
shell: bash
- name: Rename binary (Unix)
if: runner.os != 'Windows'
run: |
mv dist/codeflash dist/${{ matrix.artifact_name }}
- name: Rename binary (Windows)
if: runner.os == 'Windows'
run: |
move dist\codeflash.exe dist\${{ matrix.artifact_name }}
shell: cmd
- name: Test binary
run: |
./dist/${{ matrix.artifact_name }} --version
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: dist/${{ matrix.artifact_name }}
retention-days: 30
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: binaries
merge-multiple: true
- name: List binaries
run: ls -la binaries/
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: binaries/*
generate_release_notes: true
draft: false
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-npm:
name: Publish to npm
needs: release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Extract version from tag
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Update package.json version
working-directory: npm-package
run: |
npm version ${{ steps.version.outputs.VERSION }} --no-git-tag-version
- name: Publish to npm
working-directory: npm-package
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-pypi:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: python -m build
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: twine upload dist/*