|
| 1 | +name: Release |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - 'v*' # Triggers on new version tags |
| 6 | + |
| 7 | +jobs: |
| 8 | + tests: |
| 9 | + uses: ./.github/workflows/test.yml |
| 10 | + |
| 11 | + publish-to-pypi: |
| 12 | + name: Publish to PyPI |
| 13 | + needs: |
| 14 | + - tests |
| 15 | + runs-on: ubuntu-latest |
| 16 | + environment: |
| 17 | + name: pypi |
| 18 | + # TODO |
| 19 | + url: https://pypi.org/p/project-name |
| 20 | + permissions: |
| 21 | + id-token: write |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v3 |
| 24 | + |
| 25 | + - name: Install poetry |
| 26 | + run: pipx install poetry |
| 27 | + |
| 28 | + - name: Setup Python |
| 29 | + uses: actions/setup-python@v4 |
| 30 | + with: |
| 31 | + python-version: '3.10' |
| 32 | + |
| 33 | + - name: Build a binary wheel |
| 34 | + run: poetry build |
| 35 | + |
| 36 | + - name: Publish distribution 📦 to PyPI |
| 37 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 38 | + |
| 39 | + github-release: |
| 40 | + name: Create GitHub Release |
| 41 | + needs: |
| 42 | + - publish-to-pypi |
| 43 | + runs-on: ubuntu-latest |
| 44 | + permissions: |
| 45 | + contents: write |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v3 |
| 48 | + |
| 49 | + - name: Check package version matches tag |
| 50 | + id: check-version |
| 51 | + uses: samuelcolvin/[email protected] |
| 52 | + with: |
| 53 | + version_file_path: 'pyproject.toml' |
| 54 | + |
| 55 | + - name: Create GitHub Release |
| 56 | + env: |
| 57 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + tag: ${{ github.ref_name }} |
| 59 | + run: | |
| 60 | + gh release create "$tag" \ |
| 61 | + --repo="$GITHUB_REPOSITORY" \ |
| 62 | + --title="${GITHUB_REPOSITORY#*/} ${tag#v}" \ |
| 63 | + --generate-notes |
| 64 | +
|
| 65 | + update_docs: |
| 66 | + name: Update Documentation |
| 67 | + needs: |
| 68 | + - github-release |
| 69 | + runs-on: ubuntu-latest |
| 70 | + permissions: |
| 71 | + contents: write |
| 72 | + steps: |
| 73 | + - uses: actions/checkout@v3 |
| 74 | + with: |
| 75 | + fetch-depth: 0 |
| 76 | + |
| 77 | + - name: Install poetry |
| 78 | + run: pipx install poetry |
| 79 | + |
| 80 | + - name: Setup Python |
| 81 | + uses: actions/setup-python@v4 |
| 82 | + with: |
| 83 | + python-version: '3.10' |
| 84 | + cache: 'poetry' |
| 85 | + |
| 86 | + - name: Configure Git user |
| 87 | + run: | |
| 88 | + git config --local user.email "github-actions[bot]@users.noreply.github.com" |
| 89 | + git config --local user.name "github-actions[bot]" |
| 90 | +
|
| 91 | + - name: Retrieve version |
| 92 | + id: check-version |
| 93 | + uses: samuelcolvin/[email protected] |
| 94 | + with: |
| 95 | + version_file_path: 'pyproject.toml' |
| 96 | + skip_env_check: true |
| 97 | + |
| 98 | + - name: Deploy the docs |
| 99 | + run: | |
| 100 | + poetry run mike deploy \ |
| 101 | + --update-aliases \ |
| 102 | + --push \ |
| 103 | + --branch docs-site \ |
| 104 | + ${{ steps.check-version.outputs.VERSION_MAJOR_MINOR }} latest |
0 commit comments