Skip to content

Commit

Permalink
Add PyPI version check job
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 721898107
  • Loading branch information
santoso-wijaya authored and The Meridian Authors committed Jan 31, 2025
1 parent d0c3ed9 commit 487ff3e
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/pytest_and_autopublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,62 @@ jobs:
fi
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
create-tag:
name: Create Version Tag
runs-on: ubuntu-latest
needs: check-version
if: ${{ needs.check-version.outputs.new_version != '' }} # Only run if new_version was discovered.
steps:
- uses: actions/checkout@v4
- name: Create and Push Tag
uses: actions/github-script@v6
with:
script: |
const newTag = 'v${{ needs.check-version.outputs.new_version }}';
try {
await github.rest.git.createTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: newTag,
message: `Release ${newTag}`,
object: context.sha,
type: 'commit'
});
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${newTag}`,
sha: context.sha
});
console.log(`Created and pushed new tag: ${newTag}`);
} catch (error) {
console.error('Error creating tag:', error);
core.setFailed(`Failed to create tag: ${error.message}`);
}
# Compare pyproject version with published version on PyPI.
check-pypi-version:
name: Check PyPI version
runs-on: ubuntu-latest
permissions:
id-token: read

steps:
- uses: actions/checkout@v4

# See: https://github.com/marketplace/actions/python-project-version-check
- name: Check PyPI version
uses: maybe-hello-world/pyproject-check-version@v4
id: pypi-version-check
with:
pyproject-path: "./pyproject.toml"

- name: Check PyPI version output
run: |
echo "Output: ${{ steps.pypi-version-check.outputs.local_version_is_higher }}"
echo "Local version: ${{ steps.pypi-version-check.outputs.local_version }}"
echo "Public version: ${{ steps.pypi-version-check.outputs.public_version }}"
publish-to-pypi:
name: >-
Publish Python distribution to PyPI
Expand Down

0 comments on commit 487ff3e

Please sign in to comment.