From a84118de50d5b8f4b90066c387612a960222c89f Mon Sep 17 00:00:00 2001 From: Mick Date: Sun, 7 Jan 2024 19:05:07 +0000 Subject: [PATCH] Update release flow --- .devcontainer/devcontainer.json | 45 ++++++++++++++++++--------------- .github/workflows/release.yml | 37 +++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 33278f9..0f09e3e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,35 +2,40 @@ { "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", "name": "ha-sagemcom-fast", - "forwardPorts": [8123], - "portsAttributes": { + "forwardPorts": [ + 8123 + ], + "portsAttributes": { "8123": { "label": "Home Assistant", "onAutoForward": "openBrowserOnce" } }, + "features": { + "ghcr.io/devcontainers-contrib/features/ffmpeg-apt-get:1": {} + }, "postCreateCommand": "pip install -r requirements_dev.txt && pre-commit install && pre-commit install-hooks", "containerEnv": { "DEVCONTAINER": "1" - }, - "remoteUser": "vscode", - "customizations": { + }, + "remoteUser": "vscode", + "customizations": { "vscode": { - "extensions": [ - "ms-python.vscode-pylance", - "ms-python.python", - "redhat.vscode-yaml", - "esbenp.prettier-vscode", - "GitHub.vscode-pull-request-github", - "GitHub.copilot" - ], - "settings": { - "python.pythonPath": "/usr/local/bin/python", - "editor.formatOnPaste": false, - "editor.formatOnSave": true, - "editor.formatOnType": true, - "files.trimTrailingWhitespace": true - } + "extensions": [ + "ms-python.vscode-pylance", + "ms-python.python", + "redhat.vscode-yaml", + "esbenp.prettier-vscode", + "GitHub.vscode-pull-request-github", + "GitHub.copilot" + ], + "settings": { + "python.pythonPath": "/usr/local/bin/python", + "editor.formatOnPaste": false, + "editor.formatOnSave": true, + "editor.formatOnType": true, + "files.trimTrailingWhitespace": true + } } } } \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c16bfc6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,37 @@ +name: Release Custom Component to HACS + +on: + release: + types: [published] + +jobs: + package: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + # Retrieve new version to tag and publish release with + - name: Retrieve version from tag name + id: version + run: | + tag=${{ github.event.release.tag_name }} + version_number=${tag#?} + echo version: $version_number + echo "version=$version_number" >> $GITHUB_OUTPUT + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + + - name: Update manifest.json version to release version + uses: jossef/action-set-json-field@v2 + with: + file: custom_components/sagemcom_fast/manifest.json + field: version + value: ${{ steps.version.outputs.version }} + + - name: Commit changes + run: | + git add custom_components/sagemcom_fast/manifest.json + git commit -m "Bump version to ${{ steps.version.outputs.version }}." + git tag -f -a ${{ github.event.release.tag_name }} -m "Release ${{ steps.version.outputs.version }}." + git push origin HEAD:main + git push origin -f ${{ github.event.release.tag_name }}