|
1 | | -name: Run Release Please |
| 1 | +# This workflow handles both automated and manual package publishing: |
| 2 | +# |
| 3 | +# AUTOMATED PUBLISHING (on push to main): |
| 4 | +# - Triggered automatically when changes are pushed to the main branch |
| 5 | +# - Uses release-please to create releases based on conventional commits |
| 6 | +# - Publishes packages to PyPI automatically when release PRs are merged |
| 7 | +# |
| 8 | +# MANUAL PUBLISHING (via workflow_dispatch): |
| 9 | +# - Can be triggered manually from the Actions tab |
| 10 | +# - Allows publishing a specific package to PyPI |
| 11 | +# - Supports dry-run mode |
| 12 | +# |
| 13 | +name: release-please |
2 | 14 |
|
3 | 15 | on: |
4 | 16 | push: |
5 | | - branches: [ main ] |
| 17 | + branches: |
| 18 | + - main |
| 19 | + workflow_dispatch: |
| 20 | + inputs: |
| 21 | + workspace_path: |
| 22 | + description: 'The workspace to publish' |
| 23 | + required: true |
| 24 | + default: 'packages/sdk/server-ai' |
| 25 | + type: choice |
| 26 | + options: |
| 27 | + - packages/sdk/server-ai |
| 28 | + - packages/ai-providers/server-ai-langchain |
| 29 | + dry_run: |
| 30 | + description: 'Is this a dry run. If so no package will be published.' |
| 31 | + type: boolean |
| 32 | + required: true |
6 | 33 |
|
7 | 34 | jobs: |
8 | | - release-package: |
| 35 | + release-please: |
9 | 36 | runs-on: ubuntu-latest |
10 | | - permissions: |
11 | | - id-token: write # Needed if using OIDC to get release secrets. |
12 | | - contents: write # Contents and pull-requests are for release-please to make releases. |
13 | | - pull-requests: write |
| 37 | + if: github.event_name == 'push' |
14 | 38 | outputs: |
15 | | - release-created: ${{ steps.release.outputs.release_created }} |
16 | | - upload-tag-name: ${{ steps.release.outputs.tag_name }} |
17 | | - package-hashes: ${{ steps.build.outputs.package-hashes}} |
| 39 | + package-server-ai-released: ${{ steps.release.outputs['packages/sdk/server-ai--release_created'] }} |
| 40 | + package-server-ai-langchain-released: ${{ steps.release.outputs['packages/ai-providers/server-ai-langchain--release_created'] }} |
18 | 41 | steps: |
19 | 42 | - uses: googleapis/release-please-action@v4 |
20 | 43 | id: release |
| 44 | + with: |
| 45 | + token: ${{secrets.GITHUB_TOKEN}} |
21 | 46 |
|
| 47 | + release-server-ai: |
| 48 | + runs-on: ubuntu-latest |
| 49 | + needs: ['release-please'] |
| 50 | + permissions: |
| 51 | + id-token: write |
| 52 | + contents: write |
| 53 | + if: ${{ needs.release-please.outputs.package-server-ai-released == 'true' }} |
| 54 | + steps: |
22 | 55 | - uses: actions/checkout@v4 |
23 | | - if: ${{ steps.release.outputs.releases_created == 'true' }} |
24 | 56 | with: |
25 | | - fetch-depth: 0 # If you only need the current version keep this. |
| 57 | + fetch-depth: 0 |
26 | 58 |
|
27 | 59 | - uses: actions/setup-python@v5 |
28 | | - if: ${{ steps.release.outputs.releases_created == 'true' }} |
29 | 60 | with: |
30 | | - python-version: 3.9 |
| 61 | + python-version: '3.11' |
31 | 62 |
|
32 | 63 | - name: Install poetry |
33 | | - if: ${{ steps.release.outputs.releases_created == 'true' }} |
34 | 64 | uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439 |
35 | 65 |
|
| 66 | + - uses: ./.github/actions/ci |
| 67 | + with: |
| 68 | + workspace_path: packages/sdk/server-ai |
| 69 | + |
| 70 | + - uses: ./.github/actions/build |
| 71 | + id: build |
| 72 | + with: |
| 73 | + workspace_path: packages/sdk/server-ai |
| 74 | + |
36 | 75 | - uses: launchdarkly/gh-actions/actions/[email protected] |
37 | | - if: ${{ steps.release.outputs.releases_created == 'true' }} |
38 | 76 | name: 'Get PyPI token' |
39 | 77 | with: |
40 | 78 | aws_assume_role: ${{ vars.AWS_ROLE_ARN }} |
41 | 79 | ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN' |
42 | 80 |
|
| 81 | + - name: Publish to PyPI |
| 82 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 83 | + with: |
| 84 | + password: ${{ env.PYPI_AUTH_TOKEN }} |
| 85 | + packages-dir: packages/sdk/server-ai/dist/ |
| 86 | + |
| 87 | + release-server-ai-langchain: |
| 88 | + runs-on: ubuntu-latest |
| 89 | + needs: ['release-please', 'release-server-ai'] |
| 90 | + permissions: |
| 91 | + id-token: write |
| 92 | + contents: write |
| 93 | + if: ${{ always() && !failure() && !cancelled() && needs.release-please.outputs.package-server-ai-langchain-released == 'true' }} |
| 94 | + steps: |
| 95 | + - uses: actions/checkout@v4 |
| 96 | + with: |
| 97 | + fetch-depth: 0 |
| 98 | + |
| 99 | + - uses: actions/setup-python@v5 |
| 100 | + with: |
| 101 | + python-version: '3.11' |
| 102 | + |
| 103 | + - name: Install poetry |
| 104 | + uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439 |
| 105 | + |
| 106 | + - uses: ./.github/actions/ci |
| 107 | + with: |
| 108 | + workspace_path: packages/ai-providers/server-ai-langchain |
| 109 | + |
43 | 110 | - uses: ./.github/actions/build |
44 | 111 | id: build |
45 | | - if: ${{ steps.release.outputs.releases_created == 'true' }} |
| 112 | + with: |
| 113 | + workspace_path: packages/ai-providers/server-ai-langchain |
46 | 114 |
|
47 | | - - uses: ./.github/actions/build-docs |
48 | | - if: ${{ steps.release.outputs.releases_created == 'true' }} |
| 115 | + - uses: launchdarkly/gh-actions/actions/[email protected] |
| 116 | + name: 'Get PyPI token' |
| 117 | + with: |
| 118 | + aws_assume_role: ${{ vars.AWS_ROLE_ARN }} |
| 119 | + ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN' |
49 | 120 |
|
50 | | - - name: Publish package distributions to PyPI |
51 | | - if: ${{ steps.release.outputs.releases_created == 'true' }} |
| 121 | + - name: Publish to PyPI |
52 | 122 | uses: pypa/gh-action-pypi-publish@release/v1 |
53 | 123 | with: |
54 | | - password: ${{env.PYPI_AUTH_TOKEN}} |
| 124 | + password: ${{ env.PYPI_AUTH_TOKEN }} |
| 125 | + packages-dir: packages/ai-providers/server-ai-langchain/dist/ |
55 | 126 |
|
56 | | - release-provenance: |
57 | | - needs: [ 'release-package' ] |
58 | | - if: ${{ needs.release-package.outputs.release-created == 'true' }} |
| 127 | + manual-publish: |
| 128 | + runs-on: ubuntu-latest |
| 129 | + if: github.event_name == 'workflow_dispatch' |
59 | 130 | permissions: |
60 | | - actions: read |
61 | 131 | id-token: write |
62 | | - contents: write |
63 | | - uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected] |
64 | | - with: |
65 | | - base64-subjects: "${{ needs.release-package.outputs.package-hashes }}" |
66 | | - upload-assets: true |
67 | | - upload-tag-name: ${{ needs.release-package.outputs.upload-tag-name }} |
| 132 | + contents: read |
| 133 | + steps: |
| 134 | + - uses: actions/checkout@v4 |
| 135 | + |
| 136 | + - uses: actions/setup-python@v5 |
| 137 | + with: |
| 138 | + python-version: '3.11' |
| 139 | + |
| 140 | + - name: Install poetry |
| 141 | + uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439 |
| 142 | + |
| 143 | + - uses: ./.github/actions/ci |
| 144 | + with: |
| 145 | + workspace_path: ${{ inputs.workspace_path }} |
| 146 | + |
| 147 | + - uses: ./.github/actions/build |
| 148 | + id: build |
| 149 | + with: |
| 150 | + workspace_path: ${{ inputs.workspace_path }} |
| 151 | + |
| 152 | + - uses: launchdarkly/gh-actions/actions/[email protected] |
| 153 | + if: ${{ inputs.dry_run != true }} |
| 154 | + name: 'Get PyPI token' |
| 155 | + with: |
| 156 | + aws_assume_role: ${{ vars.AWS_ROLE_ARN }} |
| 157 | + ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN' |
| 158 | + |
| 159 | + - name: Publish to PyPI |
| 160 | + if: ${{ inputs.dry_run != true }} |
| 161 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 162 | + with: |
| 163 | + password: ${{ env.PYPI_AUTH_TOKEN }} |
| 164 | + packages-dir: ${{ inputs.workspace_path }}/dist/ |
0 commit comments