Skip to content

Commit

Permalink
Merge pull request #25 from geertmeersman/dev-current
Browse files Browse the repository at this point in the history
feat: synchronise charger time
  • Loading branch information
geertmeersman committed May 7, 2024
2 parents c80b936 + c081207 commit e653732
Show file tree
Hide file tree
Showing 14 changed files with 607 additions and 34 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
48 changes: 48 additions & 0 deletions .github/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
- name: Stale
description: Stale
color: 393C41
- name: feat
description: A new feature
color: a2eeef
- name: fix
description: A bug fix
color: d3fc03
- name: docs
description: Documentation only changes
color: D4C5F9
- name: documentation
description: This issue relates to writing documentation
color: D4C5F9
- name: doc
description: This issue relates to writing documentation
color: D4C5F9
- name: style
description: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
color: D4C5F9
- name: refactor
description: A code change that neither fixes a bug nor adds a feature
color: D4C5F9
- name: perf
description: A code change that improves performance
color: d3fc03
- name: test
description: Adding missing or correcting existing tests
color: d3fc03
- name: chore
description: Changes to the build process or auxiliary tools and libraries such as documentation generation
color: d3fc03
- name: major
description: A change requiring a major version bump
color: 6b230e
- name: minor
description: A change requiring a minor version bump
color: cc6749
- name: patch
description: A change requiring a patch version bump
color: f9d0c4
- name: breaking
description: A breaking change
color: d30000
- name: breaking change
description: A breaking change
color: d30000
73 changes: 73 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name-template: "Release v$RESOLVED_VERSION"
tag-template: "v$RESOLVED_VERSION"
template: |
## What Changed 👀
$CHANGES
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
categories:
- title: 🚀 Features
labels:
- feat
- feature
- enhancement
- title: 🐛 Bug Fixes
labels:
- fix
- bug
- title: ⚠️ Breaking
labels:
- breaking
- breaking change
- title: ⚠️ Changes
labels:
- changed
- title: ⛔️ Deprecated
labels:
- deprecated
- title: 🗑 Removed
labels:
- removed
- title: 🔐 Security
labels:
- security
- title: 📄 Documentation
labels:
- docs
- doc
- documentation
- title: 🛠 Refactoring
labels:
- refactor
- style
- title: 🚀 Performance
labels:
- perf
- title: 🧪 Test
labels:
- test
- title: 👷 Chore
labels:
- chore
- title: 🧩 Dependency Updates
labels:
- deps
- dependencies
collapse-after: 5

change-template: "- $TITLE @$AUTHOR (#$NUMBER)"
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- major
minor:
labels:
- minor
patch:
labels:
- patch
default: patch

exclude-labels:
- skip-changelog
69 changes: 69 additions & 0 deletions .github/scripts/get_new_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
"""Script to calculate the next beta version."""
import os
import sys

import requests

# Get repository owner and repository name from the environment variable
repository = os.environ["GITHUB_REPOSITORY"]
owner, repo = repository.split("/")

# print(f"Repository: {repo}")
# print(f"Owner: {owner}")

# Get the latest release information
response = requests.get(
f"https://api.github.com/repos/{owner}/{repo}/releases/latest", timeout=10
)
latest_release = response.json()
latest_version = latest_release["tag_name"]

ref = os.environ["GITHUB_REF"]

# Get the commit count since the latest release
response = requests.get(
f"https://api.github.com/repos/{owner}/{repo}/compare/{latest_version}...{ref}",
timeout=10,
)
compare_info = response.json()
commit_count = compare_info["total_commits"]


def get_semver_level(commit_messages):
"""Extract SemVer level."""
major_keywords = ["breaking change", "major"]
minor_keywords = ["feat", "minor"]
for message in commit_messages:
if any(keyword in message for keyword in major_keywords):
return "major"
for message in commit_messages:
if any(keyword in message for keyword in minor_keywords):
return "minor"
return "patch"


# Determine version components based on commit messages
commit_messages = []
for commit in compare_info["commits"]:
commit_messages.append(commit["commit"]["message"])

bump = get_semver_level(commit_messages)

major, minor, patch = map(int, latest_version[1:].split("."))

if bump == "major":
major += 1
elif bump == "minor":
minor += 1
else:
patch += 1

# Create the next version
next_version = f"v{major}.{minor}.{patch}"

# Check if there are any commits since the latest release
if commit_count > 0:
next_version += f"-beta.{commit_count}"

print(next_version)
sys.exit(0)
43 changes: 43 additions & 0 deletions .github/scripts/pr_extract_labels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Script to extract the labels for a PR."""
import os
import re
import sys


def extract_semver_types(commit_messages):
"""Extract SemVer types."""
types = []
for message in commit_messages:
pattern = r"^(feat|fix|chore|docs|style|refactor|perf|test)(?:\(.+?\))?:\s(.+)$"
match = re.match(pattern, message)
if match and match.group(1) not in types:
types.append(match.group(1))
return types


def get_semver_level(commit_messages):
"""Extract SemVer level."""
major_keywords = ["breaking change", "major"]
minor_keywords = ["feat", "minor"]
for message in commit_messages:
if any(keyword in message for keyword in major_keywords):
return "major"
for message in commit_messages:
if any(keyword in message for keyword in minor_keywords):
return "minor"
return "patch"


file_path = "COMMIT_MESSAGES"
if os.path.exists(file_path):
with open(file_path) as file:
messages = []
for line in file:
messages.append(line.strip())
semver_level = get_semver_level(messages)
types = extract_semver_types(messages)
types.append(semver_level)
print(types)
sys.exit(0)
else:
sys.exit(f"ERROR: {file_path} does not exist")
92 changes: 92 additions & 0 deletions .github/workflows/bump_version_and_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Release - Bump and Release
on: [workflow_dispatch]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
create_release_draft:
name: Create the release draft
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: ⤵️ Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: 🗑 Delete drafts
uses: hugo19941994/delete-draft-releases@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 📝 Draft release
uses: release-drafter/release-drafter@v6
id: release_drafter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 🔄 Update version in 'VERSION' and push changes
env:
tag_name: ${{ steps.release_drafter.outputs.tag_name }}
GITHUB_REPO: ${{ github.event.repository.name }}
run: |
echo $tag_name > VERSION
- name: 🚀 Add and commit changes
uses: EndBug/add-and-commit@v9
with:
message: Bump version ${{ steps.release_drafter.outputs.tag_name }}

- name: 📝 Publish release
uses: release-drafter/release-drafter@v6
id: release_published
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
publish: true

- name: "✏️ Generate release changelog"
uses: heinrichreimer/github-changelog-generator-action@v2.4
with:
token: ${{ secrets.GH_PAT }}
issues: true
issuesWoLabels: true
pullRequests: true
prWoLabels: true
unreleased: false
addSections: '{"documentation":{"prefix":"**Documentation:**","labels":["documentation"]}}'

- name: ✅ Commit release notes
uses: EndBug/add-and-commit@v9
with:
message: Commit release notes ${{ steps.release_drafter.outputs.tag_name }}

- name: 📦 Create zip file
run: |
cd config
zip -r "${{ github.event.repository.name }}.zip" .
mv "${{ github.event.repository.name }}.zip" ..
- name: 📎 Upload zip file to release
uses: actions/upload-artifact@v4
with:
name: release-artifact
path: "${{ github.event.repository.name }}.zip"

- name: 📝 Update release with zip file
run: |
gh release upload ${{ steps.release_drafter.outputs.tag_name }} "${{ github.event.repository.name }}.zip"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 🚀 Discord notification
env:
tag_name: ${{ steps.release_drafter.outputs.tag_name }}
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: "New release published: https://github.com/{{ EVENT_PAYLOAD.repository.full_name }}/releases/tag/{{tag_name}}"
20 changes: 20 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dependency Review Action
#
# This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging.
#
# Source repository: https://github.com/actions/dependency-review-action
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
name: "Analysis - Dependency Review"
on: [pull_request]

permissions:
contents: read

jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- name: "Checkout Repository"
uses: actions/checkout@v4
- name: "Dependency Review"
uses: actions/dependency-review-action@v4
Loading

0 comments on commit e653732

Please sign in to comment.