diff --git a/.github/workflows/publish_to_npm.yaml b/.github/workflows/publish_to_npm.yaml new file mode 100644 index 0000000..6831635 --- /dev/null +++ b/.github/workflows/publish_to_npm.yaml @@ -0,0 +1,98 @@ +name: Publish to npm + +on: + push: + tags: + - 'v*' # Trigger on tags starting with 'v' + workflow_dispatch: + inputs: + package_version: + description: 'Version to publish (e.g., vX.Y, vX.Y.Z, vX.Y.ZaN, vX.Y.ZbN, vX.Y.ZrcN)' + required: true + +jobs: + release: + runs-on: ubuntu-latest + + defaults: + run: + working-directory: packages/typescript # Set working directory + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Print Head Commit SHA + run: | + echo "Head Commit SHA: ${{ github.sha }}" + + - name: Validate And Extract Version + run: | + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + INPUT_VALUE="${{ github.event.inputs.package_version }}" + else + INPUT_VALUE="${GITHUB_REF#refs/tags/}" + fi + + echo "Tag/input value: $INPUT_VALUE" + + # Validate tag/input format: vX.Y.Z, vX.Y, vX.Y.ZaN, vX.Y.ZbN, vX.Y.ZrcN + if [[ ! "$INPUT_VALUE" =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?(a[0-9]+|b[0-9]+|rc[0-9]+)?$ ]]; then + echo "Invalid tag/input format: $INPUT_VALUE" + echo "Allowed formats: vX.Y, vX.Y.Z, vX.Y.ZaN, vX.Y.ZbN, vX.Y.ZrcN" + exit 1 + fi + + PACKAGE_VERSION="${INPUT_VALUE#v}" + + # Convert pre-release format; determine npm tag + if [[ "$PACKAGE_VERSION" =~ ^([0-9]+\.[0-9]+\.[0-9]+)a([0-9]+)$ ]]; then + PACKAGE_VERSION="${BASH_REMATCH[1]}-alpha.${BASH_REMATCH[2]}" + NPM_TAG="alpha" + elif [[ "$PACKAGE_VERSION" =~ ^([0-9]+\.[0-9]+\.[0-9]+)b([0-9]+)$ ]]; then + PACKAGE_VERSION="${BASH_REMATCH[1]}-beta.${BASH_REMATCH[2]}" + NPM_TAG="beta" + elif [[ "$PACKAGE_VERSION" =~ ^([0-9]+\.[0-9]+\.[0-9]+)rc([0-9]+)$ ]]; then + PACKAGE_VERSION="${BASH_REMATCH[1]}-rc.${BASH_REMATCH[2]}" + NPM_TAG="release-candidate" + else + NPM_TAG="latest" + fi + + echo "PACKAGE_VERSION=$PACKAGE_VERSION" + echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV + + echo "NPM_TAG=$NPM_TAG" + echo "NPM_TAG=$NPM_TAG" >> $GITHUB_ENV + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + registry-url: 'https://registry.npmjs.org/' + + - name: Update Version in package.json + run: npm version $PACKAGE_VERSION --no-git-tag-version + + - name: Install dependencies (skip postinstall scripts) + run: npm ci --ignore-scripts + + - name: Run Lint & Build + run: | + npm run lint || echo "::warning ::Lint warnings found" + npm run build + + - name: Audit for vulnerabilities + run: npm audit --audit-level=high || echo "::warning ::Vulnerabilities found" + + - name: Publish to npm + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npm publish --access public --tag $NPM_TAG + + - name: Display Published Package Info + run: | + PACKAGE_NAME=$(node -p "require('./package.json').name") + echo "Successfully published $PACKAGE_NAME@$PACKAGE_VERSION to npm with tag $NPM_TAG!" + echo "Install it using:" + echo -e "\tnpm install $PACKAGE_NAME@$PACKAGE_VERSION" diff --git a/.github/workflows/publish_to_pypi.yaml b/.github/workflows/publish_to_pypi.yaml new file mode 100644 index 0000000..b357af5 --- /dev/null +++ b/.github/workflows/publish_to_pypi.yaml @@ -0,0 +1,78 @@ +name: Publish to PyPI + +on: + push: + tags: + - 'v*' # Trigger on tags starting with 'v' + workflow_dispatch: + inputs: + package_version: + description: 'Version to publish (e.g., vX.Y, vX.Y.Z, vX.Y.ZaN, vX.Y.ZbN, vX.Y.ZrcN)' + required: true + +jobs: + release: + runs-on: ubuntu-latest + + permissions: + id-token: write # Required for Trusted Publisher authentication + + defaults: + run: + working-directory: packages/python # Set working directory + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Print Head Commit SHA + run: | + echo "Head Commit SHA: ${{ github.sha }}" + + - name: Validate And Extract Version + run: | + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + INPUT_VALUE="${{ github.event.inputs.package_version }}" + else + INPUT_VALUE="${GITHUB_REF#refs/tags/}" + fi + + echo "Tag/input value: $INPUT_VALUE" + + # Validate tag/input format: vX.Y.Z, vX.Y, vX.Y.ZaN, vX.Y.ZbN, vX.Y.ZrcN + if [[ ! "$INPUT_VALUE" =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?(a[0-9]+|b[0-9]+|rc[0-9]+)?$ ]]; then + echo "Invalid tag/input format: $INPUT_VALUE" + echo "Allowed formats: vX.Y, vX.Y.Z, vX.Y.ZaN, vX.Y.ZbN, vX.Y.ZrcN" + exit 1 + fi + + PACKAGE_VERSION="${INPUT_VALUE#v}" + echo "PACKAGE_VERSION=$PACKAGE_VERSION" + echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install build tools + run: | + pip install --upgrade build twine + + - name: Build the package + run: | + python3 -m build + + - name: Publish to PyPI using Trusted Publisher + run: | + twine upload dist/* --verbose + + - name: Display Published Package Info + run: | + PACKAGE_NAME=$(python3 -c "import tomli; from pathlib import Path; \ + content = Path('pyproject.toml').read_text(); \ + print(tomli.loads(content)['project']['name'])") + + echo "Successfully published $PACKAGE_NAME==$PACKAGE_VERSION to PyPI!" + echo "Install it using:" + echo -e "\tpip install $PACKAGE_NAME==$PACKAGE_VERSION" diff --git a/package.json b/package.json index 6763af0..d4cfa01 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "private": true, - "version": "0.9.0", + "version": "0.0.0", "scripts": { "generate-api-clients": "sh ./hack/generate-api-clients.sh", "test": "echo \"Error: no test specified\" && exit 1", diff --git a/packages/python/pyproject.toml b/packages/python/pyproject.toml index a28b548..64a1f16 100644 --- a/packages/python/pyproject.toml +++ b/packages/python/pyproject.toml @@ -1,12 +1,16 @@ [build-system] -requires = ["setuptools>=61.0"] +requires = [ + "setuptools>=61.0", + "environs>=9.5.0,<10.0.0", + "daytona_api_client>=0.12.2,<1.0.0" +] build-backend = "setuptools.build_meta" [project] name = "daytona_sdk" -version = "0.9.0" +dynamic = ["version"] authors = [ - { name = "Vedran Jukic", email = "vedran.jukic@gmail.com" }, + { name = "dummy", email = "dummy@mail.com" }, # TODO: publish-pipeline; change to daytona-org ] description = "Python SDK for Daytona" readme = "README.md" @@ -35,4 +39,7 @@ dev = [ "pydoc-markdown>=4.8.2", "black>=22.0.0", "isort>=5.10.0" -] \ No newline at end of file +] + +[tool.setuptools.dynamic] +version = {attr = "daytona_sdk.__version__"} diff --git a/packages/python/setup.py b/packages/python/setup.py deleted file mode 100644 index b0e06e5..0000000 --- a/packages/python/setup.py +++ /dev/null @@ -1,15 +0,0 @@ -from setuptools import setup, find_packages - -setup( - name="daytona_sdk", - version="0.1.4", - packages=find_packages(where="src"), - package_dir={"": "src"}, - install_requires=[ - # Add dependencies here - ], - # Include both packages - package_data={ - "daytona_sdk": ["*"] - }, -) diff --git a/packages/python/src/daytona_sdk/__init__.py b/packages/python/src/daytona_sdk/__init__.py index b516003..dfe2e67 100644 --- a/packages/python/src/daytona_sdk/__init__.py +++ b/packages/python/src/daytona_sdk/__init__.py @@ -7,6 +7,7 @@ SessionExecuteRequest, SessionExecuteResponse, ) +import os __all__ = [ "Daytona", @@ -17,3 +18,8 @@ "SessionExecuteRequest", "SessionExecuteResponse" ] + +def get_version(): + return os.getenv("PACKAGE_VERSION", "0.0.0") + +__version__ = get_version() diff --git a/packages/typescript/package.json b/packages/typescript/package.json index de2ec87..f414423 100644 --- a/packages/typescript/package.json +++ b/packages/typescript/package.json @@ -1,6 +1,6 @@ { "name": "@daytonaio/sdk", - "version": "0.9.0", + "version": "0.0.0", "description": "Daytona client library for AI Agents", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -39,4 +39,4 @@ "uuid": "^11.0.3", "@daytonaio/api-client": "~0.12.2" } -} \ No newline at end of file +}