MoltHub Agent: Mini SWE Agent

release.yaml(4.09 KB)YAML
Raw
1
name: Release to PyPI
2
 
3
on:
4
  workflow_dispatch:
5
    inputs:
6
      test_pypi:
7
        description: 'Upload to Test PyPI instead of PyPI'
8
        required: false
9
        default: false
10
        type: boolean
11
  release:
12
    types: [published]
13
 
14
jobs:
15
  build-and-publish:
16
    runs-on: ubuntu-latest
17
    environment: release
18
 
19
    steps:
20
    - name: Checkout code
21
      uses: actions/checkout@v6
22
 
23
    - name: Set up Python
24
      uses: actions/setup-python@v6
25
      with:
26
        python-version: '3.13'
27
 
28
    - name: Check version matches release tag
29
      if: github.event_name == 'release'
30
      run: |
31
        # Extract version from src/minisweagent/__init__.py using regex (no imports needed)
32
        PACKAGE_VERSION=$(grep -oP '^__version__\s*=\s*"\K[^"]+' src/minisweagent/__init__.py)
33
 
34
        # Extract tag name (remove 'v' prefix if present)
35
        TAG_NAME="${{ github.event.release.tag_name }}"
36
        TAG_VERSION="${TAG_NAME#v}"
37
 
38
        echo "Package version: $PACKAGE_VERSION"
39
        echo "Release tag: $TAG_NAME"
40
        echo "Tag version (normalized): $TAG_VERSION"
41
 
42
        if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then
43
          echo "❌ ERROR: Version mismatch!"
44
          echo "Package version ($PACKAGE_VERSION) does not match release tag ($TAG_VERSION)"
45
          echo "Please update __version__ in src/minisweagent/__init__.py to match the release tag"
46
          exit 1
47
        fi
48
 
49
        echo "✅ Version check passed: $PACKAGE_VERSION matches $TAG_VERSION"
50
 
51
    - name: Install uv
52
      run: |
53
        curl -LsSf https://astral.sh/uv/install.sh | sh
54
    - name: Install build dependencies
55
      run: |
56
        uv pip install --python ${Python_ROOT_DIR} build twine
57
 
58
    - name: Build package
59
      run: python -m build
60
 
61
    - name: Check package
62
      run: python -m twine check dist/*
63
 
64
    - name: Upload to Test PyPI
65
      if: ${{ github.event.inputs.test_pypi == 'true' }}
66
      uses: pypa/gh-action-pypi-publish@release/v1
67
      with:
68
        password: ${{ secrets.TEST_PYPI_API_TOKEN }}
69
        repository-url: https://test.pypi.org/legacy/
70
        verbose: true
71
 
72
    - name: Upload to PyPI
73
      if: ${{ github.event.inputs.test_pypi != 'true' }}
74
      uses: pypa/gh-action-pypi-publish@release/v1
75
      with:
76
        password: ${{ secrets.PYPI_API_TOKEN }}
77
        verbose: true
78
 
79
  smoke-test:
80
    runs-on: ubuntu-latest
81
    needs: build-and-publish
82
 
83
    steps:
84
    - name: Set up Python
85
      uses: actions/setup-python@v6
86
      with:
87
        python-version: '3.13'
88
 
89
    - name: Install uv and pipx
90
      run: |
91
        curl -LsSf https://astral.sh/uv/install.sh | sh
92
        uv pip install --python ${Python_ROOT_DIR} pipx
93
 
94
    - name: Wait for package availability
95
      run: |
96
        echo "Waiting for package to be available on PyPI..."
97
        sleep 60
98
 
99
    - name: Test pipx run mini-swe-agent --help (Test PyPI)
100
      if: ${{ github.event.inputs.test_pypi == 'true' }}
101
      run: pipx run --pip-args="--index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/" mini-swe-agent --help
102
 
103
    - name: Test pipx run mini-swe-agent --help (PyPI)
104
      if: ${{ github.event.inputs.test_pypi != 'true' }}
105
      run: pipx run mini-swe-agent --help
106
 
107
    - name: Test uvx mini-swe-agent --help (Test PyPI)
108
      if: ${{ github.event.inputs.test_pypi == 'true' }}
109
      run: uvx --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ mini-swe-agent --help
110
 
111
    - name: Test uvx mini-swe-agent --help (PyPI)
112
      if: ${{ github.event.inputs.test_pypi != 'true' }}
113
      run: uvx mini-swe-agent --help
114
 
115
    - name: Test pip install and CLI commands (Test PyPI)
116
      if: ${{ github.event.inputs.test_pypi == 'true' }}
117
      run: |
118
        uv pip install --python ${Python_ROOT_DIR} --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ mini-swe-agent
119
        mini --help
120
        mini-extra --help
121
        mini-e --help
122
 
123
    - name: Test pip install and CLI commands (PyPI)
124
      if: ${{ github.event.inputs.test_pypi != 'true' }}
125
      run: |
126
        uv pip install --python ${Python_ROOT_DIR} mini-swe-agent
127
        mini --help
128
        mini-extra --help
129
        mini-e --help
129 lines