Skip to content

Replace entire codebase with wish-ng implementation #50

Replace entire codebase with wish-ng implementation

Replace entire codebase with wish-ng implementation #50

Workflow file for this run

name: Publish to PyPI
on:
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g. 0.1.0)'
required: true
type: string
test_pypi:
description: 'Publish to Test PyPI first'
required: false
type: boolean
default: false
jobs:
# 1. Publish the foundation package (wish-models) first
publish-models:
name: Publish wish-models
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- name: Install build dependencies
run: |
uv pip install --system build twine
# Update version in pyproject.toml
- name: Update version in pyproject.toml
run: |
sed -i "s/version = \"[^\"]*\"/version = \"${{ inputs.version }}\"/" packages/wish-models/pyproject.toml
echo "Updated version in packages/wish-models/pyproject.toml to ${{ inputs.version }}"
grep -m 1 'version = ' packages/wish-models/pyproject.toml
- name: Build package
run: cd packages/wish-models && python -m build
- name: Publish to Test PyPI
if: ${{ inputs.test_pypi }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
run: cd packages/wish-models && twine upload --repository testpypi dist/*
- name: Publish to PyPI
if: ${{ !inputs.test_pypi }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: cd packages/wish-models && twine upload dist/*
# 2. Publish wish-core (depends on wish-models)
publish-core:
name: Publish wish-core
needs: publish-models
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- name: Install build dependencies
run: |
uv pip install --system build twine
# Update version in pyproject.toml
- name: Update version in pyproject.toml
run: |
sed -i "s/version = \"[^\"]*\"/version = \"${{ inputs.version }}\"/" packages/wish-core/pyproject.toml
echo "Updated version in packages/wish-core/pyproject.toml to ${{ inputs.version }}"
grep -m 1 'version = ' packages/wish-core/pyproject.toml
# Update dependency versions
- name: Update dependency versions
run: |
sed -i "s/wish-models[^\"]*\"/wish-models==${{ inputs.version }}\"/" packages/wish-core/pyproject.toml
echo "Updated dependency versions in packages/wish-core/pyproject.toml"
- name: Build package
run: cd packages/wish-core && python -m build
- name: Publish to Test PyPI
if: ${{ inputs.test_pypi }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
run: cd packages/wish-core && twine upload --repository testpypi dist/*
- name: Publish to PyPI
if: ${{ !inputs.test_pypi }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: cd packages/wish-core && twine upload dist/*
# 3. Publish intermediate packages (packages that depend on core/models)
publish-dependencies:
name: Publish wish dependencies
needs: publish-core
runs-on: ubuntu-latest
strategy:
matrix:
package:
- wish-knowledge
- wish-tools
- wish-c2
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- name: Install build dependencies
run: |
uv pip install --system build twine
# Update version in pyproject.toml
- name: Update version in pyproject.toml
run: |
sed -i "s/version = \"[^\"]*\"/version = \"${{ inputs.version }}\"/" packages/${{ matrix.package }}/pyproject.toml
echo "Updated version in packages/${{ matrix.package }}/pyproject.toml to ${{ inputs.version }}"
grep -m 1 'version = ' packages/${{ matrix.package }}/pyproject.toml
# Update dependency versions
- name: Update dependency versions
run: |
sed -i "s/wish-models[^\"]*\"/wish-models==${{ inputs.version }}\"/" packages/${{ matrix.package }}/pyproject.toml
sed -i "s/wish-core[^\"]*\"/wish-core==${{ inputs.version }}\"/" packages/${{ matrix.package }}/pyproject.toml
echo "Updated dependency versions in packages/${{ matrix.package }}/pyproject.toml"
- name: Build package
run: cd packages/${{ matrix.package }} && python -m build
- name: Publish to Test PyPI
if: ${{ inputs.test_pypi }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
run: cd packages/${{ matrix.package }} && twine upload --repository testpypi dist/*
- name: Publish to PyPI
if: ${{ !inputs.test_pypi }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: cd packages/${{ matrix.package }} && twine upload dist/*
# 4. Publish wish-ai (depends on models, core, knowledge)
publish-ai:
name: Publish wish-ai
needs: publish-dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- name: Install build dependencies
run: |
uv pip install --system build twine
# Update version in pyproject.toml
- name: Update version in pyproject.toml
run: |
sed -i "s/version = \"[^\"]*\"/version = \"${{ inputs.version }}\"/" packages/wish-ai/pyproject.toml
echo "Updated version in packages/wish-ai/pyproject.toml to ${{ inputs.version }}"
grep -m 1 'version = ' packages/wish-ai/pyproject.toml
# Update dependency versions
- name: Update dependency versions
run: |
sed -i "s/wish-models[^\"]*\"/wish-models==${{ inputs.version }}\"/" packages/wish-ai/pyproject.toml
sed -i "s/wish-core[^\"]*\"/wish-core==${{ inputs.version }}\"/" packages/wish-ai/pyproject.toml
sed -i "s/wish-knowledge[^\"]*\"/wish-knowledge==${{ inputs.version }}\"/" packages/wish-ai/pyproject.toml
echo "Updated dependency versions in packages/wish-ai/pyproject.toml"
- name: Build package
run: cd packages/wish-ai && python -m build
- name: Publish to Test PyPI
if: ${{ inputs.test_pypi }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
run: cd packages/wish-ai && twine upload --repository testpypi dist/*
- name: Publish to PyPI
if: ${{ !inputs.test_pypi }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: cd packages/wish-ai && twine upload dist/*
# 5. Publish wish-cli (depends on all packages)
publish-cli:
name: Publish wish-cli
needs: publish-ai
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- name: Install build dependencies
run: |
uv pip install --system build twine
# Update version in pyproject.toml
- name: Update version in pyproject.toml
run: |
sed -i "s/version = \"[^\"]*\"/version = \"${{ inputs.version }}\"/" packages/wish-cli/pyproject.toml
echo "Updated version in packages/wish-cli/pyproject.toml to ${{ inputs.version }}"
grep -m 1 'version = ' packages/wish-cli/pyproject.toml
# Update dependency versions
- name: Update dependency versions
run: |
sed -i "s/wish-models[^\"]*\"/wish-models==${{ inputs.version }}\"/" packages/wish-cli/pyproject.toml
sed -i "s/wish-core[^\"]*\"/wish-core==${{ inputs.version }}\"/" packages/wish-cli/pyproject.toml
sed -i "s/wish-knowledge[^\"]*\"/wish-knowledge==${{ inputs.version }}\"/" packages/wish-cli/pyproject.toml
sed -i "s/wish-ai[^\"]*\"/wish-ai==${{ inputs.version }}\"/" packages/wish-cli/pyproject.toml
sed -i "s/wish-tools[^\"]*\"/wish-tools==${{ inputs.version }}\"/" packages/wish-cli/pyproject.toml
sed -i "s/wish-c2[^\"]*\"/wish-c2==${{ inputs.version }}\"/" packages/wish-cli/pyproject.toml
echo "Updated dependency versions in packages/wish-cli/pyproject.toml"
- name: Build package
run: cd packages/wish-cli && python -m build
- name: Publish to Test PyPI
if: ${{ inputs.test_pypi }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
run: cd packages/wish-cli && twine upload --repository testpypi dist/*
- name: Publish to PyPI
if: ${{ !inputs.test_pypi }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: cd packages/wish-cli && twine upload dist/*
# 6. Publish the meta package (wish-sh)
publish-sh:
name: Publish wish-sh
needs: publish-cli
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- name: Install build dependencies
run: |
uv pip install --system build twine
# Update version in pyproject.toml
- name: Update version in pyproject.toml
run: |
sed -i "s/version = \"[^\"]*\"/version = \"${{ inputs.version }}\"/" pyproject.toml
echo "Updated version in pyproject.toml to ${{ inputs.version }}"
grep -m 1 'version = ' pyproject.toml
# Update dependency versions
- name: Update dependency versions
run: |
sed -i "s/wish-cli[^\"]*\"/wish-cli==${{ inputs.version }}\"/" pyproject.toml
echo "Updated dependency versions in pyproject.toml"
- name: Build package
run: python -m build
- name: Publish to Test PyPI
if: ${{ inputs.test_pypi }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
run: twine upload --repository testpypi dist/*
- name: Publish to PyPI
if: ${{ !inputs.test_pypi }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*
# 7. Update CHANGELOG.md and create GitHub release
update-changelog:
name: Update CHANGELOG and create release
needs: publish-sh
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Check if CHANGELOG.md exists
id: check-changelog
run: |
if [ -f "CHANGELOG.md" ]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Create initial CHANGELOG.md if not exists
if: steps.check-changelog.outputs.exists == 'false'
run: |
cat > CHANGELOG.md << 'EOF'
# Changelog
All notable changes to this project will be documented in this file.

Check failure on line 361 in .github/workflows/publish.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/publish.yml

Invalid workflow file

You have an error in your yaml syntax on line 361
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
### Changed
### Fixed
### Removed
EOF
- name: Update CHANGELOG.md
id: update-changelog
run: |
# Get current date in YYYY-MM-DD format
RELEASE_DATE=$(date +%Y-%m-%d)
# Create a new version section from Unreleased
sed -i "/## \[Unreleased\]/a \\\n## [${{ inputs.version }}] - ${RELEASE_DATE}" CHANGELOG.md
# Create new empty Unreleased section
sed -i "/## \[Unreleased\]/a \\\n### Added\n\n### Changed\n\n### Fixed\n\n### Removed\n" CHANGELOG.md
# Extract the content for the new release (everything between the new version header and the next version header)
VERSION_CONTENT=$(sed -n "/## \[${{ inputs.version }}\]/,/## \[/p" CHANGELOG.md | sed '1d;$d')
echo "VERSION_CONTENT<<EOF" >> $GITHUB_OUTPUT
echo "$VERSION_CONTENT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Commit CHANGELOG.md changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add CHANGELOG.md
git commit -m "Update CHANGELOG.md for version ${{ inputs.version }}" || echo "No changes to commit"
git push || echo "No changes to push"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ inputs.version }}
name: Release v${{ inputs.version }}
body: |
## PyPI Packages
This release includes the following packages on PyPI:
- [wish-sh](https://pypi.org/project/wish-sh/${{ inputs.version }}/) - Main meta package
- [wish-cli](https://pypi.org/project/wish-cli/${{ inputs.version }}/) - CLI interface
- [wish-ai](https://pypi.org/project/wish-ai/${{ inputs.version }}/) - AI capabilities
- [wish-core](https://pypi.org/project/wish-core/${{ inputs.version }}/) - Core functionality
- [wish-models](https://pypi.org/project/wish-models/${{ inputs.version }}/) - Data models
- [wish-knowledge](https://pypi.org/project/wish-knowledge/${{ inputs.version }}/) - Knowledge base
- [wish-tools](https://pypi.org/project/wish-tools/${{ inputs.version }}/) - Pentesting tools
- [wish-c2](https://pypi.org/project/wish-c2/${{ inputs.version }}/) - C2 integration
## Installation
```bash
pip install wish-sh==${{ inputs.version }}
```
## Changelog
${{ steps.update-changelog.outputs.VERSION_CONTENT }}
draft: false
prerelease: false