|
| 1 | + |
| 2 | +name: Python Labs Post-Publish |
| 3 | +description: Perform post-release operations for Python Libraries in MongoDB Labs |
| 4 | +inputs: |
| 5 | + following_version: |
| 6 | + description: The following (dev) version |
| 7 | + required: false |
| 8 | + product_name: |
| 9 | + description: The name of the product |
| 10 | + required: true |
| 11 | + version_bump_script: |
| 12 | + description: The version bump script |
| 13 | + default: hatch version |
| 14 | + working_directory: |
| 15 | + description: The working directory for the action |
| 16 | + default: "." |
| 17 | + tag_template: |
| 18 | + description: The template for the git tag |
| 19 | + default: "${VERSION}" |
| 20 | + repository-url: |
| 21 | + description: The PyPI repository URL to use |
| 22 | + default: https://upload.pypi.org/legacy/ |
| 23 | + token: |
| 24 | + description: The GitHub access token |
| 25 | + dry_run: |
| 26 | + description: Whether this is a dry run |
| 27 | + required: true |
| 28 | + |
| 29 | +runs: |
| 30 | + using: composite |
| 31 | + steps: |
| 32 | + - uses: actions/setup-python@v5 |
| 33 | + with: |
| 34 | + python-version: '3.11' |
| 35 | + - name: Install hatch |
| 36 | + shell: bash |
| 37 | + run: pipx install hatch |
| 38 | + - name: Download all the dists |
| 39 | + uses: actions/download-artifact@v4 |
| 40 | + with: |
| 41 | + name: all-dist-${{ github.run_id }} |
| 42 | + path: dist/ |
| 43 | + - name: Get the package version |
| 44 | + shell: bash |
| 45 | + run: | |
| 46 | + # Handle version already bumped |
| 47 | + if [ -z "$VERSION" ]; then |
| 48 | + # Extract the version from the sdist name, which must be of the form |
| 49 | + # {name}-{version}.tar.gz according to PEP 625. |
| 50 | + VERSION=$(ls dist/*.tar.gz | rev | cut -d'-' -f 1 | rev | sed 's/.tar.gz//g') |
| 51 | + echo "VERSION=$VERSION" >> $GITHUB_ENV |
| 52 | + else |
| 53 | + echo "VERSION=$VERSION" >> $GITHUB_ENV |
| 54 | + fi |
| 55 | + - name: Run GitHub Publish script |
| 56 | + shell: bash |
| 57 | + id: publish-script |
| 58 | + run: ${{ github.action_path }}/post-publish.sh |
| 59 | + env: |
| 60 | + GH_TOKEN: ${{ inputs.token }} |
| 61 | + VERSION: ${{ env.VERSION }} |
| 62 | + TAG_TEMPLATE: ${{ inputs.tag_template }} |
| 63 | + PRODUCT_NAME: ${{ inputs.product_name }} |
| 64 | + DRY_RUN: ${{ inputs.dry_run }} |
| 65 | + FOLLOWING_VERSION: ${{ inputs.following_version }} |
| 66 | + - name: Ensure a clean repo |
| 67 | + shell: bash |
| 68 | + run: | |
| 69 | + git clean -dffx |
| 70 | + git pull origin ${GITHUB_REF} |
| 71 | + - name: Set following version |
| 72 | + uses: mongodb-labs/drivers-github-tools/bump-version@v2 |
| 73 | + if: inputs.dry_run == 'false' |
| 74 | + with: |
| 75 | + version: ${{ steps.publish-script.outputs.following_version }} |
| 76 | + version_bump_script: ${{ inputs.version_bump_script }} |
| 77 | + working_directory: ${{ inputs.working_directory }} |
| 78 | + - name: Skip Setting following version |
| 79 | + shell: bash |
| 80 | + if: inputs.dry_run == 'true' |
| 81 | + run: | |
| 82 | + echo "Dry run, not setting the following version: ${{ steps.publish-script.outputs.following_version }}" >> $GITHUB_STEP_SUMMARY |
0 commit comments