Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add us deployment option #26

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/publish_on_tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ on:
tags:
- '*.*.*'

env:
API_URL: https://api.cloud.deepset.ai
# For the US tenant
# API_URL: https://api.us.deepset.ai

jobs:
build-and-push:
runs-on: ubuntu-latest
Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ After forking or cloning this repository:
(To add a secret, go to your repository and choose _Settings > Secrets and variables > Actions > New repository secret_.)
3. Enable workflows for your repository by going to _Actions > Enable workflows_.
4. (Optional) Adjust the workflow file in `.github/workflows/publish_on_tag.yaml` as needed.
5. Create a new release with a tag to trigger the GitHub Actions workflow. The workflow builds and pushes the custom component to deepset Cloud with the tag as version. For help, see [GitHub documentation](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository).
5. (Optional) If you're not using the European deepset Cloud tenant, change the `API_URL` variable in `.github/workflows/publish_on_tag.yaml`
6. Create a new release with a tag to trigger the GitHub Actions workflow. The workflow builds and pushes the custom component to deepset Cloud with the tag as version. For help, see [GitHub documentation](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository).

> **Warning:** When using this GitHub Actions workflow, the version specified in the `__about__` file will be overwritten by the tag value. Make sure your tag matches the desired version number.

Expand All @@ -116,11 +117,17 @@ You can check the upload status in the `Actions` tab of your forked repository.
### Uploading a zipped repository with commands

In this method, you run commands to zip and push the repository to deepset Cloud.

1. Set your [deepset Cloud API key](https://docs.cloud.deepset.ai/docs/generate-api-key).
1. (Optional) If you're not using the European tenant, set the API URL:
- deepset Cloud Europe:
- On Linux and macOS: `export API_URL="https://api.cloud.deepset.ai"`
- On Windows: `set API_URL=https://api.cloud.deepset.ai`
- deepset Cloud US:
- On Linux and macOS: `export API_URL="https://api.us.deepset.ai"`
- On Windows: `set API_URL=https://api.us.deepset.ai`
2. Set your [deepset Cloud API key](https://docs.cloud.deepset.ai/docs/generate-api-key).
- On Linux and macOS: `export API_KEY=<TOKEN>`
- On Windows: `set API_KEY=<TOKEN>`
2. Upload your project by running the following command from inside of this project:
3. Upload your project by running the following command from inside of this project:
- On Linux and macOS: `hatch run dc:build-and-push`
- On Windows: `hatch run dc:build-windows` and `hatch run dc:push-windows`
This creates a ZIP file called `custom_component.zip` in the `dist` directory and uploads it to deepset Cloud.
Expand Down
25 changes: 17 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,23 @@ detached = true

[tool.hatch.envs.dc.scripts]
build = "mkdir -p dist && zip -r dist/custom_component.zip ./* -x 'dist/*' '**/__pycache__/*'"
push = "curl --request POST --url https://api.cloud.deepset.ai/api/v2/custom_components --header 'accept: application/json' --header \"Authorization: Bearer $API_KEY\" --form 'file=@dist/custom_component.zip;type=application/zip'"
build-and-push = "hatch run code-quality:all && mkdir -p dist && zip -r dist/custom_component.zip ./* -x 'dist/*' '**/__pycache__/*' && curl --request POST --url https://api.cloud.deepset.ai/api/v2/custom_components --header 'accept: application/json' --header \"Authorization: Bearer $API_KEY\" --form 'file=@dist/custom_component.zip;type=application/zip'"
list = "curl --request GET --url https://api.cloud.deepset.ai/api/v2/custom_components --header 'accept: application/json' --header \"Authorization: Bearer $API_KEY\""
build-windows = "powershell -Command \"& {{ if (-Not (Test-Path dist)) {{mkdir dist}}; if (Test-Path dist/custom_component.zip) {{ Remove-Item dist/custom_component.zip }}; Get-ChildItem -Path . | Where-Object {{ $_.FullName -notlike '*\\dist*' }} | Compress-Archive -DestinationPath dist/custom_component.zip -Update }}"
push-windows = "curl --request POST --url https://api.cloud.deepset.ai/api/v2/custom_components --header \"accept: application/json\" --header \"Authorization: Bearer %API_KEY%\" --form \"file=@dist/custom_component.zip;type=application/zip\""
list-windows = "curl --request GET --url https://api.cloud.deepset.ai/api/v2/custom_components --header \"accept: application/json\" --header \"Authorization: Bearer %API_KEY%\""
logs = "curl --request GET --url https://api.cloud.deepset.ai/api/v2/custom_components/logs --header 'accept: text/plain' --header \"Authorization: Bearer $API_KEY\""
logs-windows = "curl --request GET --url https://api.cloud.deepset.ai/api/v2/custom_components/logs --header \"accept: text/plain\" --header \"Authorization: Bearer %API_KEY%\""
push = "curl --request POST --url ${API_URL:-https://api.cloud.deepset.ai}/api/v2/custom_components --header 'accept: application/json' --header \"Authorization: Bearer $API_KEY\" --form 'file=@dist/custom_component.zip;type=application/zip'"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did it with default variables to avoid introducing another dimension

build-and-push = "hatch run code-quality:all && mkdir -p dist && zip -r dist/custom_component.zip ./* -x 'dist/*' '**/__pycache__/*' && curl --request POST --url ${API_URL:-https://api.cloud.deepset.ai}/api/v2/custom_components --header 'accept: application/json' --header \"Authorization: Bearer $API_KEY\" --form 'file=@dist/custom_component.zip;type=application/zip'"
list = "curl --request GET --url ${API_URL:-https://api.cloud.deepset.ai}/api/v2/custom_components --header 'accept: application/json' --header \"Authorization: Bearer $API_KEY\""
build-windows = "powershell -Command \"& {{ if (-Not (Test-Path dist)) {{mkdir dist}}; if (Test-Path dist/custom_component.zip) {{ Remove-Item dist/custom_component.zip }}; Get-ChildItem -Path . | Where-Object {{ $_.FullName -notlike '*\\dist*' }} | Compress-Archive -DestinationPath dist/custom_component.zip -Update }}\""
push-windows = [
'IF "%API_URL%"=="" (SET "_api_url=https://api.cloud.deepset.ai") ELSE (SET "_api_url=%API_URL%")',
"curl --request POST --url %_api_url%/api/v2/custom_components --header \"accept: application/json\" --header \"Authorization: Bearer %API_KEY%\" --form \"file=@dist/custom_component.zip;type=application/zip\""
]
list-windows = [
'IF "%API_URL%"=="" (SET "_api_url=https://api.cloud.deepset.ai") ELSE (SET "_api_url=%API_URL%")',
"curl --request GET --url %_api_url%/api/v2/custom_components --header \"accept: application/json\" --header \"Authorization: Bearer %API_KEY%\""
]
logs = "curl --request GET --url ${API_URL:-https://api.cloud.deepset.ai}/api/v2/custom_components/logs --header 'accept: text/plain' --header \"Authorization: Bearer $API_KEY\""
logs-windows = [
'IF "%API_URL%"=="" (SET "_api_url=https://api.cloud.deepset.ai") ELSE (SET "_api_url=%API_URL%")',
"curl --request GET --url %_api_url%/api/v2/custom_components/logs --header \"accept: text/plain\" --header \"Authorization: Bearer %API_KEY%\""
]

[tool.hatch.envs.code-quality]
python = "3.11"
Expand Down
Loading