Only update latest tag if commit changed. (#8379)
authorMathias Preiner <mathias.preiner@gmail.com>
Wed, 23 Mar 2022 18:26:15 +0000 (11:26 -0700)
committerGitHub <noreply@github.com>
Wed, 23 Mar 2022 18:26:15 +0000 (11:26 -0700)
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

index bd18093c4e181c3e7ec29824e53f57d28fbfa444..00986aec393e62dc664a26fa889ed772b465e790 100644 (file)
@@ -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}'