Skip to content

Commit

Permalink
Update Jenkinsfile
Browse files Browse the repository at this point in the history
  • Loading branch information
michelu89 committed Feb 5, 2024
1 parent 5459ebb commit a2b23c5
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions .jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,40 @@ pipeline {
def tagName = "v5.2.1"
def fileName = "signed.exe"

sh """
curl -L \\
-H "Accept: application/vnd.github+json" \\
-H "Authorization: Bearer <YOUR-TOKEN>" \\
-H "X-GitHub-Api-Version: 2022-11-28" \\
https://api.github.com/repos/${repo}/releases/tags/${tagName}
"""
def releaseId = sh(script: """
curl -s -L \\
-H "Accept: application/vnd.github+json" \\
-H "Authorization: Bearer \$GITHUB_TOKEN" \\
https://api.github.com/repos/${repo}/releases/tags/${tagName} | jq -r '.id'
""", returnStdout: true).trim()

sh """
def asset = sh(script: """
curl -s -H "Authorization: Bearer \$GITHUB_TOKEN" \\
-H "Accept: application/vnd.github+json" \\
https://api.github.com/repos/${repo}/releases/${releaseId}/assets | jq -c '.[] | select(.name | endswith(".exe"))'
""", returnStdout: true).trim()

if (asset) {
sh """
curl -L \
-X PATCH \
-H "Accept: application/vnd.github+json" \\
-H "Authorization: Bearer \$GITHUB_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @${fileName} \
"https://uploads.github.com/repos/${repo}/releases/${releaseId}/assets?name=${fileName}"
"""
} else {
sh """
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \\
-H "Authorization: Bearer \$GITHUB_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @${fileName} \
"https://uploads.github.com/repos/${repo}/releases/${releaseId}/assets?name=${fileName}"
"""
"""
}
}
}
}
Expand Down

0 comments on commit a2b23c5

Please sign in to comment.