diff --git a/.github/workflows/automatic-release.yaml b/.github/workflows/automatic-release.yaml index d048d23dd0..3ae445c2b5 100644 --- a/.github/workflows/automatic-release.yaml +++ b/.github/workflows/automatic-release.yaml @@ -65,9 +65,10 @@ jobs: needs: create-releases steps: - uses: actions/checkout@v3 - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v4 with: python-version: '3.9' + cache: pip - name: Install dependencies run: | python -m pip install --upgrade pip @@ -75,7 +76,13 @@ jobs: - name: Generate release notes id: release-notes run: | - - echo "body=$(make release-notes MLRUN_OLD_VERSION=v${{ github.event.inputs.previous_version }} MLRUN_NEW_VERSION=v${{ github.event.inputs.version }} MLRUN_RELEASE_BRANCH=${{ github.ref_name }} MLRUN_RAISE_ON_ERROR=false MLRUN_RELEASE_NOTES_OUTPUT_PATH=release_notes.md || cat release_notes.md)" >> $GITHUB_OUTPUT + make release-notes MLRUN_OLD_VERSION=v${{ github.event.inputs.previous_version }} MLRUN_VERSION=v${{ github.event.inputs.version }} MLRUN_RELEASE_BRANCH=${{ github.ref_name }} MLRUN_RAISE_ON_ERROR=false MLRUN_RELEASE_NOTES_OUTPUT_FILE=release_notes.md MLRUN_SKIP_CLONE=true + - name: resolve release notes + id: resolve-release-notes + run: | + echo "body<> $GITHUB_OUTPUT + cat release_notes.md >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT - uses: ncipollo/release-action@v1 with: tag: v${{ github.event.inputs.version }} @@ -83,4 +90,4 @@ jobs: token: ${{ secrets.RELEASE_GITHUB_ACCESS_TOKEN }} allowUpdates: true prerelease: ${{ github.event.inputs.pre_release }} - body: ${{ steps.release-notes.outputs.body }} + body: ${{ steps.resolve-release-notes.outputs.body }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d60a594cb6..864bd6ea12 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -127,7 +127,7 @@ jobs: - name: Generate release notes id: release-notes run: | - - echo "body=$(make release-notes MLRUN_OLD_VERSION=v${{ github.event.inputs.previous_version }} MLRUN_NEW_VERSION=v${{ github.event.inputs.version }} MLRUN_RELEASE_BRANCH=${{ github.ref_name }} MLRUN_RAISE_ON_ERROR=false MLRUN_RELEASE_NOTES_OUTPUT_PATH=release_notes.md || cat release_notes.md)" >> $GITHUB_OUTPUT + - echo "body=$(make release-notes MLRUN_OLD_VERSION=v${{ github.event.inputs.previous_version }} MLRUN_NEW_VERSION=v${{ github.event.inputs.version }} MLRUN_RELEASE_BRANCH=${{ github.ref_name }} MLRUN_RAISE_ON_ERROR=false MLRUN_RELEASE_NOTES_OUTPUT_FILE=release_notes.md || cat release_notes.md)" >> $GITHUB_OUTPUT - uses: ncipollo/release-action@v1 with: tag: v${{ github.event.inputs.version }} diff --git a/Makefile b/Makefile index c730702769..5b81289fed 100644 --- a/Makefile +++ b/Makefile @@ -56,6 +56,7 @@ MLRUN_PUSH_DOCKER_CACHE_IMAGE ?= MLRUN_GIT_ORG ?= mlrun MLRUN_RELEASE_BRANCH ?= master MLRUN_RAISE_ON_ERROR ?= true +MLRUN_SKIP_CLONE ?= false MLRUN_RELEASE_NOTES_OUTPUT_FILE ?= MLRUN_SYSTEM_TESTS_CLEAN_RESOURCES ?= true MLRUN_CUDA_VERSION = 11.7.0 @@ -661,7 +662,7 @@ endif ifndef MLRUN_RELEASE_BRANCH $(error MLRUN_RELEASE_BRANCH is undefined) endif - python ./automation/release_notes/generate.py run $(MLRUN_VERSION) $(MLRUN_OLD_VERSION) $(MLRUN_RELEASE_BRANCH) $(MLRUN_RAISE_ON_ERROR) $(MLRUN_RELEASE_NOTES_OUTPUT_FILE) + python ./automation/release_notes/generate.py run $(MLRUN_VERSION) $(MLRUN_OLD_VERSION) $(MLRUN_RELEASE_BRANCH) $(MLRUN_RAISE_ON_ERROR) $(MLRUN_RELEASE_NOTES_OUTPUT_FILE) $(MLRUN_SKIP_CLONE) .PHONY: pull-cache diff --git a/automation/release_notes/generate.py b/automation/release_notes/generate.py index cbe6af9863..7f68f43f2b 100644 --- a/automation/release_notes/generate.py +++ b/automation/release_notes/generate.py @@ -49,13 +49,15 @@ def __init__( release_branch: str, raise_on_failed_parsing: bool = True, tmp_file_path: str = None, + skip_clone: bool = False, ): self._logger = logger self._release = release self._previous_release = previous_release self._release_branch = release_branch self._raise_on_failed_parsing = raise_on_failed_parsing - self.tmp_file_path = tmp_file_path + self._tmp_file_path = tmp_file_path + self._skip_clone = skip_clone # adding a map with the common contributors to prevent going to github API on every commit (better performance, # and prevent rate limiting) self._git_to_github_usernames_map = { @@ -86,17 +88,24 @@ def run(self): with tempfile.TemporaryDirectory( suffix="mlrun-release-notes-clone" ) as repo_dir: - self._logger.info("Cloning repo", repo_dir=repo_dir) - self._run_command( - "git", - args=[ - "clone", - "--branch", - self._release_branch, - "git@github.com:mlrun/mlrun.git", - repo_dir, - ], - ) + current_working_dir = repo_dir + if self._skip_clone: + current_working_dir = None + self._logger.info( + "Skipping cloning repo, assuming already cloned, using current working dir" + ) + else: + self._logger.info("Cloning repo", repo_dir=current_working_dir) + self._run_command( + "git", + args=[ + "clone", + "--branch", + self._release_branch, + "git@github.com:mlrun/mlrun.git", + current_working_dir, + ], + ) commits_for_highlights = self._run_command( "git", @@ -105,7 +114,7 @@ def run(self): '--pretty=format:"%h {%an} %s"', f"{self._previous_release}..{self._release}", ], - cwd=repo_dir, + cwd=current_working_dir, ) commits_for_pull_requests = self._run_command( @@ -115,7 +124,7 @@ def run(self): '--pretty=format:"%h %s"', f"{self._previous_release}..{self._release}", ], - cwd=repo_dir, + cwd=current_working_dir, ) self._generate_release_notes_from_commits( @@ -168,9 +177,9 @@ def _generate_release_notes_from_commits( def output_release_notes(self, release_notes: str): print(release_notes) - if self.tmp_file_path: - logger.info("Writing release notes to file", path=self.tmp_file_path) - with open(self.tmp_file_path, "w") as f: + if self._tmp_file_path: + logger.info("Writing release notes to file", path=self._tmp_file_path) + with open(self._tmp_file_path, "w") as f: f.write(release_notes) def _generate_highlight_notes_from_commits(self, commits: str): @@ -263,12 +272,14 @@ def main(): @click.argument("release-branch", type=str, required=False, default="master") @click.argument("raise-on-failed-parsing", type=bool, required=False, default=True) @click.argument("tmp-file-path", type=str, required=False, default=None) +@click.argument("skip-clone", type=bool, required=False, default=True) def run( release: str, previous_release: str, release_branch: str, raise_on_failed_parsing: bool, - tmp_file_path: str = None, + tmp_file_path: str, + skip_clone: bool, ): release_notes_generator = ReleaseNotesGenerator( release, @@ -276,6 +287,7 @@ def run( release_branch, raise_on_failed_parsing, tmp_file_path, + skip_clone, ) try: release_notes_generator.run()