Skip to content

Commit

Permalink
Updated workflow for SDK release
Browse files Browse the repository at this point in the history
  • Loading branch information
StrahinjaJacimovic committed Sep 27, 2024
1 parent 64f7946 commit 91c6fa0
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 31 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ on:
type: boolean
description: Promote selected version to latest? (Only applied if index is set to "live")
default: false
notify_sdk:
type: boolean
description: Notify SDK
default: false

jobs:
index:
Expand Down Expand Up @@ -80,3 +84,18 @@ jobs:
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$repo_owner/$repo_name/dispatches \
-d "{\"event_type\": \"$event_type\", \"client_payload\": {\"version\": \"$version\", \"index\": \"$index\", \"unit\": false, \"integration\": true}}"
- name: Build SDK Message with Python
if: ${{ github.event.inputs.notify_sdk == 'true' }}
run: |
python -u scripts/build_message_sdk.py "${{ github.event.inputs.release_version }}" > message.txt
- name: Send SDK notification to Mattermost
if: ${{ github.event.inputs.notify_sdk == 'true' }}
env:
MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
run: |
MESSAGE=$(cat message.txt)
curl -X POST -H 'Content-Type: application/json' \
--data "{\"text\": \"$MESSAGE\"}" \
$MATTERMOST_WEBHOOK_URL
30 changes: 28 additions & 2 deletions .github/workflows/notify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ name: Notify Mattermost

on:
workflow_dispatch:
inputs:
notify_sdk:
type: boolean
description: Notify SDK
default: false
notify_components:
type: boolean
description: Notify Boards/Cards
default: false

jobs:
notify:
Expand All @@ -23,11 +32,28 @@ jobs:
pip install py7zr
pip install chardet
- name: Build Message with Python
- name: Build SDK Message with Python
if: ${{ github.event.inputs.notify_sdk == 'true' }}
run: |
python -u scripts/build_message_sdk.py "${{ github.event.inputs.release_version }}" > message.txt
- name: Send SDK notification to Mattermost
if: ${{ github.event.inputs.notify_sdk == 'true' }}
env:
MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
run: |
MESSAGE=$(cat message.txt)
curl -X POST -H 'Content-Type: application/json' \
--data "{\"text\": \"$MESSAGE\"}" \
$MATTERMOST_WEBHOOK_URL
- name: Build Boards/Cards Message with Python
if: ${{ github.event.inputs.notify_components == 'true' }}
run: |
python -u scripts/build_message.py > message.txt
- name: Send notification to Mattermost
- name: Send Boards/Cards notification to Mattermost
if: ${{ github.event.inputs.notify_components == 'true' }}
env:
MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
run: |
Expand Down
27 changes: 0 additions & 27 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,3 @@ jobs:

- name: Run Package Script
run: python -u scripts/package.py ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} ${{ github.event.release.tag_name }}

- name: Trigger database update in Core repo
run: |
# Set the required variables
repo_owner="MikroElektronika"
repo_name="core_packages"
event_type="trigger-workflow"
version="${{ github.event.release.tag_name }}"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.MIKROE_ACTIONS_KEY }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$repo_owner/$repo_name/dispatches \
-d "{\"event_type\": \"$event_type\", \"client_payload\": {\"version\": \"$version\", \"index\": \"Test\", \"unit\": false, \"integration\": true}}"
# Wait 30 seconds to give GIT time to merge everything
sleep 30s
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.MIKROE_ACTIONS_KEY }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$repo_owner/$repo_name/dispatches \
-d "{\"event_type\": \"$event_type\", \"client_payload\": {\"version\": \"$version\", \"index\": \"Live\", \"unit\": false, \"integration\": true}}"
12 changes: 12 additions & 0 deletions changelog/v2.11.3/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,24 @@
- [`v2.11.3`](#v2113)
- [Changes](#changes)
- [Fixes](#fixes)
- [Improvements](#improvements)
- [NEW HARDWARE](#new-hardware)

### Fixes

+ Fixed touch panel implementation and TSC2003 library to recognize touch on TSC2003 RESISTIVE Displays while using LVGL projects
+ Fixed TP_ROTATION value to be "180" for all 4" CAPACITIVE Mikromedia Boards with PIC32MZ so touch position can be detected correctly

### Improvements

+ Updated [CMakeLists.txt](../../bsp/board/CMakeLists.txt) to include MCU Cards headers differently
+ Headers are now included with new path with `MCU_NAME`

### NEW HARDWARE

> NOTE:
>> If any new hardware was added to current version, it will be listed here.
---

**[BACK TO MAIN FILE](../../changelog.md)**
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"display-name": "mikroSDK",
"description": "MikroSDK 2.0 is an embedded software development framework designed to simplify and accelerate application development on Mikroe hardware platform, specifically for Click Boards and other extension board drivers, on a broad range of microcontroller vendors and architectures. It includes peripheral libraries and drivers, middleware, board support, and application layer libraries among others.",
"icon": "images/icon-mikroSDK.png",
"manifest-version": "1.0.16"
"manifest-version": "1.0.17"
}
68 changes: 68 additions & 0 deletions scripts/build_message_sdk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
from datetime import datetime
from bs4 import BeautifulSoup
import os
import markdown
import argparse

# Set up argument parsing to accept the markdown file path
parser = argparse.ArgumentParser(description="Process a markdown file to generate formatted release notes.")
parser.add_argument('version', type=str, help='Path to the markdown file')
args = parser.parse_args()

markdown_file_path = os.path.join(os.getcwd(), 'changelog', args.version.replace('mikroSDK-', ''), 'changelog.md')

# Read the markdown content from the file path provided as a command-line argument
with open(markdown_file_path, 'r', encoding='utf-8') as file:
markdown_content = file.read()

# Convert markdown to HTML and parse it with BeautifulSoup
html_content = markdown.markdown(markdown_content)
soup = BeautifulSoup(html_content, 'html.parser')

# Function to extract sections dynamically based on headers, excluding unwanted sections
def extract_sections(soup):
sections = {}
current_section = None
for tag in soup.find_all(['h3', 'p', 'ul']):
if tag.name == 'h3':
current_section = tag.get_text(strip=True)
# Exclude the "NEW HARDWARE" section
if current_section.lower() == 'new hardware':
current_section = None
else:
sections[current_section] = []
elif current_section and tag.name in ['p', 'ul']:
# Join text contents with spaces to avoid missing spaces between elements
text_content = ' '.join(tag.stripped_strings)
sections[current_section].append(text_content)
return sections

# Extract sections from the parsed markdown, excluding specified sections
sections = extract_sections(soup)

# Format the extracted sections
formatted_sections = []
for section, content in sections.items():
formatted_sections.append(f"+ {section}")
for line in content:
formatted_sections.append(f" + {line}")

# Combine all formatted sections
formatted_message_content = "\n".join(formatted_sections)

# Get the current date and time
release_date = datetime.now().strftime("%a %b %d %H:%M:%S CEST %Y")

# Create the final formatted message
formatted_message = f"""
NECTO SDK Release for {release_date}:
Update notes:
{formatted_message_content}
> For more information on today's release, visit following [README](https://github.com/MikroElektronika/mikrosdk_v2/blob/master/changelog/v2.11.2/new_hw/2024-09-27.md)
"""

# Print the formatted message
print(formatted_message)
5 changes: 4 additions & 1 deletion scripts/update_board_changelog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from datetime import datetime
from packaging.version import Version

def write_output_to_file(file, content):
with open(file, 'w') as file_write:
Expand Down Expand Up @@ -27,4 +28,6 @@ def find_file(root_folder, filename):

write_output_to_file(os.path.join(os.getcwd(), 'sdk_tag.txt'), file_dir.split(os.path.sep)[-2][1:])
else:
write_output_to_file(os.path.join(os.getcwd(), 'sdk_tag.txt'), '0')
# Extract and sort versions, removing the 'v' prefix
latest_version = max(os.listdir(os.path.join(os.getcwd(), 'changelog')), key=lambda v: Version(v.lstrip('v'))).lstrip('v')
write_output_to_file(os.path.join(os.getcwd(), 'sdk_tag.txt'), latest_version)

0 comments on commit 91c6fa0

Please sign in to comment.