|
1 | | -name: Build and/or Publish |
| 1 | +# This workflow publishes the python package to PyPI. |
| 2 | +# |
| 3 | +# Triggers: |
| 4 | +# - release: published - When user clicks "Publish" on a draft release (downloads pre-built assets) |
| 5 | +# |
| 6 | +# Authentication: This workflow expects GitHub OIDC for passwordless PyPI publishing. |
| 7 | +# For more info: https://docs.pypi.org/trusted-publishers/ |
2 | 8 |
|
3 | | -on: |
4 | | - push: |
5 | | - |
6 | | - workflow_dispatch: |
7 | | - inputs: |
8 | | - git_ref: |
9 | | - description: 'Git ref (SHA or branch) to checkout and build' |
10 | | - required: false |
11 | | - type: string |
12 | | - version_override: |
13 | | - description: 'Version to use (overrides dynamic versioning)' |
14 | | - required: false |
15 | | - type: string |
16 | | - publish: |
17 | | - description: 'Whether to publish to PyPI (true/false)' |
18 | | - required: false |
19 | | - type: string |
20 | | - default: 'false' |
| 9 | +name: Publish Package |
21 | 10 |
|
22 | | - workflow_call: |
23 | | - inputs: |
24 | | - git_ref: |
25 | | - description: 'Git ref (SHA or branch) to checkout and build' |
26 | | - required: true |
27 | | - type: string |
28 | | - version_override: |
29 | | - description: 'Version to use (overrides dynamic versioning)' |
30 | | - required: false |
31 | | - type: string |
32 | | - publish: |
33 | | - description: 'Whether to publish to PyPI' |
34 | | - required: false |
35 | | - type: boolean |
36 | | - default: false |
| 11 | +on: |
| 12 | + release: |
| 13 | + types: [published] |
37 | 14 |
|
38 | 15 | env: |
39 | 16 | AIRBYTE_ANALYTICS_ID: ${{ vars.AIRBYTE_ANALYTICS_ID }} |
40 | 17 |
|
41 | 18 | jobs: |
42 | | - build: |
43 | | - runs-on: ubuntu-latest |
44 | | - steps: |
45 | | - - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
46 | | - with: |
47 | | - ref: ${{ inputs.git_ref || github.ref }} |
48 | | - fetch-depth: 0 |
49 | | - - name: Prepare version override |
50 | | - id: version |
51 | | - run: | |
52 | | - echo "override=${{ inputs.version_override }}" >> $GITHUB_OUTPUT |
53 | | - echo "has_override=${{ inputs.version_override != '' }}" >> $GITHUB_OUTPUT |
54 | | - - name: Build package (with version override) |
55 | | - if: steps.version.outputs.has_override == 'true' |
56 | | - uses: hynek/build-and-inspect-python-package@v2 |
57 | | - env: |
58 | | - UV_DYNAMIC_VERSIONING_BYPASS: ${{ steps.version.outputs.override }} |
59 | | - - name: Build package (dynamic version) |
60 | | - if: steps.version.outputs.has_override != 'true' |
61 | | - uses: hynek/build-and-inspect-python-package@v2 |
62 | | - |
63 | | - publish: |
64 | | - name: Publish to PyPI |
| 19 | + publish_to_pypi: |
| 20 | + name: Publish Package to PyPI |
65 | 21 | runs-on: ubuntu-latest |
66 | | - needs: [build] |
67 | 22 | permissions: |
68 | | - id-token: write # IMPORTANT: this permission is mandatory for trusted publishing |
69 | | - contents: write # Needed to upload artifacts to the release |
| 23 | + id-token: write |
| 24 | + contents: read |
70 | 25 | environment: |
71 | 26 | name: PyPi |
72 | 27 | url: https://pypi.org/p/airbyte |
73 | | - # Publish when: (1) triggered by a tag push, OR (2) called with publish=true (handles both boolean and string) |
74 | | - if: startsWith(github.ref, 'refs/tags/') || inputs.publish == true || inputs.publish == 'true' |
75 | 28 | steps: |
76 | | - - uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 |
77 | | - with: |
78 | | - name: Packages |
79 | | - path: dist |
80 | | - - name: Upload wheel to release |
81 | | - # Only upload to GitHub release when triggered by a tag |
82 | | - if: startsWith(github.ref, 'refs/tags/') |
83 | | - uses: svenstaro/upload-release-action@81c65b7cd4de9b2570615ce3aad67a41de5b1a13 # latest |
84 | | - with: |
85 | | - repo_token: ${{ secrets.GITHUB_TOKEN }} |
86 | | - file: dist/*.whl |
87 | | - tag: ${{ github.ref }} |
88 | | - overwrite: true |
89 | | - file_glob: true |
| 29 | + - name: Download release assets |
| 30 | + uses: robinraju/release-downloader@v1.12 |
| 31 | + with: |
| 32 | + tag: ${{ github.event.release.tag_name }} |
| 33 | + fileName: "*" |
| 34 | + out-file-path: dist |
90 | 35 |
|
91 | | - - name: Publish |
92 | | - uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0 |
| 36 | + # Uses GitHub OIDC for passwordless authentication (see header comment) |
| 37 | + - name: Publish to PyPI |
| 38 | + uses: pypa/gh-action-pypi-publish@v1.13.0 |
0 commit comments