From b918abc1b0c57ec24f43c3d43b25ef95c5591dad Mon Sep 17 00:00:00 2001 From: aptalca Date: Thu, 25 Mar 2021 22:56:25 -0400 Subject: [PATCH] check for yarn package versions --- .github/workflows/external_trigger.yml | 2 +- Dockerfile | 4 +-- Dockerfile.aarch64 | 4 +-- Dockerfile.armhf | 4 +-- Jenkinsfile | 34 +++++++++----------------- jenkins-vars.yml | 6 ++--- 6 files changed, 21 insertions(+), 33 deletions(-) diff --git a/.github/workflows/external_trigger.yml b/.github/workflows/external_trigger.yml index 4df1b66..8385449 100644 --- a/.github/workflows/external_trigger.yml +++ b/.github/workflows/external_trigger.yml @@ -18,7 +18,7 @@ jobs: fi echo "**** External trigger running off of master branch. To disable this trigger, set a Github secret named \"PAUSE_EXTERNAL_TRIGGER_CODE_SERVER_MASTER\". ****" echo "**** Retrieving external version ****" - EXT_RELEASE=$(curl -u "${{ secrets.CR_USER }}:${{ secrets.CR_PAT }}" -sX GET "https://api.github.com/repos/cdr/code-server/releases/latest" | jq -r '. | .tag_name') + EXT_RELEASE=$(curl -sX GET https://registry.yarnpkg.com/code-server | jq -r '."dist-tags".latest' | sed 's|^|v|') if [ -z "${EXT_RELEASE}" ] || [ "${EXT_RELEASE}" == "null" ]; then echo "**** Can't retrieve external version, exiting ****" FAILURE_REASON="Can't retrieve external version for code-server branch master" diff --git a/Dockerfile b/Dockerfile index bcc6f27..b3ac371 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,8 +40,8 @@ RUN \ yarn && \ echo "**** install code-server ****" && \ if [ -z ${CODE_RELEASE+x} ]; then \ - CODE_RELEASE=$(curl -sX GET "https://api.github.com/repos/cdr/code-server/releases/latest" \ - | awk '/tag_name/{print $4;exit}' FS='[""]'); \ + CODE_RELEASE=$(curl -sX GET https://registry.yarnpkg.com/code-server \ + | jq -r '."dist-tags".latest' | sed 's|^|v|'); \ fi && \ CODE_VERSION=$(echo "$CODE_RELEASE" | awk '{print substr($1,2); }') && \ yarn config set network-timeout 600000 -g && \ diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index cd4f211..9321fb6 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -40,8 +40,8 @@ RUN \ yarn && \ echo "**** install code-server ****" && \ if [ -z ${CODE_RELEASE+x} ]; then \ - CODE_RELEASE=$(curl -sX GET "https://api.github.com/repos/cdr/code-server/releases/latest" \ - | awk '/tag_name/{print $4;exit}' FS='[""]'); \ + CODE_RELEASE=$(curl -sX GET https://registry.yarnpkg.com/code-server \ + | jq -r '."dist-tags".latest' | sed 's|^|v|'); \ fi && \ CODE_VERSION=$(echo "$CODE_RELEASE" | awk '{print substr($1,2); }') && \ yarn config set network-timeout 600000 -g && \ diff --git a/Dockerfile.armhf b/Dockerfile.armhf index 5822ad0..d5ba348 100644 --- a/Dockerfile.armhf +++ b/Dockerfile.armhf @@ -40,8 +40,8 @@ RUN \ yarn && \ echo "**** install code-server ****" && \ if [ -z ${CODE_RELEASE+x} ]; then \ - CODE_RELEASE=$(curl -sX GET "https://api.github.com/repos/cdr/code-server/releases/latest" \ - | awk '/tag_name/{print $4;exit}' FS='[""]'); \ + CODE_RELEASE=$(curl -sX GET https://registry.yarnpkg.com/code-server \ + | jq -r '."dist-tags".latest' | sed 's|^|v|'); \ fi && \ CODE_VERSION=$(echo "$CODE_RELEASE" | awk '{print substr($1,2); }') && \ yarn config set network-timeout 600000 -g && \ diff --git a/Jenkinsfile b/Jenkinsfile index d3481f9..d3a827d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,9 +16,6 @@ pipeline { GITHUB_TOKEN=credentials('498b4638-2d02-4ce5-832d-8a57d01d97ab') GITLAB_TOKEN=credentials('b6f0f1dd-6952-4cf6-95d1-9c06380283f0') GITLAB_NAMESPACE=credentials('gitlab-namespace-id') - EXT_GIT_BRANCH = 'master' - EXT_USER = 'cdr' - EXT_REPO = 'code-server' CONTAINER_NAME = 'code-server' BUILD_VERSION_ARG = 'CODE_RELEASE' LS_USER = 'linuxserver' @@ -101,23 +98,16 @@ pipeline { /* ######################## External Release Tagging ######################## */ - // If this is a stable github release use the latest endpoint from github to determine the ext tag - stage("Set ENV github_stable"){ - steps{ - script{ - env.EXT_RELEASE = sh( - script: '''curl -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq -r '. | .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 - } - } + // If this is a custom command to determine version use that command + stage("Set tag custom bash"){ + steps{ + script{ + env.EXT_RELEASE = sh( + script: ''' curl -sX GET https://registry.yarnpkg.com/code-server | jq -r '."dist-tags".latest' | sed 's|^|v|' ''', + returnStdout: true).trim() + env.RELEASE_LINK = 'custom_command' + } + } } // Sanitize the release tag and strip illegal docker or github characters stage("Sanitize tag"){ @@ -746,11 +736,11 @@ pipeline { "tagger": {"name": "LinuxServer Jenkins","email": "jenkins@linuxserver.io","date": "'${GITHUB_DATE}'"}}' ''' echo "Pushing New release for Tag" sh '''#! /bin/bash - curl -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq '. |.body' | sed 's:^.\\(.*\\).$:\\1:' > releasebody.json + echo "Updating to ${EXT_RELEASE_CLEAN}" > releasebody.json echo '{"tag_name":"'${META_TAG}'",\ "target_commitish": "master",\ "name": "'${META_TAG}'",\ - "body": "**LinuxServer Changes:**\\n\\n'${LS_RELEASE_NOTES}'\\n**'${EXT_REPO}' Changes:**\\n\\n' > start + "body": "**LinuxServer Changes:**\\n\\n'${LS_RELEASE_NOTES}'\\n**Remote Changes:**\\n\\n' > start printf '","draft": false,"prerelease": false}' >> 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''' diff --git a/jenkins-vars.yml b/jenkins-vars.yml index 2e583cb..f05393f 100644 --- a/jenkins-vars.yml +++ b/jenkins-vars.yml @@ -2,14 +2,12 @@ # jenkins variables project_name: docker-code-server -external_type: github_stable +external_type: na +custom_version_command: "curl -sX GET https://registry.yarnpkg.com/code-server | jq -r '.\"dist-tags\".latest' | sed 's|^|v|'" release_type: stable release_tag: latest ls_branch: master repo_vars: - - EXT_GIT_BRANCH = 'master' - - EXT_USER = 'cdr' - - EXT_REPO = 'code-server' - CONTAINER_NAME = 'code-server' - BUILD_VERSION_ARG = 'CODE_RELEASE' - LS_USER = 'linuxserver'