Skip to content

Commit

Permalink
build: add release and publish actions
Browse files Browse the repository at this point in the history
  • Loading branch information
future-xy committed Feb 14, 2025
1 parent fd42623 commit 205139c
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 27 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions .github/workflows/scripts/create_release.js
Original file line number Diff line number Diff line change
@@ -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);
}
}
40 changes: 13 additions & 27 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected]"}
{name = "Yao Fu", email = "[email protected]"}
]

dependencies = [
Expand All @@ -18,6 +19,7 @@ dependencies = [
"matplotlib>=3.10",
"click>=8.1.8"
]
requires-python = ">=3.9"

[project.scripts]
tracestorm = "tracestorm.cli:main"
Expand All @@ -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
skip_gitignore = true

0 comments on commit 205139c

Please sign in to comment.