workflow: improve Gitea release process with additional environment variables and error handling
This commit is contained in:
		
							
								
								
									
										31
									
								
								.github/workflows/gitea-release.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										31
									
								
								.github/workflows/gitea-release.yml
									
									
									
									
										vendored
									
									
								
							@@ -75,6 +75,8 @@ jobs:
 | 
			
		||||
      env:
 | 
			
		||||
        GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
 | 
			
		||||
        GITEA_API_URL: ${{ secrets.GITEA_API_URL }}
 | 
			
		||||
        GITEA_REPO: ${{ secrets.GITEA_REPO }}
 | 
			
		||||
        GITEA_OWNER: ${{ secrets.GITEA_OWNER }}
 | 
			
		||||
      run: |
 | 
			
		||||
        VERSION=${{ steps.get_version.outputs.VERSION }}
 | 
			
		||||
        cd .pio/build/esp32dev
 | 
			
		||||
@@ -101,21 +103,38 @@ jobs:
 | 
			
		||||
          \"body\": \"${{ steps.changelog.outputs.CHANGES }}\"
 | 
			
		||||
        }"
 | 
			
		||||
 | 
			
		||||
        # Create release
 | 
			
		||||
        RESPONSE=$(curl -X POST \
 | 
			
		||||
        # Create release and capture HTTP status
 | 
			
		||||
        RESPONSE=$(curl -s -w "%{http_code}" -X POST \
 | 
			
		||||
          -H "Authorization: token ${GITEA_TOKEN}" \
 | 
			
		||||
          -H "Content-Type: application/json" \
 | 
			
		||||
          -d "$RELEASE_DATA" \
 | 
			
		||||
          "${GITEA_API_URL}/repos/owner/repo/releases")
 | 
			
		||||
          "${GITEA_API_URL}/api/v1/repos/${GITEA_OWNER}/${GITEA_REPO}/releases")
 | 
			
		||||
        
 | 
			
		||||
        HTTP_STATUS=${RESPONSE: -3}
 | 
			
		||||
        RESPONSE_BODY=${RESPONSE:0:-3}
 | 
			
		||||
 | 
			
		||||
        if [ "$HTTP_STATUS" != "201" ]; then
 | 
			
		||||
          echo "Fehler beim Erstellen des Releases: $RESPONSE_BODY"
 | 
			
		||||
          exit 1
 | 
			
		||||
        fi
 | 
			
		||||
 | 
			
		||||
        # Extract release ID from response
 | 
			
		||||
        RELEASE_ID=$(echo "$RESPONSE_BODY" | jq -r .id)
 | 
			
		||||
        
 | 
			
		||||
        # Upload assets
 | 
			
		||||
        RELEASE_ID=$(echo $RESPONSE | jq -r .id)
 | 
			
		||||
        for file in upgrade_filaman_firmware_v${VERSION}.bin upgrade_filaman_website_v${VERSION}.bin filaman_full_${VERSION}.bin; do
 | 
			
		||||
          if [ -f "$file" ]; then
 | 
			
		||||
            curl -X POST \
 | 
			
		||||
            echo "Uploading $file..."
 | 
			
		||||
            UPLOAD_RESPONSE=$(curl -s -w "%{http_code}" -X POST \
 | 
			
		||||
              -H "Authorization: token ${GITEA_TOKEN}" \
 | 
			
		||||
              -H "Content-Type: application/octet-stream" \
 | 
			
		||||
              --data-binary @"$file" \
 | 
			
		||||
              "${GITEA_API_URL}/repos/owner/repo/releases/${RELEASE_ID}/assets?name=${file}"
 | 
			
		||||
              "${GITEA_API_URL}/api/v1/repos/${GITEA_OWNER}/${GITEA_REPO}/releases/${RELEASE_ID}/assets?name=${file}")
 | 
			
		||||
            
 | 
			
		||||
            UPLOAD_STATUS=${UPLOAD_RESPONSE: -3}
 | 
			
		||||
            if [ "$UPLOAD_STATUS" != "201" ]; then
 | 
			
		||||
              echo "Fehler beim Upload von $file"
 | 
			
		||||
              exit 1
 | 
			
		||||
            fi
 | 
			
		||||
          fi
 | 
			
		||||
        done
 | 
			
		||||
		Reference in New Issue
	
	Block a user