diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..10256a1 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + open-pull-requests-limit: 10 diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..d654224 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,5 @@ +changelog: + exclude: + labels: + - ignore-for-release + - dependencies diff --git a/.github/workflows/ha_and_hacs_validate.yml b/.github/workflows/ha_and_hacs_validate.yml new file mode 100644 index 0000000..d7d6701 --- /dev/null +++ b/.github/workflows/ha_and_hacs_validate.yml @@ -0,0 +1,20 @@ +name: HA and HACS Validate + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + ha_and_hacs_validation: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4.1.7 + - name: Hassfest validation + uses: home-assistant/actions/hassfest@master + - name: HACS validation + uses: hacs/action@main + with: + category: integration + ignore: brands diff --git a/.github/workflows/hacs.yml b/.github/workflows/hacs.yml deleted file mode 100644 index df1dd1a..0000000 --- a/.github/workflows/hacs.yml +++ /dev/null @@ -1,20 +0,0 @@ -# https://github.com/hacs/action -name: HACS - -on: - push: - pull_request: - schedule: - - cron: "0 0 * * *" - -jobs: - validate: - runs-on: "ubuntu-latest" - name: HACS - steps: - - uses: "actions/checkout@v2" - - name: HACS validation - uses: "hacs/action@main" - with: - ignore: "brands" - category: "integration" diff --git a/.github/workflows/hassfest.yml b/.github/workflows/hassfest.yml deleted file mode 100644 index 495c0f5..0000000 --- a/.github/workflows/hassfest.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: hassfest - -on: - push: - pull_request: - schedule: - - cron: "0 0 * * *" - -jobs: - validate: - name: hassfest - runs-on: "ubuntu-latest" - steps: - - uses: "actions/checkout@v2" - - uses: home-assistant/actions/hassfest@master diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 1d6826e..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Release - -on: - push: - tags: - - "v*.*.*" - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Release - uses: softprops/action-gh-release@v1 diff --git a/.github/workflows/version_update_and_zip_on_release.yml b/.github/workflows/version_update_and_zip_on_release.yml new file mode 100644 index 0000000..44bbcef --- /dev/null +++ b/.github/workflows/version_update_and_zip_on_release.yml @@ -0,0 +1,59 @@ +name: Update Version and Create Zip on Release +on: + workflow_dispatch: + release: + types: [published, edited] + +jobs: + update_version: + if: ${{ github.event_name == 'release' && github.event.release.prerelease == false && github.event.release.draft == false }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4.1.7 + - name: Debug Variables + run: | + echo "github.event_name: ${{ github.event_name }}" + echo "github.ref_name: ${{ github.ref_name }}" + echo "github.event.repository.default_branch: ${{ github.event.repository.default_branch }}" + echo "github.event.release.target_commitish: ${{ github.event.release.target_commitish }}" + echo "github.event.release.prerelease: ${{ github.event.release.prerelease }}" + echo "github.event.release.draft: ${{ github.event.release.draft }}" + - name: Update Version in Manifest + run: | + sed -i 's/\"version\"\s*\:\s*\".*\"/\"version\"\:\"${{ github.ref_name }}\"/g' ./custom_components/opnsense/manifest.json + - name: Update Version in const.py + run: | + sed -i 's/VERSION \= \".*\"/VERSION \= \"${{ github.ref_name }}\"/' ./custom_components/opnsense/const.py + - name: Commit & Push Version Changes + uses: actions-js/push@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.event.release.target_commitish }} + message: 'Updating to version ${{ github.ref_name }}' + + create_zip: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4.1.7 + - name: Create Zip + uses: thedoctor0/zip-release@0.7.6 + with: + type: 'zip' + filename: 'opnsense.zip' + directory: ./custom_components/opnsense + - name: Upload Zip to Release + if: ${{ github.event_name == 'release' }} + uses: Roang-zero1/github-upload-release-artifacts-action@v3.0.0 + with: + args: ./custom_components/opnsense/opnsense.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Add Zip to Action + if: ${{ github.event_name == 'workflow_dispatch' }} + uses: actions/upload-artifact@v4.3.6 + with: + name: opnsense + path: ./custom_components/opnsense/opnsense.zip + if-no-files-found: error diff --git a/custom_components/opnsense/const.py b/custom_components/opnsense/const.py index 746b6da..32f6b06 100644 --- a/custom_components/opnsense/const.py +++ b/custom_components/opnsense/const.py @@ -1,7 +1,5 @@ """The OPNsense component.""" -from __future__ import annotations - from typing import Final from homeassistant.components.sensor import ( @@ -13,10 +11,10 @@ PERCENTAGE, UnitOfFrequency, UnitOfInformation, - UnitOfTemperature, UnitOfTime, ) +VERSION = "0.1.0" DEFAULT_USERNAME = "" DOMAIN = "opnsense" diff --git a/hacs.json b/hacs.json index 1f95eb9..8b61be2 100644 --- a/hacs.json +++ b/hacs.json @@ -1,5 +1,6 @@ { "name": "OPNsense integration for Home Assistant", - "homeassistant": "2022.4.0", - "render_readme": true + "homeassistant": "2022.4.0b0", + "zip_release": true, + "filename": "opnsense.zip" }