diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e4d614c..13a133d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,7 @@ on: branches: [main, dev] pull_request: branches: [main, dev] + workflow_call: jobs: test: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9a83c6e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,61 @@ +name: Publish to PyPI + +on: + workflow_dispatch: + +permissions: + contents: write + id-token: write + +jobs: + ci: + uses: ./.github/workflows/ci.yml + + publish: + needs: ci + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + environment: pypi + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Install uv + uses: astral-sh/setup-uv@v8.0.0 + with: + python-version: "3.12" + + - name: Get version + id: version + run: | + VERSION=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])") + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Check version not already published + run: | + VERSION="${{ steps.version.outputs.version }}" + if uv pip index versions designer-plugin 2>/dev/null | grep -q "$VERSION"; then + echo "Version $VERSION already exists on PyPI. Aborting." + exit 1 + fi + + - name: Validate tag does not exist + run: | + if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then + echo "Tag v${{ steps.version.outputs.version }} already exists. Aborting." + exit 1 + fi + + - name: Build package + run: uv build + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + + - name: Tag release + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git tag "v${{ steps.version.outputs.version }}" + git push origin "v${{ steps.version.outputs.version }}" diff --git a/pyproject.toml b/pyproject.toml index 5c2eb1c..b54eca7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,8 +7,8 @@ name = "designer-plugin" version = "1.3.0" description = "Python library for creating Disguise Designer plugins with DNS-SD discovery and remote Python execution" authors = [ - { name = "Tom Whittock", email = "tom.whittock@disguise.one" }, - { name = "Taegyun Ha", email = "taegyun.ha@disguise.one" } + { name = "Taegyun Ha", email = "taegyun.ha@disguise.one" }, + { name = "Tom Whittock", email = "tom.whittock@disguise.one" } ] dependencies = [ "aiohttp>=3.13.2",