From 6b07412d37833506479619f5000da35084c99611 Mon Sep 17 00:00:00 2001 From: Christian Beilschmidt Date: Mon, 27 Nov 2023 16:30:46 +0100 Subject: [PATCH] PR generator for new backend tags --- .generation/update_config.py | 33 ++++++++++++++++++++++++++++++++ .github/workflows/create-pr.yml | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100755 .generation/update_config.py create mode 100644 .github/workflows/create-pr.yml diff --git a/.generation/update_config.py b/.generation/update_config.py new file mode 100755 index 0000000..c92d1d5 --- /dev/null +++ b/.generation/update_config.py @@ -0,0 +1,33 @@ +#!/bin/python3 + +''' +1. Set a new container tag +2. Increment the version number +''' + +import argparse +import configparser +from pathlib import Path + +CWD = Path('.generation/') +INI_FILE = CWD / 'config.ini' + +parser = argparse.ArgumentParser(description='Update the config.ini file.') +parser.add_argument('--backendTag', dest='backend_tag', required=True, type=str, nargs=1,) + +args = parser.parse_args() + +config = configparser.ConfigParser() +config.read(INI_FILE) + +config['input']['backendTag'] = args.backend_tag[0] + +# retrieve version +version_digits: list[int] = [int(digit) for digit in config['package']['version'].split('.')] +# increment last version digit +version_digits[-1] += 1 +# write back +config['package']['version'] = '.'.join(str(digit) for digit in version_digits) + +with open(INI_FILE, 'w', encoding='utf-8') as f: + config.write(f) diff --git a/.github/workflows/create-pr.yml b/.github/workflows/create-pr.yml new file mode 100644 index 0000000..9c6cdb8 --- /dev/null +++ b/.github/workflows/create-pr.yml @@ -0,0 +1,34 @@ +# Update the generation and create a new PR + +name: Generate and PR + +on: + # schedule manually + workflow_dispatch: + inputs: + # On workflow dispatch, `branch` is selected by default + # You can access it in `github.ref_name` + + backend_tag: + description: "Tag name for the container" + required: true + default: "pro-nightly-2023-11-14" + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Update config.ini + run: .generation/update_config.py --backendTag ${{ github.event.inputs.backend_tag }} + + - name: Generate Code + run: .generation/generate.py + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + title: "Code for backend tag ${{ github.event.inputs.backend_tag }}" + commit-message: "Code for backend tag ${{ github.event.inputs.backend_tag }}"