|
| 1 | +name: Release |
| 2 | + |
| 3 | +env: |
| 4 | + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + tags: |
| 9 | + - 'v*' |
| 10 | + workflow_dispatch: |
| 11 | + inputs: |
| 12 | + version: |
| 13 | + description: 'Version to release (e.g. 0.2.0)' |
| 14 | + required: true |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: write |
| 18 | + id-token: write |
| 19 | + |
| 20 | +jobs: |
| 21 | + test: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Set up Python |
| 27 | + uses: actions/setup-python@v5 |
| 28 | + with: |
| 29 | + python-version: '3.13' |
| 30 | + |
| 31 | + - name: Install and test |
| 32 | + run: | |
| 33 | + python -m pip install --upgrade pip |
| 34 | + pip install -e ".[dev]" |
| 35 | + python -m pytest tests/ -v --tb=short |
| 36 | +
|
| 37 | + build: |
| 38 | + needs: test |
| 39 | + runs-on: ubuntu-latest |
| 40 | + steps: |
| 41 | + - uses: actions/checkout@v4 |
| 42 | + |
| 43 | + - name: Set up Python |
| 44 | + uses: actions/setup-python@v5 |
| 45 | + with: |
| 46 | + python-version: '3.13' |
| 47 | + |
| 48 | + - name: Install build tools |
| 49 | + run: python -m pip install --upgrade pip setuptools wheel build |
| 50 | + |
| 51 | + - name: Determine version |
| 52 | + id: version |
| 53 | + run: | |
| 54 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 55 | + echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT |
| 56 | + else |
| 57 | + echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT |
| 58 | + fi |
| 59 | +
|
| 60 | + - name: Verify version matches __init__.py |
| 61 | + run: | |
| 62 | + EXPECTED="${{ steps.version.outputs.version }}" |
| 63 | + ACTUAL=$(python -c "import grncli; print(grncli.__version__)") |
| 64 | + if [ "$EXPECTED" != "$ACTUAL" ]; then |
| 65 | + echo "Version mismatch: tag=$EXPECTED, __init__.py=$ACTUAL" |
| 66 | + exit 1 |
| 67 | + fi |
| 68 | +
|
| 69 | + - name: Build wheel and sdist |
| 70 | + run: python -m build |
| 71 | + |
| 72 | + - name: Build offline bundle |
| 73 | + run: | |
| 74 | + pip install . |
| 75 | + bash scripts/make-bundle |
| 76 | +
|
| 77 | + - name: Upload PyPI artifacts |
| 78 | + uses: actions/upload-artifact@v4 |
| 79 | + with: |
| 80 | + name: pypi-dist |
| 81 | + path: | |
| 82 | + dist/*.whl |
| 83 | + dist/*.tar.gz |
| 84 | +
|
| 85 | + - name: Upload bundle artifact |
| 86 | + uses: actions/upload-artifact@v4 |
| 87 | + with: |
| 88 | + name: bundle |
| 89 | + path: dist/grncli-bundle.zip |
| 90 | + |
| 91 | + github-release: |
| 92 | + needs: build |
| 93 | + runs-on: ubuntu-latest |
| 94 | + steps: |
| 95 | + - uses: actions/download-artifact@v4 |
| 96 | + with: |
| 97 | + name: pypi-dist |
| 98 | + path: dist/ |
| 99 | + |
| 100 | + - uses: actions/download-artifact@v4 |
| 101 | + with: |
| 102 | + name: bundle |
| 103 | + path: dist/ |
| 104 | + |
| 105 | + - name: Create GitHub Release |
| 106 | + uses: softprops/action-gh-release@v2 |
| 107 | + with: |
| 108 | + tag_name: ${{ github.ref_name }} |
| 109 | + generate_release_notes: true |
| 110 | + files: | |
| 111 | + dist/*.whl |
| 112 | + dist/*.tar.gz |
| 113 | + dist/grncli-bundle.zip |
| 114 | +
|
| 115 | + publish-pypi: |
| 116 | + needs: build |
| 117 | + runs-on: ubuntu-latest |
| 118 | + environment: release |
| 119 | + steps: |
| 120 | + - uses: actions/download-artifact@v4 |
| 121 | + with: |
| 122 | + name: pypi-dist |
| 123 | + path: dist/ |
| 124 | + |
| 125 | + - name: Publish to PyPI |
| 126 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 127 | + with: |
| 128 | + password: ${{ secrets.PYPI_API_TOKEN }} |
| 129 | + attestations: false |
0 commit comments