diff --git a/.github/workflows/sdkAutomation.yaml b/.github/workflows/sdkAutomation.yaml index 1a0f0e009..248539a28 100644 --- a/.github/workflows/sdkAutomation.yaml +++ b/.github/workflows/sdkAutomation.yaml @@ -86,26 +86,33 @@ jobs: # Create a new branch - name: Create branch + env: + RELEASES_SPREADSHEET: ${{ secrets.RELEASES_SPREADSHEET }} run: | - git fetch --all - if [[ `git branch -a | grep "new-feature/automation"` ]]; then - highest=$(git branch -a | grep "new-feature/automation" | grep -E -o '[0-9]+' | sort -n | tail -1) - if ${{ github.event.inputs.new_branch }} == true; then - number=$((highest+1)) + branch_name = $(python scripts/release_calendar.py "NECTO DAILY UPDATE" $RELEASES_SPREADSHEET) + + if $branch_name == "new_branch"; then + git fetch --all + if [[ `git branch -a | grep "new-feature/automation"` ]]; then + highest=$(git branch -a | grep "new-feature/automation" | grep -E -o '[0-9]+' | sort -n | tail -1) + if ${{ github.event.inputs.new_branch }} == true; then + number=$((highest+1)) + else + number=$((highest)) + fi else - number=$((highest)) + number=1 fi - else - number=1 + branch_name = "new-feature/automation/$number" fi - echo "Found number: $number" + echo "Found number: $branch_name" if ${{ github.event.inputs.new_branch }} == true; then - git branch "new-feature/automation/$number" - git checkout "new-feature/automation/$number" - git push -u origin "new-feature/automation/$number" + git branch $branch_name + git checkout $branch_name + git push -u origin $branch_name else - git checkout "new-feature/automation/$number" + git checkout $branch_name git reset --hard $(git rev-list --max-parents=1 ) fi @@ -208,16 +215,16 @@ jobs: GH_TOKEN: ${{ secrets.MIKROE_ACTIONS_KEY }} # Move the asset we just downloaded to automatization and extract it - - name: Move to the created directory unzip and distribute files + - name: Move to the created directory unzip and distribute files run: | sudo mv generated_files.zip automatization/ cd automatization unzip generated_files.zip - + mkdir -p ../${{ github.event.inputs.architecture }}/gcc_clang/def/${{ github.event.inputs.vendor }}/${{ github.event.inputs.mcu_name }} mkdir -p ../${{ github.event.inputs.architecture }}/gcc_clang/interrupts/include/interrupts_mcu/${{ github.event.inputs.mcu_name }} mkdir -p ../${{ github.event.inputs.architecture }}/gcc_clang/system/src/${{ github.event.inputs.vendor }}/doc_ds_1 - + sudo mv 'mcu.h' ../${{ github.event.inputs.architecture }}/gcc_clang/def/${{ github.event.inputs.vendor }}/${{ github.event.inputs.mcu_name }}/ sudo mv "$(find . -maxdepth 1 -name '*.json' | head -n 1)" ../${{ github.event.inputs.architecture }}/gcc_clang/def/ sudo mv 'interrupts_mcu.h' ../${{ github.event.inputs.architecture }}/gcc_clang/interrupts/include/interrupts_mcu/${{ github.event.inputs.mcu_name }}/ diff --git a/scripts/release_calendar.py b/scripts/release_calendar.py new file mode 100644 index 000000000..19eb7cceb --- /dev/null +++ b/scripts/release_calendar.py @@ -0,0 +1,143 @@ +import os, argparse, json, urllib.request + +from datetime import datetime + +def get_data(link, calendar_title, saveToFile=None): + """ + Fetches data from the provided link, processes the release information, and merges events with the same start date. + :param link: URL to fetch the CSV data. + :param saveToFile: Optional; path to save the processed JSON data. + :return: A list of merged events based on their start date. + """ + try: + ## Fetch the data from the provided link + with urllib.request.urlopen(link) as f: + html = f.read().decode('utf-8') + ## Save fetched data temporarily to a file named 'releases.txt' + with open(os.path.join(os.path.dirname(__file__), 'releases.txt'), 'w') as releases: + releases.write(html) + releases.close() + except Exception as e: + ## Handle errors that may occur during the data fetch process + print(f"Error fetching data: {e}") + ## Read lines from the temporary file + with open(os.path.join(os.path.dirname(__file__), 'releases.txt'), 'r') as releases: + all_releases = releases.readlines() + releases.close() + ## Remove the temporary file after reading its content + if os.path.exists(os.path.join(os.path.dirname(__file__), "releases.txt")): + os.remove(os.path.join(os.path.dirname(__file__), "releases.txt")) + ## List to store formatted event data + formatted_array = [] + for each_line in all_releases: + ## Split the line into individual parts based on commas + parts = each_line.split(',') + ## Skip empty lines or headers + if parts[0] == '' or parts[0] == 'Product name' or parts[0] == '\n': + continue + ## Extract the board name and release plan date + board_name = parts[0] + try: + ## Parse the release date from the format 'dd.mm.yyyy' + release_date = datetime.strptime(parts[3], "%d.%m.%Y") + except ValueError: + ## Skip lines with incorrect date format + continue + ## Create a dictionary for each event and append to the formatted array + formatted_array.append( + { + "notes": f"