From 7930ffd561bc95a24b5370b6aeda5711057bd9b1 Mon Sep 17 00:00:00 2001 From: Oliver Cullimore Date: Wed, 27 Sep 2023 18:40:30 +0100 Subject: [PATCH 1/2] ci: Migrate to commitizen to bump version --- .github/workflows/bump.yml | 33 +++++++++++++++ .github/workflows/release.yml | 40 ++++--------------- .../uk_bin_collection/manifest.json | 4 +- pyproject.toml | 23 ++++------- 4 files changed, 50 insertions(+), 50 deletions(-) create mode 100644 .github/workflows/bump.yml diff --git a/.github/workflows/bump.yml b/.github/workflows/bump.yml new file mode 100644 index 0000000000..3803de095a --- /dev/null +++ b/.github/workflows/bump.yml @@ -0,0 +1,33 @@ +name: Bump Version + +on: + push: + # Trigger unless only the wiki directory changed + paths-ignore: + - "wiki/**" + - "**/**.md" + branches: [ "master" ] + +jobs: + bump: + if: "!startsWith(github.event.head_commit.message, 'bump:')" + runs-on: ubuntu-latest + environment: bump + concurrency: bump + permissions: + id-token: write + contents: write + steps: + - uses: actions/checkout@v4 + with: + token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}" + fetch-depth: 0 + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Bump version + id: cz + uses: commitizen-tools/commitizen-action@master + with: + github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dff474f412..fd5663c6a8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,23 +2,18 @@ name: Publish Release on: push: - # Trigger only when uk_bin_collection/uk_bin_collection directory changes - paths: - - "uk_bin_collection/uk_bin_collection/**" - branches: [ "master" ] + tags: + - '*' jobs: release: runs-on: ubuntu-latest environment: release - concurrency: release permissions: id-token: write contents: write steps: - uses: actions/checkout@v4 - with: - fetch-depth: 0 - uses: actions/setup-python@v4 with: python-version: '3.10' @@ -36,36 +31,17 @@ jobs: - name: Install run: make install - - name: Python Semantic Release - id: release - uses: python-semantic-release/python-semantic-release@v8.1.1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} # May need to replace with a Personal Access Token if it fails + - name: Set release version + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - uses: ncipollo/release-action@v1 + - name: Create release + uses: ncipollo/release-action@v1 with: - tag: ${{ steps.release.outputs.tag }} - allowUpdates: true + tag: ${{ env.RELEASE_VERSION }} generateReleaseNotes: true - - - name: Update manifest.json version - if: steps.release.outputs.released == 'true' - uses: jossef/action-set-json-field@v2.1 - with: - file: custom_components/uk_bin_collection/manifest.json - field: version - value: ${{ steps.release.outputs.tag }} - - - name: Update manifest.json requirements - if: steps.release.outputs.released == 'true' - uses: jossef/action-set-json-field@v2.1 - with: - file: custom_components/uk_bin_collection/manifest.json - field: requirements[0] - value: uk-bin-collection>=${{ steps.release.outputs.tag }} + prerelease: true - name: Build and publish package - if: steps.release.outputs.released == 'true' run: | poetry config pypi-token.pypi "${{ secrets.PYPI_API_KEY }}" poetry publish --build diff --git a/custom_components/uk_bin_collection/manifest.json b/custom_components/uk_bin_collection/manifest.json index 80dbef5c14..e35ee0bd11 100644 --- a/custom_components/uk_bin_collection/manifest.json +++ b/custom_components/uk_bin_collection/manifest.json @@ -3,12 +3,12 @@ "name": "UK Bin Collection Data", "documentation": "https://github.com/robbrad/UKBinCollectionData/wiki", "issue_tracker": "https://github.com/robbrad/UKBinCollectionData/issues", - "requirements": ["uk-bin-collection"], + "requirements": ["uk-bin-collection>=0.10.0"], "codeowners": ["@robbrad"], "config_flow": true, "zeroconf": [], "homeassistant": "2021.1.0", - "version": "0.1.0", + "version": "0.10.0", "after_dependencies": [], "dependencies": [], "iot_class": "cloud_polling", diff --git a/pyproject.toml b/pyproject.toml index 675ef6b812..69d32fee2e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,21 +55,12 @@ requests = "*" selenium = "*" lxml = "*" -[tool.semantic_release] -version_toml = ["pyproject.toml:tool.poetry.version"] -branch = "master" -commit_message = "Release version {version}" -prerelease = true -major_on_zero = true - -[tool.semantic_release.commit_parser_options] -allowed_tags = [ - "ci", - "docs", - "feat", - "fix", - "refactor" +[tool.commitizen] +major_version_zero = true +version_provider = "poetry" +version_scheme = "semver" +version_files = [ + "custom_components/uk_bin_collection/manifest.json:version", + "custom_components/uk_bin_collection/manifest.json:requirements" ] -minor_tags = ["feat"] -patch_tags = ["fix"] From 5d416c11d38ec7a98fba888c3635ad237a99faf1 Mon Sep 17 00:00:00 2001 From: Oliver Cullimore Date: Wed, 27 Sep 2023 19:20:40 +0100 Subject: [PATCH 2/2] ci: Migrate to commitizen to bump version --- custom_components/uk_bin_collection/config_flow.py | 2 +- pyproject.toml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/custom_components/uk_bin_collection/config_flow.py b/custom_components/uk_bin_collection/config_flow.py index 7ce95e998d..551daabe71 100644 --- a/custom_components/uk_bin_collection/config_flow.py +++ b/custom_components/uk_bin_collection/config_flow.py @@ -20,7 +20,7 @@ def __init__(self): async def get_councils_json(self) -> object: """Returns an object of supported council's and their required fields.""" # Fetch the JSON data from the provided URL - url = "https://raw.githubusercontent.com/robbrad/UKBinCollectionData/master/uk_bin_collection/tests/input.json" + url = "https://raw.githubusercontent.com/robbrad/UKBinCollectionData/0.10.0/uk_bin_collection/tests/input.json" async with aiohttp.ClientSession() as session: async with session.get(url) as response: data_text = await response.text() diff --git a/pyproject.toml b/pyproject.toml index 69d32fee2e..42b0e3ff85 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,5 +62,6 @@ version_scheme = "semver" version_files = [ "custom_components/uk_bin_collection/manifest.json:version", "custom_components/uk_bin_collection/manifest.json:requirements" + "custom_components/uk_bin_collection/config_flow.py:githubusercontent" ]