This repository was archived by the owner on May 26, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
feat: npm and pypi publish workflows #8
Open
MDzaja
wants to merge
3
commits into
daytonaio:main
Choose a base branch
from
MDzaja:publish-pipeline
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| 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: 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" >> $GITHUB_ENV | ||
| # Determine npm tag based on version suffix | ||
| if [[ "$PACKAGE_VERSION" =~ a[0-9]+$ ]]; then | ||
| NPM_TAG="alpha" | ||
| elif [[ "$PACKAGE_VERSION" =~ b[0-9]+$ ]]; then | ||
| NPM_TAG="beta" | ||
| elif [[ "$PACKAGE_VERSION" =~ rc[0-9]+$ ]]; then | ||
| NPM_TAG="release-candidate" | ||
| else | ||
| NPM_TAG="latest" | ||
| fi | ||
| 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" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| 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: 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" >> $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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" | ||
| name = "daytona-sdk" | ||
| dynamic = ["version"] | ||
| authors = [ | ||
| { name = "Vedran Jukic", email = "vedran.jukic@gmail.com" }, | ||
| { name = "dummy", email = "dummy@mail.com" }, # TODO: publish-pipeline; change to daytona-org | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change to |
||
| ] | ||
| 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" | ||
| ] | ||
| ] | ||
|
|
||
| [tool.setuptools.dynamic] | ||
| version = {attr = "daytona_sdk.__version__"} | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We follow this convention for pre-releases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MDzaja this doesn't seem to be addressed