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
26 changes: 16 additions & 10 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,40 @@ jobs:
name: Build and publish to PyPI
runs-on: ubuntu-latest
needs: [authorize]
permissions:
contents: write
id-token: write
steps:
- name: Checkout for release to PyPI
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: 3.8
python-version: 3.9

- name: Install semantic release
run: python -m pip install python-semantic-release==10.5.3

- name: Run Test
run: python -m unittest discover -s ./src -p 'test_*.py'

- name: Publish distribution PyPI --dry-run
- name: Publish distribution to VCS Release (dry run)
if: ${{ github.event.inputs.dryRun == 'true'}}
run: |
python -m pip install python-semantic-release==7.33.0
semantic-release publish --noop
semantic-release -vv version --no-commit --no-tag --no-push

- name: Publish distribution PyPI
- name: Publish distribution to VCS Release
if: ${{ github.event.inputs.dryRun == 'false'}}
run: |
python -m pip install python-semantic-release==7.33.0
git config user.name amplitude-sdk-bot
git config user.email amplitude-sdk-bot@users.noreply.github.com
semantic-release publish
semantic-release version
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY_USERNAME: __token__
REPOSITORY_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}

- name: Publish distribution PyPI
if: ${{ github.event.inputs.dryRun == 'false'}}
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
51 changes: 38 additions & 13 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Publish to TestPyPI
name: Publish to Test PyPI

on: workflow_dispatch
on:
workflow_dispatch:
inputs:
dryRun:
description: "Preview only (no version bump, no publish)"
required: true
default: "true"

jobs:
authorize:
Expand All @@ -15,26 +21,45 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-n-publish:
name: Build and publish to TestPyPI
name: Build and publish to Test PyPI
runs-on: ubuntu-latest
needs: [authorize]
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v3
- name: Checkout for release to Test PyPI
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: 3.8
python-version: 3.9

- name: Install semantic release
run: python -m pip install python-semantic-release==10.5.3

- name: Install dependencies
run: python -m pip install build setuptools wheel twine
- name: Run Test
run: python -m unittest discover -s ./src -p 'test_*.py'

- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/ .
- name: Publish distribution to VCS Release (dry run)
if: ${{ github.event.inputs.dryRun == 'true' }}
run: |
semantic-release -vv version --no-commit --no-tag --no-push --noop

- name: Publish distribution to VCS Release
if: ${{ github.event.inputs.dryRun == 'false' }}
run: |
git config user.name amplitude-sdk-bot
git config user.email amplitude-sdk-bot@users.noreply.github.com
semantic-release version --no-push
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish distribution Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: ${{ github.event.inputs.dryRun == 'false' }}
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
19 changes: 10 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[tool.semantic_release]
version_variable = [
"src/amplitude/constants.py:SDK_VERSION"
]
major_on_zero = false
branch = "main"
upload_to_PyPI = true
upload_to_release = true
build_command = "pip install build && python -m build"
version_source = "tag"
commit_version_number = true
commit_subject = "chore(release): Bump version to {version}"
version_variables = [
"src/amplitude/constants.py:SDK_VERSION"
]
commit_message = "chore(release): Bump version to {version}"
commit_author = "amplitude-sdk-bot <amplitude-sdk-bot@users.noreply.github.com>"

[tool.semantic_release.branches.main]
match = "(main|master)"
prerelease = false

[tool.semantic_release.publish]
upload_to_vcs_release = true
Loading