diff --git a/.gitea/release.yaml b/.gitea/release.yaml index 6907e14..962899a 100644 --- a/.gitea/release.yaml +++ b/.gitea/release.yaml @@ -1 +1 @@ -version_descriptor: setup.py +version_descriptor: pyproject.toml diff --git a/flake.lock b/flake.lock index 08e416f..f01d5cb 100644 --- a/flake.lock +++ b/flake.lock @@ -34,10 +34,31 @@ "type": "github" } }, + "pyproject-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1764134915, + "narHash": "sha256-xaKvtPx6YAnA3HQVp5LwyYG1MaN4LLehpQI8xEdBvBY=", + "owner": "pyproject-nix", + "repo": "pyproject.nix", + "rev": "2c8df1383b32e5443c921f61224b198a2282a657", + "type": "github" + }, + "original": { + "owner": "pyproject-nix", + "repo": "pyproject.nix", + "type": "github" + } + }, "root": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "pyproject-nix": "pyproject-nix" } }, "systems": { diff --git a/flake.nix b/flake.nix index 6b53cca..723e2da 100644 --- a/flake.nix +++ b/flake.nix @@ -4,22 +4,23 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; flake-utils.url = "github:numtide/flake-utils"; + + pyproject-nix = { + url = "github:pyproject-nix/pyproject.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, nixpkgs, flake-utils, ... }: + outputs = { self, nixpkgs, flake-utils, pyproject-nix }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; - python = pkgs.python313.withPackages (ps: with ps; [ - isort - flake8 - semver - toml - requests - pyyaml - packaging - ]); + pythonProject = pyproject-nix.lib.project.loadPyproject { + projectRoot = ./.; + }; + + pythonInterpreter = pkgs.python313; pythonPackage = pkgs.python3Packages.buildPythonPackage { name = "release-action"; @@ -32,24 +33,18 @@ pkgs.envsubst pkgs.just pkgs.gitea-actions-runner - python + (pythonInterpreter.withPackages + (pythonProject.renderers.withPackages { + python = pythonInterpreter; + extraPackages = ps: with ps; [ flake8 isort ]; + })) ]; }; - packages.default = pkgs.writers.writePython3Bin - "release-action" - { - libraries = with pkgs.python3Packages; [ - semver # TODO move to setup.py? - toml - requests - pythonPackage - pyyaml - packaging - ]; - } - (builtins.readFile ./src/main.py) - ; + packages.default = pythonInterpreter.pkgs.buildPythonPackage ( + pythonProject.renderers.buildPythonPackage { + python = pythonInterpreter; + }); } ); } diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..d3df7ab --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,16 @@ +[project] +name = "gitea-release-action" +version = "0.0.1" +description = "reusable action for release workflows" +authors = [ ] +requires-python = ">=3.13" +dependencies = [ + "semver", + "toml", + "requests", + "pyyaml", + "packaging" +] + +[project.scripts] +gitea-release-action = "main:main_cli" diff --git a/setup.py b/setup.py deleted file mode 100644 index 5ab564c..0000000 --- a/setup.py +++ /dev/null @@ -1,6 +0,0 @@ -from setuptools import setup - -setup( - name='release-action', - version='0.0.1', -) diff --git a/src/main.py b/src/main.py index 94a9f02..6bd2e0b 100755 --- a/src/main.py +++ b/src/main.py @@ -248,7 +248,7 @@ def sync_versions(project_description: ProjectDescription): sync(artefact.version_descriptor) -if __name__ == '__main__': +def main_cli(): parser = ArgumentParser() parser.add_argument('action', choices=[ 'declare',