|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*' |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + uses: ./.github/workflows/test.yml |
| 12 | + |
| 13 | + build_package: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + needs: test |
| 16 | + steps: |
| 17 | + - name: Checkout code |
| 18 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 19 | + |
| 20 | + - name: Install uv |
| 21 | + uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1 |
| 22 | + |
| 23 | + - name: Set up Python |
| 24 | + run: uv python install 3.13 |
| 25 | + |
| 26 | + - name: Check tag matches version files |
| 27 | + run: | |
| 28 | + TAG_VERSION="${GITHUB_REF##*/}" |
| 29 | + TAG_VERSION_NO_PREFIX="${TAG_VERSION#v}" |
| 30 | + echo "Tag version: $TAG_VERSION (stripped: $TAG_VERSION_NO_PREFIX)" |
| 31 | +
|
| 32 | + PYPROJECT_VERSION=$(grep '^version =' pyproject.toml | sed 's/version = "\(.*\)"/\1/') |
| 33 | + echo "pyproject.toml version: $PYPROJECT_VERSION" |
| 34 | +
|
| 35 | + INIT_VERSION=$(grep '^__version__ =' src/briefcase_pythonanywhere/__init__.py | sed 's/__version__ = "\(.*\)"/\1/') |
| 36 | + echo "__init__.py version: $INIT_VERSION" |
| 37 | +
|
| 38 | + if [ "$TAG_VERSION_NO_PREFIX" != "$PYPROJECT_VERSION" ]; then |
| 39 | + echo "Tag version ($TAG_VERSION_NO_PREFIX) does not match pyproject.toml version ($PYPROJECT_VERSION)" >&2 |
| 40 | + exit 1 |
| 41 | + fi |
| 42 | +
|
| 43 | + if [ "$TAG_VERSION_NO_PREFIX" != "$INIT_VERSION" ]; then |
| 44 | + echo "Tag version ($TAG_VERSION_NO_PREFIX) does not match __init__.py version ($INIT_VERSION)" >&2 |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | +
|
| 48 | + if [ "$PYPROJECT_VERSION" != "$INIT_VERSION" ]; then |
| 49 | + echo "pyproject.toml version ($PYPROJECT_VERSION) does not match __init__.py version ($INIT_VERSION)" >&2 |
| 50 | + exit 1 |
| 51 | + fi |
| 52 | + shell: bash |
| 53 | + |
| 54 | + - name: Build package |
| 55 | + run: uv build |
| 56 | + |
| 57 | + - name: Publish to PyPI |
| 58 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 59 | + with: |
| 60 | + user: __token__ |
| 61 | + password: ${{ secrets.PYPI_API_TOKEN }} |
| 62 | + |
| 63 | + - name: Upload build artifacts |
| 64 | + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 |
| 65 | + with: |
| 66 | + name: dist |
| 67 | + path: dist/ |
| 68 | + |
| 69 | + create_release: |
| 70 | + runs-on: ubuntu-latest |
| 71 | + needs: build_package |
| 72 | + steps: |
| 73 | + - name: Download build artifacts |
| 74 | + uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 |
| 75 | + with: |
| 76 | + name: dist |
| 77 | + path: dist/ |
| 78 | + |
| 79 | + - name: Create Release |
| 80 | + uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0 |
| 81 | + with: |
| 82 | + files: | |
| 83 | + dist/* |
| 84 | + env: |
| 85 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 86 | + |
| 87 | + deploy_docs: |
| 88 | + runs-on: ubuntu-latest |
| 89 | + needs: build_package |
| 90 | + steps: |
| 91 | + - name: Checkout code |
| 92 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 93 | + |
| 94 | + - name: Install uv |
| 95 | + uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1 |
| 96 | + |
| 97 | + - name: Set up Python |
| 98 | + run: uv python install 3.13 |
| 99 | + |
| 100 | + - name: Build documentation |
| 101 | + run: uvx mkdocs build |
| 102 | + |
| 103 | + - name: Setup SSH key |
| 104 | + uses: webfactory/ssh-agent@a6f90b1f127823b31d4d4a8d96047790581349bd # v0.9.1 |
| 105 | + with: |
| 106 | + ssh-private-key: ${{ secrets.DOCS_DEPLOY_SSH_KEY }} |
| 107 | + |
| 108 | + - name: Add server to known hosts |
| 109 | + run: | |
| 110 | + ssh-keyscan -H ssh.pythonanywhere.com >> ~/.ssh/known_hosts |
| 111 | +
|
| 112 | + - name: Deploy to PythonAnywhere |
| 113 | + run: | |
| 114 | + rsync -av --delete site/ briefcase@ssh.pythonanywhere.com:/home/briefcase/docs/ |
0 commit comments