name: Release
on:
push:
tags:
- 'v*'
jobs:
build-executables:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
artifact_name: mcp-testing-sensei-linux
- os: windows-latest
artifact_name: mcp-testing-sensei-windows.exe
- os: macos-latest
artifact_name: mcp-testing-sensei-macos
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
- name: Install UPX
if: matrix.os != 'macos-latest' # UPX doesn't work well on macOS
uses: crazy-max/ghaction-upx@v3
with:
install-only: true
- name: Build executable
env:
PYTHONOPTIMIZE: 2
run: |
pyinstaller mcp_testing_sensei_optimized.spec --clean --log-level WARN
- name: Apply additional compression
if: matrix.os != 'macos-latest'
shell: bash
run: |
if [ "${{ matrix.os }}" == "windows-latest" ]; then
if upx --best --lzma dist/mcp-testing-sensei.exe; then
echo "UPX compression successful!"
else
echo "::warning::UPX compression failed, continuing with uncompressed executable"
fi
else
if upx --best --lzma dist/mcp-testing-sensei; then
echo "UPX compression successful!"
else
echo "::warning::UPX compression failed, continuing with uncompressed executable"
fi
fi
- name: Rename executable
shell: bash
run: |
if [ "${{ matrix.os }}" == "windows-latest" ]; then
mv dist/mcp-testing-sensei.exe dist/${{ matrix.artifact_name }}
else
mv dist/mcp-testing-sensei dist/${{ matrix.artifact_name }}
fi
- name: Upload executable
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: dist/${{ matrix.artifact_name }}
build-and-publish:
runs-on: ubuntu-latest
needs: build-executables
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
pip install -r requirements.txt
- name: Run tests
run: |
pip install pytest
pytest
- name: Build Python distribution
run: python -m build
- name: Build NPM package
run: npm pack
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python -m twine upload dist/*
- name: Publish to NPM
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm publish
- name: Build and push Docker image
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker build -t $DOCKER_USERNAME/mcp-testing-sensei:${GITHUB_REF#refs/tags/} .
docker tag $DOCKER_USERNAME/mcp-testing-sensei:${GITHUB_REF#refs/tags/} $DOCKER_USERNAME/mcp-testing-sensei:latest
docker push $DOCKER_USERNAME/mcp-testing-sensei:${GITHUB_REF#refs/tags/}
docker push $DOCKER_USERNAME/mcp-testing-sensei:latest
- name: Download executables
uses: actions/download-artifact@v4
with:
path: executables
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
dist/*
*.tgz
executables/*/*
generate_release_notes: true