Skip to content

Commit

Permalink
Update release check
Browse files Browse the repository at this point in the history
  • Loading branch information
thespad committed Jul 8, 2024
1 parent 270ae4e commit e78aa4b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/external_trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
echo "**** External trigger running off of development branch. To disable this trigger, set a Github secret named \"PAUSE_EXTERNAL_TRIGGER_OMBI_DEVELOPMENT\". ****"
echo "External trigger running off of development branch. To disable this trigger, set a Github secret named \`PAUSE_EXTERNAL_TRIGGER_OMBI_DEVELOPMENT\`" >> $GITHUB_STEP_SUMMARY
echo "**** Retrieving external version ****"
EXT_RELEASE=$(curl -u "${{ secrets.CR_USER }}:${{ secrets.CR_PAT }}" -sX GET "https://api.github.com/repos/Ombi-app/ombi/releases" | jq -r '. | first(.[] | select(.prerelease == true)) | .tag_name')
EXT_RELEASE=$(curl -u "${{ secrets.CR_USER }}:${{ secrets.CR_PAT }}" -sX GET "https://api.github.com/repos/Ombi-app/Ombi/releases" | jq -r '.[0] | .tag_name')
if [ -z "${EXT_RELEASE}" ] || [ "${EXT_RELEASE}" == "null" ]; then
echo "**** Can't retrieve external version, exiting ****"
FAILURE_REASON="Can't retrieve external version for ombi branch development"
Expand Down
35 changes: 21 additions & 14 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ pipeline {
GITLAB_TOKEN=credentials('b6f0f1dd-6952-4cf6-95d1-9c06380283f0')
GITLAB_NAMESPACE=credentials('gitlab-namespace-id')
DOCKERHUB_TOKEN=credentials('docker-hub-ci-pat')
JSON_URL = 'https://api.github.com/repos/Ombi-app/ombi/releases'
JSON_PATH = 'first(.[] | select(.prerelease == true)) | .tag_name'
EXT_USER = 'Ombi-app'
EXT_REPO = 'Ombi'
CONTAINER_NAME = 'ombi'
BUILD_VERSION_ARG = 'OMBI_RELEASE'
LS_USER = 'linuxserver'
Expand Down Expand Up @@ -113,16 +113,23 @@ pipeline {
/* ########################
External Release Tagging
######################## */
// If this is a custom json endpoint parse the return to get external tag
stage("Set ENV custom_json"){
steps{
script{
env.EXT_RELEASE = sh(
script: '''curl -s ${JSON_URL} | jq -r ". | ${JSON_PATH}" ''',
returnStdout: true).trim()
env.RELEASE_LINK = env.JSON_URL
}
}
// If this is a devel github release use the first in an array from github to determine the ext tag
stage("Set ENV github_devel"){
steps{
script{
env.EXT_RELEASE = sh(
script: '''curl -H "Authorization: token ${GITHUB_TOKEN}" -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases | jq -r '.[0] | .tag_name' ''',
returnStdout: true).trim()
}
}
}
// If this is a stable or devel github release generate the link for the build message
stage("Set ENV github_link"){
steps{
script{
env.RELEASE_LINK = 'https://github.com/' + env.EXT_USER + '/' + env.EXT_REPO + '/releases/tag/' + env.EXT_RELEASE
}
}
}
// Sanitize the release tag and strip illegal docker or github characters
stage("Sanitize tag"){
Expand Down Expand Up @@ -855,11 +862,11 @@ pipeline {
"tagger": {"name": "LinuxServer Jenkins","email": "jenkins@linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
echo "Pushing New release for Tag"
sh '''#! /bin/bash
echo "Data change at JSON endpoint ${JSON_URL}" > releasebody.json
curl -H "Authorization: token ${GITHUB_TOKEN}" -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases | jq '.[0] |.body' | sed 's:^.\\(.*\\).$:\\1:' > releasebody.json
echo '{"tag_name":"'${META_TAG}'",\
"target_commitish": "development",\
"name": "'${META_TAG}'",\
"body": "**LinuxServer Changes:**\\n\\n'${LS_RELEASE_NOTES}'\\n\\n**Remote Changes:**\\n\\n' > start
"body": "**LinuxServer Changes:**\\n\\n'${LS_RELEASE_NOTES}'\\n\\n**'${EXT_REPO}' Changes:**\\n\\n' > start
printf '","draft": false,"prerelease": true}' >> releasebody.json
paste -d'\\0' start releasebody.json > releasebody.json.done
curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/releases -d @releasebody.json.done'''
Expand Down
7 changes: 3 additions & 4 deletions jenkins-vars.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
# jenkins variables
project_name: docker-ombi
external_type: custom_json
external_type: github_devel
release_type: prerelease
release_tag: development
ls_branch: development
repo_vars:
- JSON_URL = 'https://api.github.com/repos/Ombi-app/ombi/releases'
- JSON_PATH = 'first(.[] | select(.prerelease == true)) | .tag_name'
- EXT_USER = 'Ombi-app'
- EXT_REPO = 'Ombi'
- CONTAINER_NAME = 'ombi'
- BUILD_VERSION_ARG = 'OMBI_RELEASE'
- LS_USER = 'linuxserver'
Expand All @@ -16,7 +16,6 @@ repo_vars:
- DEV_DOCKERHUB_IMAGE = 'lsiodev/ombi'
- PR_DOCKERHUB_IMAGE = 'lspipepr/ombi'
- DIST_IMAGE = 'ubuntu'
- DIST_TAG = 'bionic'
- MULTIARCH='true'
- CI='true'
- CI_WEB='true'
Expand Down

0 comments on commit e78aa4b

Please sign in to comment.