|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: 'Version to release (e.g., 1.0.0)' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | +concurrency: release |
| 12 | + |
| 13 | +jobs: |
| 14 | + release: |
| 15 | + name: Release packages |
| 16 | + runs-on: ubuntu-latest |
| 17 | + if: github.ref == 'refs/heads/main' |
| 18 | + environment: |
| 19 | + name: npm-release |
| 20 | + url: https://www.npmjs.com/org/jentic |
| 21 | + permissions: |
| 22 | + contents: write |
| 23 | + id-token: write # Required for PyPI OIDC and NPM provenance |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout repository |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + |
| 31 | + - name: Set up Python |
| 32 | + uses: actions/setup-python@v5 |
| 33 | + with: |
| 34 | + python-version: '3.12' |
| 35 | + |
| 36 | + - name: Install uv |
| 37 | + uses: astral-sh/setup-uv@v5 |
| 38 | + |
| 39 | + - name: Set up Node.js |
| 40 | + uses: actions/setup-node@v4 |
| 41 | + with: |
| 42 | + node-version: '20' |
| 43 | + registry-url: 'https://registry.npmjs.org' |
| 44 | + |
| 45 | + - name: Configure Git |
| 46 | + run: | |
| 47 | + git config user.name "github-actions[bot]" |
| 48 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 49 | +
|
| 50 | + - name: Update Python package version |
| 51 | + working-directory: python |
| 52 | + run: | |
| 53 | + sed -i 's/^version = .*/version = "${{ inputs.version }}"/' pyproject.toml |
| 54 | +
|
| 55 | + - name: Update TypeScript package version |
| 56 | + working-directory: typescript |
| 57 | + run: | |
| 58 | + npm version ${{ inputs.version }} --no-git-tag-version |
| 59 | +
|
| 60 | + - name: Commit version changes and create tag |
| 61 | + env: |
| 62 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 63 | + run: | |
| 64 | + git add python/pyproject.toml typescript/package.json typescript/package-lock.json |
| 65 | + git commit -m "chore: release v${{ inputs.version }}" |
| 66 | + git tag -a "v${{ inputs.version }}" -m "Release v${{ inputs.version }}" |
| 67 | + git push origin main --tags |
| 68 | +
|
| 69 | + - name: Install Python dependencies and build |
| 70 | + working-directory: python |
| 71 | + run: | |
| 72 | + uv pip install --system build |
| 73 | + python -m build |
| 74 | +
|
| 75 | + - name: Build TypeScript package |
| 76 | + working-directory: typescript |
| 77 | + run: | |
| 78 | + npm ci |
| 79 | + npm run build |
| 80 | +
|
| 81 | + - name: Prepare release artifacts |
| 82 | + run: | |
| 83 | + mkdir -p release-assets |
| 84 | + cp python/dist/* release-assets/ |
| 85 | +
|
| 86 | + echo "📦 Release artifacts:" |
| 87 | + ls -la release-assets/ |
| 88 | +
|
| 89 | + - name: Create GitHub Release |
| 90 | + env: |
| 91 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 92 | + run: | |
| 93 | + echo "🚀 Creating GitHub release..." |
| 94 | + VERSION="${{ inputs.version }}" |
| 95 | +
|
| 96 | + # Try to extract changelog for this version |
| 97 | + CHANGELOG_CONTENT="$(sed -n '/^## v'$VERSION'/,/^## /p' CHANGELOG.md 2>/dev/null | sed '$d')" |
| 98 | +
|
| 99 | + if [ -z "$CHANGELOG_CONTENT" ]; then |
| 100 | + CHANGELOG_CONTENT="Release v$VERSION" |
| 101 | + fi |
| 102 | +
|
| 103 | + gh release create "v$VERSION" \ |
| 104 | + --title "v$VERSION" \ |
| 105 | + --notes "$CHANGELOG_CONTENT" \ |
| 106 | + release-assets/* |
| 107 | +
|
| 108 | + - name: Publish Python package to PyPI |
| 109 | + id: pypi_publish |
| 110 | + continue-on-error: true # TODO: Remove after Trusted Publisher is configured on PyPI |
| 111 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 112 | + with: |
| 113 | + packages-dir: python/dist/ |
| 114 | + attestations: false |
| 115 | + |
| 116 | + - name: Publish TypeScript package to NPM |
| 117 | + id: npm_publish |
| 118 | + working-directory: typescript |
| 119 | + run: npm publish --access public --provenance |
| 120 | + |
| 121 | + - name: Release Summary |
| 122 | + run: | |
| 123 | + echo "🎉 RELEASE COMPLETED" |
| 124 | + echo "Released version: ${{ inputs.version }}" |
| 125 | + echo "" |
| 126 | + if [ "${{ steps.pypi_publish.outcome }}" == "success" ]; then |
| 127 | + echo "Published to PyPI: ✓" |
| 128 | + else |
| 129 | + echo "Published to PyPI: ⚠️ SKIPPED (Trusted Publisher not configured yet)" |
| 130 | + fi |
| 131 | + echo "Published to NPM: ✓" |
| 132 | + echo "GitHub release created: ✓" |
0 commit comments