-
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #578 from PiotrMachowski/dev
Dev
- Loading branch information
Showing
15 changed files
with
335 additions
and
100 deletions.
There are no files selected for viewing
This file contains 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 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,28 +1,38 @@ | ||
--- | ||
name: Release | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
env: | ||
COMPONENT_NAME: xiaomi_cloud_map_extractor | ||
|
||
jobs: | ||
release: | ||
name: Prepare release | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
id-token: write | ||
steps: | ||
- name: Download repo | ||
uses: actions/checkout@v1 | ||
uses: actions/checkout@v4.2.2 | ||
|
||
- name: Adjust version number | ||
shell: bash | ||
run: | | ||
version="${{ github.event.release.tag_name }}" | ||
yq e -P -o=json \ | ||
-i ".version = \"${version}\"" \ | ||
"${{ github.workspace }}/custom_components/${{ env.COMPONENT_NAME }}/manifest.json" | ||
- name: Zip xiaomi_cloud_map_extractor dir | ||
- name: Zip ${{ env.COMPONENT_NAME }} dir | ||
run: | | ||
cd /home/runner/work/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/custom_components/xiaomi_cloud_map_extractor | ||
zip xiaomi_cloud_map_extractor.zip -r ./ | ||
cd "${{ github.workspace }}/custom_components/${{ env.COMPONENT_NAME }}" | ||
zip ${{ env.COMPONENT_NAME }}.zip -r ./ | ||
- name: Upload zip to release | ||
uses: svenstaro/upload-release-action@v1-release | ||
uses: softprops/action-gh-release@v2.1.0 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: /home/runner/work/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_map_extractor.zip | ||
asset_name: xiaomi_cloud_map_extractor.zip | ||
tag: ${{ github.ref }} | ||
overwrite: true | ||
files: ${{ github.workspace }}/custom_components/${{ env.COMPONENT_NAME }}/${{ env.COMPONENT_NAME }}.zip |
This file contains 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 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 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
14 changes: 14 additions & 0 deletions
14
custom_components/xiaomi_cloud_map_extractor/common/backoff.py
This file contains 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,14 @@ | ||
import random | ||
|
||
|
||
class Backoff: | ||
"""Exponential backoff with jitter.""" | ||
|
||
def __init__(self, min_sleep, max_sleep): | ||
self.min_sleep = min_sleep | ||
self.sleep = min_sleep | ||
self.max_sleep = max_sleep | ||
|
||
def backoff(self): | ||
self.sleep = min(self.max_sleep, random.uniform(self.min_sleep, self.sleep * 3)) | ||
return self.sleep |
Oops, something went wrong.