diff --git a/update-project-version/action.yml b/update-project-version/action.yml index 65c900f..974f14b 100644 --- a/update-project-version/action.yml +++ b/update-project-version/action.yml @@ -48,22 +48,40 @@ runs: run: python ${{ github.action_path }}/update_version.py ${{ inputs.version-rule }} ${{ inputs.use-dev-suffix == 'true' && '--dev' || '' }} shell: bash working-directory: ${{ inputs.project-directory }} - - name: Get changed files - id: get-changed-files + - name: Get PR details + id: get-pr-details run: | - echo "changed-files<> "$GITHUB_OUTPUT" - # Prefix with "- " to generate a Markdown list. - git diff --name-only | awk '{ print "-", $0 }' >> "$GITHUB_OUTPUT" - echo "EOF" >> "$GITHUB_OUTPUT" - shell: bash + import pathlib, os, subprocess + changed_files = [pathlib.Path(file) for file in subprocess.run(["git", "diff", "--name-only"], capture_output=True, check=True, text=True).stdout.split()] + changed_projects = [file for file in changed_files if file.name == "pyproject.toml"] + project_info = {} + for project in changed_projects: + name, version = subprocess.run(["poetry", "version", "-C", str(project.parent)], capture_output=True, check=True, text=True).stdout.split() + project_info[project] = {"name": name, "version": version} + if len(changed_projects) == 1: + title = "chore: Update project {} to v{}".format(project_info[changed_projects[0]]["name"], project_info[changed_projects[0]]["version"]) + else: + title = "chore: Update project versions" + base_branch = "${{ steps.set-vars.outputs.base-branch }}" + if base_branch not in ["main", "master"]: + title = f"[{base_branch}] {title}" + with open(os.environ["GITHUB_OUTPUT"], "a") as output: + print(f"title={title}", file=output) + print("project-table<