diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..c36272a --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,72 @@ +name: Release and Publish + +on: + push: + tags: + - 'v*' + +permissions: + contents: write # Required for creating releases + id-token: write # Required for PyPI trusted publishing + +jobs: + create-release: + runs-on: ubuntu-latest + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + + steps: + - uses: actions/checkout@v4 + + - name: Create Release + id: create_release + uses: actions/github-script@v7 + with: + script: | + const script = require('./.github/workflows/scripts/create_release.js') + await script(github, context, core) + env: + RELEASE_TAG: ${{ github.ref_name }} + + build-n-publish: + needs: create-release + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/tracestorm + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + cache: 'pip' + + - name: Install build dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine build + + - name: Build source and wheel distributions + run: | + python -m build + twine check dist/* + + - name: Upload Release Assets + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create-release.outputs.upload_url }} + asset_path: ./dist/*.whl + asset_name: tracestorm-${{ github.ref_name }}.whl + asset_content_type: application/x-wheel+zip + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: dist/ + verbose: true + print-hash: true \ No newline at end of file diff --git a/.github/workflows/scripts/create_release.js b/.github/workflows/scripts/create_release.js new file mode 100644 index 0000000..53bdd76 --- /dev/null +++ b/.github/workflows/scripts/create_release.js @@ -0,0 +1,17 @@ +// Uses Github's API to create the release and wait for result +module.exports = async (github, context, core) => { + try { + const response = await github.rest.repos.createRelease({ + draft: false, + generate_release_notes: true, + name: process.env.RELEASE_TAG, + owner: context.repo.owner, + prerelease: false, + repo: context.repo.repo, + tag_name: process.env.RELEASE_TAG, + }); + core.setOutput('upload_url', response.data.upload_url); + } catch (error) { + core.setFailed(error.message); + } +} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 8420d34..03f4363 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,10 +4,11 @@ build-backend = "setuptools.build_meta" [project] name = "tracestorm" -version = "0.0.2" -description = "A replay tool for LLM requests" +version = "0.0.3" +description = "A tool for generating and replaying traces of requests to OpenAI API endpoints" +readme = "README.md" authors = [ - {name="Yao Fu", email="yao.fu.aisys@gmail.com"} + {name = "Yao Fu", email = "yao.fu.aisys@gmail.com"} ] dependencies = [ @@ -18,6 +19,7 @@ dependencies = [ "matplotlib>=3.10", "click>=8.1.8" ] +requires-python = ">=3.9" [project.scripts] tracestorm = "tracestorm.cli:main" @@ -29,32 +31,16 @@ exclude = [] [tool.ruff.lint] fixable = ["ALL"] unfixable = [ - # star imports - "F405", - "F403", - # lambda expression assignment - "E731", - # Loop control variable not used within loop body - "B007", - # raise distinguish errors - "B904", - # f-string format + "F405", # star imports + "F403", # lambda expression assignment + "E731", # Loop control variable not used within loop body + "B007", # raise distinguish errors + "B904", # f-string format "UP032", ] -select = [ - # isort - "I", -] -ignore = [ - # Loop control variable not used within loop body - "B007" -] - +select = ["I"] # isort +ignore = ["B007"] # Loop control variable not used within loop body [tool.isort] use_parentheses = true -skip_gitignore = true - -[tool.codespell] -skip = 'build,*.egg-info,images' -quiet-level = 1 \ No newline at end of file +skip_gitignore = true \ No newline at end of file