-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(ci): addresses issue about archiving in releases the APK (cycle 4.4) #2473
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
581f612
chore: cleanup code curl to release
yamilmedina d2f87ae
chore: cleanup code curl to release
yamilmedina cd7624c
chore: cleanup code curl to release
yamilmedina 8440d66
chore: parser
yamilmedina 20339f0
chore: parser
yamilmedina 29aeb59
chore: parser
yamilmedina 962b691
chore: parser and curl fixedx
yamilmedina b21cb6a
chore: parser and curl fixedx
yamilmedina 4aaee0a
chore: parser and curl fixed
yamilmedina dad3592
chore: parser and curl fixed
yamilmedina a5dc0d8
chore: parser and curl fixed
yamilmedina 43d8f7d
chore: sanitized name and more logs
yamilmedina 815c378
chore: cleanup
yamilmedina c68d163
chore: cleanup, and test
yamilmedina 97bf17b
chore: cleanup, revert forcing to run in code
yamilmedina d28add7
chore: cleanup, revert forcing to run in code
yamilmedina df36a15
chore: cleanup
yamilmedina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,11 @@ String shellQuote(String s) { | |
return "'" + s.replaceAll("'", "'\"'\"'") + "'" | ||
} | ||
|
||
String shellParentheses(String s) { | ||
// Parenthesize a string so it's suitable to pass to the shell | ||
return s.replaceAll("\\(", "\\\\(").replaceAll("\\)", "\\\\)") | ||
} | ||
|
||
def postGithubComment(String changeId, String body) { | ||
def authHeader = shellQuote("Authorization: token ${env.GITHUB_API_TOKEN}") | ||
def apiUrl = shellQuote("https://api.github.com/repos/wireapp/wire-android-reloaded/issues/${changeId}/comments") | ||
|
@@ -42,6 +47,33 @@ def postGithubComment(String changeId, String body) { | |
|
||
} | ||
|
||
def postGithubApkToRelease(String flavor, String buildType) { | ||
def apks = findFiles(glob: "app/build/outputs/apk/${flavor.toLowerCase()}/${buildType.toLowerCase()}/com.wire.android-*.apk") | ||
if (apks.size() > 0) { | ||
echo 'Attaching APK to Github Release for tag: ' + env.SOURCE_BRANCH | ||
def fileApk = apks[0] | ||
// note: apk name value rename to comply with github releases assets names requirements | ||
// https://docs.github.com/en/rest/releases/assets?apiVersion=2022-11-28#upload-a-release-asset | ||
def filename = fileApk.getName().replaceAll("\\(", "_").replaceAll("\\)", "_") | ||
|
||
// building headers request | ||
def acceptHeader = shellQuote("Accept: application/vnd.github.v3+json") | ||
def contentTypeHeader = shellQuote("Content-Type: application/octet-stream") | ||
def authHeader = shellQuote("Authorization: token ${env.GITHUB_API_TOKEN}") | ||
|
||
// building gh api request | ||
def apiUrl = shellQuote("https://api.github.com/repos/wireapp/wire-android/releases/latest") | ||
def releaseId = sh(script: "curl -s ${apiUrl} | grep -m 1 \"id.:\" | grep -w id | tr : = | tr -cd '[[:alnum:]]=' | cut -d'=' -f2", returnStdout: true).trim() | ||
def sanitizedUploadUrl = "https://uploads.github.com/repos/wireapp/wire-android/releases/${releaseId}/assets?name=\$(basename '${filename}')" | ||
def sanitizedApkPath = shellParentheses(fileApk.getPath()) | ||
echo 'Starting! Upload of APK: ' + sanitizedApkPath + ' to Github Release destination: ' + sanitizedUploadUrl | ||
|
||
sh "curl -s -H ${authHeader} -H ${acceptHeader} -H ${contentTypeHeader} -X POST -T ${sanitizedApkPath} ${sanitizedUploadUrl}" | ||
} else { | ||
echo 'No APK found to attach to Github Release for tag: ' + env.SOURCE_BRANCH | ||
} | ||
} | ||
|
||
def defineTrackName(String branchName) { | ||
def overwrite = env.CUSTOM_TRACK | ||
|
||
|
@@ -527,9 +559,12 @@ pipeline { | |
|
||
postGithubComment(params.GITHUB_CHANGE_ID, payload) | ||
} | ||
|
||
if (env.SOURCE_BRANCH ==~ /v[0-9]+.[0-9]+.[0-9A-Za-z-+]+/) { | ||
postGithubApkToRelease(params.FLAVOR, params.BUILD_TYPE) | ||
} | ||
} | ||
|
||
sh './gradlew jacocoReport' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not needed at all in Jenkins. Confirmed with QA. |
||
wireSend(secret: env.WIRE_BOT_SECRET, message: "**[#${BUILD_NUMBER} Link](${BUILD_URL})** [${SOURCE_BRANCH}] - ✅ SUCCESS 🎉" + "\nLast 5 commits:\n```text\n$lastCommits\n```") | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In an ideal world, this can be simplified if
./jq
would be available.But
grep
,tr
andcut
can also manage to do it.