Skip to content

Commit

Permalink
ci: Migrate to commitizen to bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverCullimore committed Sep 27, 2023
1 parent b270cac commit 7930ffd
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 50 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
@@ -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 }}
40 changes: 8 additions & 32 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -36,36 +31,17 @@ jobs:
- name: Install
run: make install

- name: Python Semantic Release
id: release
uses: python-semantic-release/[email protected]
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/[email protected]
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/[email protected]
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
4 changes: 2 additions & 2 deletions custom_components/uk_bin_collection/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 7 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

0 comments on commit 7930ffd

Please sign in to comment.