From c0f4e91d743371c839771ed8b9a8a0b6cae8d090 Mon Sep 17 00:00:00 2001 From: aptalca <541623+aptalca@users.noreply.github.com> Date: Mon, 19 May 2025 11:25:02 -0400 Subject: [PATCH] fix external trigger --- .editorconfig | 0 .github/workflows/external_trigger.yml | 4 ++-- Dockerfile | 2 +- Jenkinsfile | 32 +++++++++++++++++--------- jenkins-vars.yml | 6 +++-- 5 files changed, 28 insertions(+), 16 deletions(-) mode change 100755 => 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig old mode 100755 new mode 100644 diff --git a/.github/workflows/external_trigger.yml b/.github/workflows/external_trigger.yml index 5464db1..75a39f8 100644 --- a/.github/workflows/external_trigger.yml +++ b/.github/workflows/external_trigger.yml @@ -26,8 +26,8 @@ jobs: echo "> [!NOTE]" >> $GITHUB_STEP_SUMMARY echo "> External trigger running off of main branch. To disable this trigger, add \`mullvad-browser_main\` into the Github organizational variable \`SKIP_EXTERNAL_TRIGGER\`." >> $GITHUB_STEP_SUMMARY printf "\n## Retrieving external version\n\n" >> $GITHUB_STEP_SUMMARY - EXT_RELEASE=$(curl -u ${{ secrets.CR_USER }}:${{ secrets.CR_PAT }} -sX GET "https://api.github.com/repos/mullvad/mullvad-browser/releases/latest" | jq -r .name | awk -F ' ' '{print $3}') - echo "Type is \`custom_version_command\`" >> $GITHUB_STEP_SUMMARY + EXT_RELEASE=$(curl -u "${{ secrets.CR_USER }}:${{ secrets.CR_PAT }}" -sX GET "https://api.github.com/repos/mullvad/mullvad-browser/releases/latest" | jq -r '. | .tag_name') + echo "Type is \`github_stable\`" >> $GITHUB_STEP_SUMMARY if grep -q "^mullvad-browser_main_${EXT_RELEASE}" <<< "${SKIP_EXTERNAL_TRIGGER}"; then echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY echo "> Github organizational variable \`SKIP_EXTERNAL_TRIGGER\` matches current external release; skipping trigger." >> $GITHUB_STEP_SUMMARY diff --git a/Dockerfile b/Dockerfile index f5c8f74..3f5526d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -51,7 +51,7 @@ RUN \ mkdir -p /app && \ if [ -z ${MULLVAD_VERSION+x} ]; then \ MULLVAD_VERSION=$(curl -sX GET "https://api.github.com/repos/mullvad/mullvad-browser/releases/latest" \ - | jq -r .name | awk -F ' ' '{print $3}'); \ + | jq -r .tag_name); \ fi && \ curl -s -o \ /tmp/mullvad.tar.xz -L \ diff --git a/Jenkinsfile b/Jenkinsfile index 9aff1b7..1d8d918 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,6 +19,9 @@ pipeline { DOCKERHUB_TOKEN=credentials('docker-hub-ci-pat') QUAYIO_API_TOKEN=credentials('quayio-repo-api-token') GIT_SIGNING_KEY=credentials('484fbca6-9a4f-455e-b9e3-97ac98785f5f') + EXT_GIT_BRANCH = 'main' + EXT_USER = 'mullvad' + EXT_REPO = 'mullvad-browser' BUILD_VERSION_ARG = 'MULLVAD_VERSION' LS_USER = 'linuxserver' LS_REPO = 'docker-mullvad-browser' @@ -138,16 +141,23 @@ pipeline { /* ######################## External Release Tagging ######################## */ - // 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://api.github.com/repos/mullvad/mullvad-browser/releases/latest" | jq -r .name | awk -F ' ' '{print $3}' ''', - returnStdout: true).trim() - env.RELEASE_LINK = 'custom_command' - } - } + // 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 -H "Authorization: token ${GITHUB_TOKEN}" -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 + } + } } // Sanitize the release tag and strip illegal docker or github characters stage("Sanitize tag"){ @@ -983,7 +993,7 @@ pipeline { "tagger": {"name": "LinuxServer-CI","email": "ci@linuxserver.io","date": "'${GITHUB_DATE}'"}}' ''' echo "Pushing New release for Tag" sh '''#! /bin/bash - echo "Updating to ${EXT_RELEASE_CLEAN}" > releasebody.json + curl -H "Authorization: token ${GITHUB_TOKEN}" -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq '. |.body' | sed 's:^.\\(.*\\).$:\\1:' > releasebody.json echo '{"tag_name":"'${META_TAG}'",\ "target_commitish": "main",\ "name": "'${META_TAG}'",\ diff --git a/jenkins-vars.yml b/jenkins-vars.yml index 7bf4828..9610023 100644 --- a/jenkins-vars.yml +++ b/jenkins-vars.yml @@ -2,13 +2,15 @@ # jenkins variables project_name: docker-mullvad-browser -external_type: na -custom_version_command: "curl -sX GET \"https://api.github.com/repos/mullvad/mullvad-browser/releases/latest\" | jq -r .name | awk -F ' ' '{print $3}'" +external_type: github_stable release_type: stable release_tag: latest ls_branch: main build_armhf: false repo_vars: + - EXT_GIT_BRANCH = 'main' + - EXT_USER = 'mullvad' + - EXT_REPO = 'mullvad-browser' - BUILD_VERSION_ARG = 'MULLVAD_VERSION' - LS_USER = 'linuxserver' - LS_REPO = 'docker-mullvad-browser'