diff --git a/.github/workflows/publish_on_tag.yaml b/.github/workflows/publish_on_tag.yaml index 65b7f0f..b42ac34 100644 --- a/.github/workflows/publish_on_tag.yaml +++ b/.github/workflows/publish_on_tag.yaml @@ -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 diff --git a/README.md b/README.md index 808b8c5..4687282 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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=` - On Windows: `set API_KEY=` -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. diff --git a/pyproject.toml b/pyproject.toml index 6a858d6..e9ed37b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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'" +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"