Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions python/post-publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ description: Perform post-release operations for Python Libraries
inputs:
version:
description: The published version
required: true
following_version:
description: The following (dev) version
required: false
Expand Down Expand Up @@ -56,6 +55,20 @@ runs:
with:
name: all-dist-${{ github.run_id }}
path: dist/
- name: Ensure we have the package version
shell: bash
env:
VERSION: "${{ inputs.version }}"
run: |
# Handle version already bumped
if [ -z "$VERSION" ]; then
# Extract the version from the sdist name, which must be of the form
# {name}-{version}.tar.gz according to PEP 625.
VERSION=$(ls dist/*.tar.gz | rev | cut -d'-' -f 1 | rev | sed 's/.tar.gz//g')
echo "VERSION=$VERSION" >> $GITHUB_ENV
else
echo "VERSION=$VERSION" >> $GITHUB_ENV
fi
- name: Create detached signature for dist files
uses: mongodb-labs/drivers-github-tools/gpg-sign@v2
with:
Expand All @@ -68,8 +81,8 @@ runs:
- uses: mongodb-labs/drivers-github-tools/full-report@v2
with:
product_name: ${{ inputs.product_name }}
release_version: ${{ inputs.version }}
sarif_report_target_ref: ${{ inputs.version }}
release_version: ${{ env.VERSION }}
sarif_report_target_ref: ${{ env.VERSION }}
dist_filenames: dist/*
kondukto_sub_project: ${{ inputs.kondukto_sub_project }}
sbom_in_path: ${{ inputs.sbom_in_path }}
Expand All @@ -79,7 +92,7 @@ runs:
token: ${{ inputs.token }}
- uses: mongodb-labs/drivers-github-tools/upload-s3-assets@v2
with:
version: ${{ inputs.version }}
version: ${{ env.VERSION }}
product_name: ${{ inputs.product_name }}
dry_run: ${{ inputs.dry_run }}
- name: Run GitHub Publish script
Expand All @@ -88,7 +101,7 @@ runs:
run: ${{ github.action_path }}/post-publish.sh
env:
GH_TOKEN: ${{ inputs.token }}
VERSION: ${{ inputs.version }}
VERSION: ${{ env.VERSION }}
TAG_TEMPLATE: ${{ inputs.tag_template }}
PRODUCT_NAME: ${{ inputs.product_name }}
DRY_RUN: ${{ inputs.dry_run }}
Expand Down
2 changes: 1 addition & 1 deletion python/post-publish/post-publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ else
fi

# Handle push_changes output.
echo "push_changes=$PUSH_CHANGES" >> $GITHUB_OUTPUT
echo "push_changes=$PUSH_CHANGES" >> $GITHUB_OUTPUT
31 changes: 24 additions & 7 deletions python/pre-publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ description: Perform pre-release operations for Python Libraries
inputs:
version:
description: The published version
required: true
version_bump_script:
description: The version bump script
default: hatch version
Expand Down Expand Up @@ -34,28 +33,46 @@ runs:
- name: Install hatch
shell: bash
working-directory: ${{ inputs.working_directory }}
run: pipx install hatch
- name: Check if we should push changes
run: |
pipx install hatch
pip install build
- name: Handle inputs
shell: bash
env:
VERSION: "${{ inputs.version }}"
DRY_RUN: "${{ inputs.dry_run }}"
run: |
set -eux
# Handle DRY_RUN
if [ "${{ inputs.dry_run }}" != "true" ]; then
if [ "$DRY_RUN" != "true" ]; then
export PUSH_CHANGES=true
else
export PUSH_CHANGES=false
fi
echo "PUSH_CHANGES=$PUSH_CHANGES" >> $GITHUB_ENV
# Handle version already bumped
if [ -z "$VERSION" ]; then
# Extract the version from the sdist name, which must be of the form
# {name}-{version}.tar.gz according to PEP 625.
python -m build --sdist .
VERSION=$(ls dist/*.tar.gz | rev | cut -d'-' -f 1 | rev | sed 's/.tar.gz//g')
echo "VERSION=$VERSION" >> $GITHUB_ENV
rm -rf dist
else
echo "VERSION=$VERSION" >> $GITHUB_ENV
fi
- name: Set version
uses: mongodb-labs/drivers-github-tools/bump-version@v2
if: ${{ inputs.version }}
with:
version: ${{ inputs.version }}
version: ${{ env.VERSION }}
version_bump_script: ${{ inputs.version_bump_script }}
working_directory: ${{ inputs.working_directory }}
push_commit: ${{ env.PUSH_CHANGES }}
- name: Tag version
uses: mongodb-labs/drivers-github-tools/tag-version@v2
with:
version: ${{ inputs.version }}
version: ${{ env.VERSION }}
tag_template: ${{ inputs.tag_template }}
tag_message_template: ${{ inputs.tag_message_template }}
push_tag: ${{ env.PUSH_CHANGES }}
Expand All @@ -66,7 +83,7 @@ runs:
if [ "${{ inputs.dry_run}}" == 'true' ]; then
echo "version=${{ github.ref }}" >> $GITHUB_OUTPUT
else
export VERSION=${{ inputs.version }}
export VERSION=${{ env.VERSION }}
export TAG=$(echo "${{ inputs.tag_template }}" | envsubst)
echo "version=$TAG" >> $GITHUB_OUTPUT
fi
Loading