Jelajahi Sumber

feat: Update git tag creation process in firmware build workflow

This commit enhances the git tag creation process in the firmware build workflow. The actions now include generating a new release version number based on the previous one, storing the previous tag name, and updating the release notes generation accordingly. This improvement contributes to a more efficient and error-free tag management.
DerSkythe 2 tahun lalu
induk
melakukan
e804bde2d0
1 mengubah file dengan 14 tambahan dan 7 penghapusan
  1. 14 7
      .github/workflows/build-with-firmwware.yml

+ 14 - 7
.github/workflows/build-with-firmwware.yml

@@ -29,7 +29,7 @@ jobs:
       REPO_SELF: ${{ vars.REPO_SELF }}
       APP_PATH: "applications_user/subbrute"
       RELATIVE_PATH: "applications/external/subbrute"
-      RELEASE_VERSION: ""
+      PREV_TAG: ""
       APP_NAME: ""
       ZIP_NAME: ""
       ZIP_TAG: ""
@@ -37,6 +37,7 @@ jobs:
       TGZ_TAG: ""
       SHA: ""
       FW_VERSION: ""
+      RELEASE_VERSION: ""
     strategy:
       fail-fast: false
       matrix:
@@ -100,30 +101,35 @@ jobs:
           $sha = (git rev-parse --verify HEAD)
           
           $releaseVersion = ''
+          $latestTag = ((gh release view --json tagName,url -R ${{ vars.REPO_SELF }}) | ConvertFrom-Json ).tagName
 
-          if ( [string]::IsNullOrWhitespace($env:INPUT_VERSION) ) {
-            $latestTag = ((gh release view --json tagName,url -R ${{ vars.REPO_SELF }}) | ConvertFrom-Json ).tagName
+          if ( [string]::IsNullOrWhitespace($env:INPUT_VERSION) ) {            
             Write-Output "::notice title=Latest tag::$latestTag"
             
             $lastIndex = $latestTag.LastIndexOf('.')
             
             $minorValue = $latestTag.Substring($latestTag.LastIndexOf('.') + 1)
             $minorValue = [Convert]::ToInt32($minorValue) + 1
-            $latestTag = $latestTag.Substring(0, $lastIndex)
+            $newTag = $latestTag.Substring(0, $lastIndex)
             
-            $releaseVersion = ('{0}.{1}' -f $latestTag, $minorValue)
+            $releaseVersion = ('{0}.{1}' -f $newTag, $minorValue)
           } else {
             $releaseVersion = "$env:INPUT_VERSION"
           }
           
-          Write-Output "::notice title=Obtain Version Number::$releaseVersion"
           if ( $releaseVersion.StartsWith('v') ) {
             $releaseVersion = $releaseVersion.Substring(1)
           }
           
+          Write-Output "::notice title=RELEASE_VERSION::$releaseVersion"
+          Write-Output "::notice title=SHA::$sha"
+          Write-Output "::notice title=FW_VERSION::$fwInfo.tagName"
+          Write-Output "::notice title=PREV_TAG::$latestTag"
+          
           Write-Output ('RELEASE_VERSION={0}' -f $releaseVersion) >> $env:GITHUB_ENV
           Write-Output ('SHA={0}' -f $sha) >> $env:GITHUB_ENV
           Write-Output ('FW_VERSION={0}' -f $fwInfo.tagName) >> $env:GITHUB_ENV
+          Write-Output ('PREV_TAG={0}' -f $latestTag) >> $env:GITHUB_ENV
 
       - name: Build Firmware
         shell: bash
@@ -229,7 +235,8 @@ jobs:
           $json = (gh api -H $mime -H $api /repos/${{ github.REPOSITORY }}/releases) | ConvertFrom-Json
           $tagExists = ($json.GetEnumerator() | Where-Object { $_.tag_name -eq 'v${{ env.RELEASE_VERSION }}' }) -ne $null
           if ( $tagExists -eq $false ) {
-            gh api --method POST -H $mime -H $api /repos/${{ github.REPOSITORY }}/releases -f tag_name='v${{ env.RELEASE_VERSION }}' -f target_commitish='${{ env.SHA }}' -f name='v${{ env.RELEASE_VERSION }}' -F draft=true -F prerelease=false -F generate_release_notes=true  
+            gh api --method POST -H $mime -H $api /repos/${{ github.REPOSITORY }}/releases -f tag_name='v${{ env.RELEASE_VERSION }}' -f target_commitish='${{ env.SHA }}' -f name='v${{ env.RELEASE_VERSION }}' -F draft=true -F prerelease=false -F generate_release_notes=false  
+            gh api --method POST -H $mime -H $api /repos/${{ github.REPOSITORY }}/releases/generate-notes -f tag_name='v${{ env.RELEASE_VERSION }}' -f target_commitish='${{ env.SHA }}' -f previous_tag_name='${{ env.PREV_TAG }}'
           }          
           gh release upload 'v${{ env.RELEASE_VERSION }}' '${{ env.ZIP_NAME }}#${{ env.ZIP_TAG }}' '${{ env.TGZ_NAME }}#${{ env.TGZ_TAG }}' --clobber -R ${{ env.REPO_SELF }}
           gh release edit 'v${{ env.RELEASE_VERSION }}' --draft=false -R ${{ env.REPO_SELF }}