|
1 |
| -name: Python Packaging |
| 1 | +name: Packaging and Publishing |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | push:
|
5 |
| - |
6 | 5 | workflow_dispatch:
|
| 6 | + inputs: |
| 7 | + version: |
| 8 | + description: "The version to publish, ie 1.0.0 or 1.0.0-dev1" |
| 9 | + required: true |
7 | 10 |
|
8 | 11 | jobs:
|
9 | 12 | build:
|
10 |
| - name: Build |
11 | 13 | runs-on: ubuntu-latest
|
12 | 14 | steps:
|
13 | 15 | - uses: actions/checkout@v4
|
14 | 16 | with:
|
15 | 17 | fetch-depth: 0
|
| 18 | + ref: ${{ github.event_name == 'workflow_dispatch' && format('v{0}', github.event.inputs.version) || github.ref }} |
| 19 | + |
16 | 20 | - uses: hynek/build-and-inspect-python-package@v2
|
17 | 21 |
|
| 22 | + - uses: actions/upload-artifact@v4 |
| 23 | + with: |
| 24 | + name: Packages-${{ github.run_id }} |
| 25 | + path: | |
| 26 | + /tmp/baipp/dist/*.whl |
| 27 | + /tmp/baipp/dist/*.tar.gz |
| 28 | +
|
18 | 29 | publish:
|
19 |
| - name: Publish to PyPI |
| 30 | + name: Publish CDK version to PyPI |
20 | 31 | runs-on: ubuntu-latest
|
21 | 32 | needs: [build]
|
22 | 33 | permissions:
|
23 |
| - id-token: write # IMPORTANT: this permission is mandatory for trusted publishing |
24 |
| - contents: write # Needed to upload artifacts to the release |
| 34 | + id-token: write |
| 35 | + contents: write |
25 | 36 | environment:
|
26 |
| - name: PyPI |
27 |
| - url: "https://pypi.org/p/airbyte-cdk" |
28 |
| - if: startsWith(github.ref, 'refs/tags/v') |
| 37 | + name: PyPi |
| 38 | + url: https://pypi.org/p/airbyte |
| 39 | + if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' |
29 | 40 | steps:
|
30 | 41 | - uses: actions/download-artifact@v4
|
31 | 42 | with:
|
32 |
| - name: Packages |
| 43 | + name: Packages-${{ github.run_id }} |
33 | 44 | path: dist
|
34 |
| - - name: Attach Wheel to GitHub Release |
| 45 | + |
| 46 | + - name: Upload wheel to release |
| 47 | + if: startsWith(github.ref, 'refs/tags/v') |
35 | 48 | uses: svenstaro/upload-release-action@v2
|
36 | 49 | with:
|
37 | 50 | repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
40 | 53 | overwrite: true
|
41 | 54 | file_glob: true
|
42 | 55 |
|
43 |
| - - name: Publish to PyPI (${{vars.PYPI_PUBLISH_URL}}) |
44 |
| - uses: pypa/gh-action-pypi-publish@v1.12.2 |
| 56 | + - name: Publish to PyPI |
| 57 | + uses: pypa/gh-action-pypi-publish@v1.10.3 |
| 58 | + |
| 59 | + publish_sdm: |
| 60 | + name: Publish SDM to DockerHub |
| 61 | + if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' |
| 62 | + runs-on: ubuntu-latest |
| 63 | + needs: [publish] |
| 64 | + |
| 65 | + steps: |
| 66 | + - uses: actions/checkout@v4 |
| 67 | + with: |
| 68 | + fetch-depth: 0 |
| 69 | + |
| 70 | + - name: Set Version (workflow_dispatch) |
| 71 | + if: github.event_name == 'workflow_dispatch' |
| 72 | + run: | |
| 73 | + echo "Version set to ${{ github.event.inputs.version }}" |
| 74 | + echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV |
| 75 | +
|
| 76 | + - name: Set Version (tag) |
| 77 | + if: startsWith(github.ref, 'refs/tags/v') |
| 78 | + run: | |
| 79 | + echo "Version set to ${{ github.ref_name }}" |
| 80 | + echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV |
| 81 | +
|
| 82 | + # We need to download the build artifact again because the previous job was on a different runner |
| 83 | + - name: Download Build Artifact |
| 84 | + uses: actions/download-artifact@v4 |
| 85 | + with: |
| 86 | + name: Packages-${{ github.run_id }} |
| 87 | + path: dist |
| 88 | + |
| 89 | + - name: Set up QEMU for multi-platform builds |
| 90 | + uses: docker/setup-qemu-action@v3 |
| 91 | + |
| 92 | + - name: Set up Docker Buildx |
| 93 | + uses: docker/setup-buildx-action@v3 |
| 94 | + |
| 95 | + - name: Login to Docker Hub |
| 96 | + uses: docker/login-action@v3 |
| 97 | + with: |
| 98 | + username: ${{ secrets.DOCKER_HUB_USERNAME }} |
| 99 | + password: ${{ secrets.DOCKER_HUB_PASSWORD }} |
| 100 | + |
| 101 | + - name: Check for existing tag |
| 102 | + run: | |
| 103 | + tag="airbyte/source-declarative-manifest:${{ env.VERSION }}" |
| 104 | + if [ -z "$tag" ]; then |
| 105 | + echo "Error: VERSION is not set. Ensure the tag follows the format 'refs/tags/vX.Y.Z'." |
| 106 | + exit 1 |
| 107 | + fi |
| 108 | + echo "Checking if tag '$tag' exists on DockerHub..." |
| 109 | + if DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect "$tag" > /dev/null 2>&1; then |
| 110 | + echo "The tag '$tag' already exists on DockerHub. Skipping publish to prevent overwrite." |
| 111 | + exit 1 |
| 112 | + fi |
| 113 | + echo "No existing tag '$tag' found. Proceeding with publish." |
| 114 | +
|
| 115 | + - name: Build and push |
| 116 | + uses: docker/build-push-action@v5 |
45 | 117 | with:
|
46 |
| - # Can be toggled at the repository level between `https://upload.pypi.org/legacy/` and `https://test.pypi.org/legacy/` |
47 |
| - repository-url: ${{vars.PYPI_PUBLISH_URL}} |
| 118 | + context: . |
| 119 | + platforms: linux/amd64,linux/arm64 |
| 120 | + push: true |
| 121 | + tags: | |
| 122 | + airbyte/source-declarative-manifest:latest |
| 123 | + airbyte/source-declarative-manifest:${{ env.VERSION }} |
| 124 | + airbyte/source-declarative-manifest:${{ github.sha }} |
0 commit comments