From 06a3895a02ea24602276181664c3db1a7d1827ae Mon Sep 17 00:00:00 2001 From: Mathias Preiner Date: Wed, 23 Mar 2022 11:26:15 -0700 Subject: [PATCH] Only update latest tag if commit changed. (#8379) Previously the latest tag was always updated when a new binary was added to a release (i.e. 3 updates per commit). This commit ensures that we only update the tag if the commit sha changed. --- .github/actions/store-binary/action.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/actions/store-binary/action.yml b/.github/actions/store-binary/action.yml index bd18093c4..00986aec3 100644 --- a/.github/actions/store-binary/action.yml +++ b/.github/actions/store-binary/action.yml @@ -35,10 +35,12 @@ runs: gh = Github(os.getenv('GITHUB_TOKEN')) repo = gh.get_repo(os.getenv('GITHUB_REPOSITORY')) - + try: - # update "latest" to current commit - repo.get_git_ref('tags/latest').edit(sha) + ref = repo.get_git_ref('tags/latest') + # update "latest" to current commit if sha changed + if ref.object.sha != sha: + ref.edit(sha) except: print('tag `latest` does not exist.') exit @@ -74,7 +76,7 @@ runs: # upload as asset with proper name rel.upload_asset(binary, name=filename) - + - name: store to release if: startsWith(github.ref, 'refs/tags/') shell: 'python3 {0}' -- 2.30.2