|
| 1 | +name: Release & Publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*' |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + pages: write |
| 11 | + id-token: write |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: release-${{ github.ref }} |
| 15 | + cancel-in-progress: false |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + name: Build Distribution |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Checkout code |
| 23 | + uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + fetch-depth: 0 # Full history for version calculation |
| 26 | + |
| 27 | + - name: Set up Python |
| 28 | + uses: actions/setup-python@v5 |
| 29 | + with: |
| 30 | + python-version: '3.12' |
| 31 | + |
| 32 | + - name: Install uv |
| 33 | + uses: astral-sh/setup-uv@v5 |
| 34 | + with: |
| 35 | + enable-cache: true |
| 36 | + |
| 37 | + - name: Build package |
| 38 | + run: uv build |
| 39 | + |
| 40 | + - name: Verify build |
| 41 | + run: | |
| 42 | + ls -lh dist/ |
| 43 | + echo "Built packages:" |
| 44 | + ls -1 dist/ |
| 45 | +
|
| 46 | + - name: Upload build artifacts |
| 47 | + uses: actions/upload-artifact@v4 |
| 48 | + with: |
| 49 | + name: dist |
| 50 | + path: dist/ |
| 51 | + retention-days: 90 |
| 52 | + |
| 53 | + release: |
| 54 | + name: Create GitHub Release |
| 55 | + needs: build |
| 56 | + runs-on: ubuntu-latest |
| 57 | + steps: |
| 58 | + - name: Checkout code |
| 59 | + uses: actions/checkout@v4 |
| 60 | + |
| 61 | + - name: Download build artifacts |
| 62 | + uses: actions/download-artifact@v4 |
| 63 | + with: |
| 64 | + name: dist |
| 65 | + path: dist/ |
| 66 | + |
| 67 | + - name: Extract release notes |
| 68 | + id: release_notes |
| 69 | + run: | |
| 70 | + TAG=${GITHUB_REF#refs/tags/} |
| 71 | + echo "tag=$TAG" >> $GITHUB_OUTPUT |
| 72 | +
|
| 73 | + # Create release notes |
| 74 | + cat > release_notes.md << EOF |
| 75 | + ## tablespec $TAG |
| 76 | +
|
| 77 | + ### Installation |
| 78 | +
|
| 79 | + \`\`\`bash |
| 80 | + # From GitHub Pages index |
| 81 | + pip install tablespec==${TAG#v} --index-url https://easel.github.io/tablespec/simple/ |
| 82 | +
|
| 83 | + # With PySpark support |
| 84 | + pip install tablespec[spark]==${TAG#v} --index-url https://easel.github.io/tablespec/simple/ |
| 85 | + \`\`\` |
| 86 | +
|
| 87 | + ### What's Changed |
| 88 | +
|
| 89 | + See the [commit history](https://github.com/easel/tablespec/commits/$TAG) for details. |
| 90 | +
|
| 91 | + ### Artifacts |
| 92 | +
|
| 93 | + - Source distribution (sdist): \`tablespec-${TAG#v}.tar.gz\` |
| 94 | + - Wheel distribution: \`tablespec-${TAG#v}-py3-none-any.whl\` |
| 95 | + EOF |
| 96 | +
|
| 97 | + - name: Create GitHub Release |
| 98 | + uses: softprops/action-gh-release@v2 |
| 99 | + with: |
| 100 | + files: dist/* |
| 101 | + body_path: release_notes.md |
| 102 | + draft: false |
| 103 | + prerelease: ${{ contains(steps.release_notes.outputs.tag, 'rc') || contains(steps.release_notes.outputs.tag, 'alpha') || contains(steps.release_notes.outputs.tag, 'beta') }} |
| 104 | + env: |
| 105 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 106 | + |
| 107 | + build-index: |
| 108 | + name: Build PyPI Index for GitHub Pages |
| 109 | + needs: build |
| 110 | + runs-on: ubuntu-latest |
| 111 | + steps: |
| 112 | + - name: Checkout code |
| 113 | + uses: actions/checkout@v4 |
| 114 | + |
| 115 | + - name: Download build artifacts |
| 116 | + uses: actions/download-artifact@v4 |
| 117 | + with: |
| 118 | + name: dist |
| 119 | + path: dist/ |
| 120 | + |
| 121 | + - name: Generate PyPI-compatible index |
| 122 | + run: | |
| 123 | + mkdir -p pages/simple/tablespec |
| 124 | +
|
| 125 | + # Create root index.html |
| 126 | + cat > pages/index.html << 'EOF' |
| 127 | + <!DOCTYPE html> |
| 128 | + <html> |
| 129 | + <head> |
| 130 | + <title>tablespec - Private PyPI Repository</title> |
| 131 | + <style> |
| 132 | + body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; margin: 40px; } |
| 133 | + h1 { color: #0366d6; } |
| 134 | + code { background: #f6f8fa; padding: 2px 6px; border-radius: 3px; } |
| 135 | + pre { background: #f6f8fa; padding: 16px; border-radius: 6px; overflow-x: auto; } |
| 136 | + .container { max-width: 800px; margin: 0 auto; } |
| 137 | + .badge { display: inline-block; padding: 4px 8px; background: #0366d6; color: white; border-radius: 3px; font-size: 12px; margin: 4px; } |
| 138 | + </style> |
| 139 | + </head> |
| 140 | + <body> |
| 141 | + <div class="container"> |
| 142 | + <h1>📊 tablespec</h1> |
| 143 | + <p><span class="badge">Python 3.12+</span> <span class="badge">Apache 2.0</span></p> |
| 144 | + <p>Python library for working with table schemas in Universal Metadata Format (UMF)</p> |
| 145 | +
|
| 146 | + <h2>Installation</h2> |
| 147 | + <pre>pip install tablespec --index-url https://easel.github.io/tablespec/simple/</pre> |
| 148 | +
|
| 149 | + <h2>Quick Start</h2> |
| 150 | + <pre> |
| 151 | + # Load and validate UMF schema |
| 152 | + from tablespec import load_umf_from_yaml, generate_sql_ddl |
| 153 | +
|
| 154 | + umf = load_umf_from_yaml("schema.yaml") |
| 155 | + ddl = generate_sql_ddl(umf) |
| 156 | + print(ddl) |
| 157 | +
|
| 158 | + # With PySpark support |
| 159 | + pip install tablespec[spark] --index-url https://easel.github.io/tablespec/simple/ |
| 160 | + </pre> |
| 161 | +
|
| 162 | + <h2>Available Packages</h2> |
| 163 | + <ul> |
| 164 | + <li><a href="simple/tablespec/">tablespec</a></li> |
| 165 | + </ul> |
| 166 | +
|
| 167 | + <h2>Links</h2> |
| 168 | + <ul> |
| 169 | + <li><a href="https://github.com/easel/tablespec">GitHub Repository</a></li> |
| 170 | + </ul> |
| 171 | + </div> |
| 172 | + </body> |
| 173 | + </html> |
| 174 | + EOF |
| 175 | +
|
| 176 | + # Create simple/index.html (PEP 503) |
| 177 | + cat > pages/simple/index.html << 'EOF' |
| 178 | + <!DOCTYPE html> |
| 179 | + <html> |
| 180 | + <head><title>Simple Index</title></head> |
| 181 | + <body> |
| 182 | + <h1>Simple Index</h1> |
| 183 | + <a href="tablespec/">tablespec</a><br/> |
| 184 | + </body> |
| 185 | + </html> |
| 186 | + EOF |
| 187 | +
|
| 188 | + # Create package index with all versions |
| 189 | + cat > pages/simple/tablespec/index.html << 'PKGEOF' |
| 190 | + <!DOCTYPE html> |
| 191 | + <html> |
| 192 | + <head><title>Links for tablespec</title></head> |
| 193 | + <body> |
| 194 | + <h1>Links for tablespec</h1> |
| 195 | + PKGEOF |
| 196 | +
|
| 197 | + # Add links to all distribution files |
| 198 | + for file in dist/*; do |
| 199 | + filename=$(basename "$file") |
| 200 | + # Calculate SHA256 hash |
| 201 | + hash=$(sha256sum "$file" | cut -d' ' -f1) |
| 202 | + echo " <a href=\"../../../releases/download/${GITHUB_REF#refs/tags/}/$filename#sha256=$hash\">$filename</a><br/>" >> pages/simple/tablespec/index.html |
| 203 | + done |
| 204 | +
|
| 205 | + # Close HTML |
| 206 | + cat >> pages/simple/tablespec/index.html << 'PKGEOF' |
| 207 | + </body> |
| 208 | + </html> |
| 209 | + PKGEOF |
| 210 | +
|
| 211 | + # Create .nojekyll to disable Jekyll processing |
| 212 | + touch pages/.nojekyll |
| 213 | +
|
| 214 | + echo "Generated index structure:" |
| 215 | + find pages -type f -exec echo " {}" \; |
| 216 | +
|
| 217 | + - name: Upload Pages artifact |
| 218 | + uses: actions/upload-pages-artifact@v3 |
| 219 | + with: |
| 220 | + path: pages/ |
| 221 | + |
| 222 | + deploy-pages: |
| 223 | + name: Deploy to GitHub Pages |
| 224 | + needs: build-index |
| 225 | + runs-on: ubuntu-latest |
| 226 | + permissions: |
| 227 | + pages: write |
| 228 | + id-token: write |
| 229 | + environment: |
| 230 | + name: github-pages |
| 231 | + url: ${{ steps.deployment.outputs.page_url }} |
| 232 | + steps: |
| 233 | + - name: Deploy to GitHub Pages |
| 234 | + id: deployment |
| 235 | + uses: actions/deploy-pages@v4 |
| 236 | + |
| 237 | + verify: |
| 238 | + name: Verify Release |
| 239 | + needs: [release, deploy-pages] |
| 240 | + runs-on: ubuntu-latest |
| 241 | + steps: |
| 242 | + - name: Set up Python |
| 243 | + uses: actions/setup-python@v5 |
| 244 | + with: |
| 245 | + python-version: '3.12' |
| 246 | + |
| 247 | + - name: Wait for GitHub Pages propagation |
| 248 | + run: sleep 60 |
| 249 | + |
| 250 | + - name: Verify GitHub Pages installation |
| 251 | + run: | |
| 252 | + TAG=${GITHUB_REF#refs/tags/} |
| 253 | + VERSION=${TAG#v} |
| 254 | +
|
| 255 | + # Try installing from GitHub Pages index |
| 256 | + pip install --index-url https://easel.github.io/tablespec/simple/ tablespec==$VERSION || echo "GitHub Pages index not yet available" |
| 257 | +
|
| 258 | + - name: Summary |
| 259 | + run: | |
| 260 | + TAG=${GITHUB_REF#refs/tags/} |
| 261 | + cat << EOF |
| 262 | + ✅ Release $TAG complete! |
| 263 | +
|
| 264 | + 📄 GitHub Pages: https://easel.github.io/tablespec/ |
| 265 | + 🏷️ GitHub Release: https://github.com/easel/tablespec/releases/tag/$TAG |
| 266 | + EOF |
0 commit comments