|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + tag: |
| 10 | + description: 'Tag to release (e.g., v4.2.0)' |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + |
| 14 | +jobs: |
| 15 | + test: |
| 16 | + uses: ./.github/workflows/test.yml |
| 17 | + |
| 18 | + build: |
| 19 | + needs: test |
| 20 | + runs-on: ubuntu-latest |
| 21 | + container: |
| 22 | + image: python:3.12-bookworm |
| 23 | + env: |
| 24 | + UV_LINK_MODE: copy |
| 25 | + UV_CACHE_DIR: /github/home/.cache/uv |
| 26 | + permissions: |
| 27 | + actions: write |
| 28 | + contents: write |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: Checkout code |
| 32 | + uses: actions/checkout@v6 |
| 33 | + with: |
| 34 | + submodules: recursive |
| 35 | + |
| 36 | + - name: Cache uv downloads |
| 37 | + uses: actions/cache@v5 |
| 38 | + with: |
| 39 | + path: /github/home/.cache/uv |
| 40 | + key: uvcache-${{ runner.os }}-${{ hashFiles('uv.lock', 'pyproject.toml') }} |
| 41 | + restore-keys: | |
| 42 | + uvcache-${{ runner.os }}- |
| 43 | +
|
| 44 | + - name: Extract version from tag |
| 45 | + id: version |
| 46 | + run: | |
| 47 | + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then |
| 48 | + VERSION=${{ inputs.tag }} |
| 49 | + else |
| 50 | + VERSION=${GITHUB_REF#refs/tags/} |
| 51 | + fi |
| 52 | + echo "version=${VERSION}" >> $GITHUB_OUTPUT |
| 53 | + echo "version_number=${VERSION#v}" >> $GITHUB_OUTPUT |
| 54 | +
|
| 55 | + - name: Add Debian sid repository |
| 56 | + run: | |
| 57 | + echo "deb http://deb.debian.org/debian sid main" >> /etc/apt/sources.list.d/sid.list |
| 58 | + echo 'Package: *\nPin: release a=sid\nPin-Priority: 100' > /etc/apt/preferences.d/sid |
| 59 | +
|
| 60 | + - name: Install system dependencies |
| 61 | + run: | |
| 62 | + apt-get update |
| 63 | + # Ensure /etc/os-release exists (required by some actions' OS detection). |
| 64 | + apt-get install -y base-files |
| 65 | + apt-get install -y build-essential pkg-config libbz2-dev |
| 66 | + apt-get install -y -t sid libmapnik-dev |
| 67 | +
|
| 68 | + - name: Install uv |
| 69 | + uses: astral-sh/setup-uv@v7 |
| 70 | + with: |
| 71 | + enable-cache: false |
| 72 | + |
| 73 | + - name: Build wheel and sdist |
| 74 | + run: | |
| 75 | + uv build --wheel --sdist |
| 76 | +
|
| 77 | + - name: Upload build artifacts |
| 78 | + uses: actions/upload-artifact@v4 |
| 79 | + with: |
| 80 | + name: dist |
| 81 | + path: dist/ |
| 82 | + retention-days: 7 |
| 83 | + |
| 84 | + - name: Create GitHub Release |
| 85 | + uses: softprops/action-gh-release@v2 |
| 86 | + if: github.event_name == 'push' |
| 87 | + with: |
| 88 | + tag_name: ${{ steps.version.outputs.version }} |
| 89 | + name: Release ${{ steps.version.outputs.version }} |
| 90 | + body: | |
| 91 | + ## Python Mapnik ${{ steps.version.outputs.version_number }} |
| 92 | + |
| 93 | + ### Installation |
| 94 | + |
| 95 | + Download the wheel file below and install: |
| 96 | + ```bash |
| 97 | + pip install mapnik-${{ steps.version.outputs.version_number }}-*.whl |
| 98 | + ``` |
| 99 | + |
| 100 | + Or install directly from GitHub: |
| 101 | + ```bash |
| 102 | + pip install https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.version }}/mapnik-${{ steps.version.outputs.version_number }}-cp312-cp312-linux_x86_64.whl |
| 103 | + ``` |
| 104 | + |
| 105 | + Or install from source: |
| 106 | + ```bash |
| 107 | + pip install git+https://github.com/${{ github.repository }}.git@${{ steps.version.outputs.version }} |
| 108 | + ``` |
| 109 | + |
| 110 | + ### Requirements |
| 111 | + |
| 112 | + - Python >= 3.8 |
| 113 | + - Mapnik >= 4.0.0 |
| 114 | + |
| 115 | + ### Changes |
| 116 | + |
| 117 | + See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/${{ steps.version.outputs.version }}/CHANGELOG.md) for details. |
| 118 | + files: | |
| 119 | + dist/*.whl |
| 120 | + dist/*.tar.gz |
| 121 | + draft: false |
| 122 | + prerelease: false |
| 123 | + env: |
| 124 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 125 | + |
| 126 | + - name: Summary |
| 127 | + run: | |
| 128 | + echo "## Release Summary" >> $GITHUB_STEP_SUMMARY |
| 129 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 130 | + echo "✅ Released version: **${{ steps.version.outputs.version }}**" >> $GITHUB_STEP_SUMMARY |
| 131 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 132 | + echo "### Artifacts Built:" >> $GITHUB_STEP_SUMMARY |
| 133 | + ls -lh dist/ >> $GITHUB_STEP_SUMMARY |
| 134 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 135 | + echo "### Distribution:" >> $GITHUB_STEP_SUMMARY |
| 136 | + echo "- GitHub Release: ✅" >> $GITHUB_STEP_SUMMARY |
0 commit comments