From 54f08f9bf64483f69aa5e81c74f36f7095724dbd Mon Sep 17 00:00:00 2001 From: David Byers <david.byers@liu.se> Date: Mon, 8 Feb 2021 11:04:59 +0100 Subject: [PATCH] Use CI variables for URLs. Reorganize CI/CD pipelines. --- .gitlab-ci.yml | 78 +++++++++++++++++++++-------- firefox/manifest.beta.part.json | 2 +- scripts/build.sh | 19 +------ shared/manifest.part.json | 2 +- thunderbird/manifest.beta.part.json | 2 +- 5 files changed, 62 insertions(+), 41 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 945a5b5..c6f777e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,7 @@ --- stages: - version + - prepare - build - deploy @@ -15,45 +16,80 @@ version: only: - branches -.npm: + +prepare: + stage: prepare + image: python:3.7-stretch + script: + - bash scripts/build.sh --version "$(cat version)" + artifacts: + paths: + - ./build/safelinks-cleaner-thunderbird.xpi + - ./build/safelinks-cleaner-firefox.xpi + only: + - master + - beta + + +.deploy:firfox: + stage: deploy image: node:lts-buster cache: paths: - $CI_PROJECT_DIR/.cache/npm before_script: - mkdir -p "$CI_PROJECT_DIR/.cache/npm" - - -.sign: - script: - - web-ext sign --channel=unlisted - - -build: - stage: build - extends: .npm script: - - apt-get -y update - - apt-get -y install zip python3-minimal - npm install --global web-ext --cache "$CI_PROJECT_DIR/.cache/npm" --prefer-offline --no-audit - - bash scripts/build.sh --version "$(cat version)" - - cd build/firefox - - ls -l + - cd ./build/firefox + - web-ext -a . sign --channel=$CHANNEL + - mv atp_safe_links_cleaner* ../../safelinks-cleaner-firefox.xpi artifacts: paths: - - ./build/safelinks-cleaner-thunderbird.xpi - ./build/safelinks-cleaner-firefox.xpi + when: manual + + +deploy:firefox:beta: + extends: .deploy:firefox + variables: + - CHANNEL=unlisted only: - - master - beta + +deploy:firefox:master: + extends: .deploy:firefox + variables: + - CHANNEL=listed + only: + - master + + +deploy:thunderbird: + stage: deploy + image: python:3.7-stretch + script: + - apt-get -y update + - apt-get -y install zip + - cd build/thunderbird + - zip -r ../../safelinks-cleaner-thunderbird.xpi * + artifacts: + paths: + - safelinks-cleaner-thunderbird.xpi + when: manual + + pages: stage: deploy + needs: + - version + - prepare script: - cp -r site .public - sed -i -e "s/%BUILDDATE%/$(date +'%Y-%m-%d %H:%M')/g" .public/index.html - - cp build/safelinks-cleaner-thunderbird.xpi .public - - cp build/safelinks-cleaner-firefox.xpi .public + - cp safelinks-cleaner-thunderbird.xpi .public + - cp safelinks-cleaner-firefox.xpi .public - mv .public public - ls -lr public artifacts: @@ -61,4 +97,4 @@ pages: - public/ only: - beta - when: always + when: manual diff --git a/firefox/manifest.beta.part.json b/firefox/manifest.beta.part.json index da4eb9d..5d784b2 100644 --- a/firefox/manifest.beta.part.json +++ b/firefox/manifest.beta.part.json @@ -3,7 +3,7 @@ "browser_specific_settings": { "gecko": { "id": "safelinks-cleaner@it.liu.se", - "update_url": "https://safelinks.gitlab-pages.liu.se/safelinks-cleaner-thunderbird/%XPIFILE%" + "update_url": "%PAGES_URL%/%XPIFILE%" } } } diff --git a/scripts/build.sh b/scripts/build.sh index 5a689d6..97b85cf 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -113,22 +113,7 @@ for target in "${TARGETS[@]}" ; do sed -i -e "s/%XPIFILE%/$xpifile/g" "$targetdir/manifest.json" sed -i -e "s/%VERSION%/$version/g" "$targetdir/manifest.json" sed -i -e "s/%VERSION_NAME%/$version_name/g" "$targetdir/manifest.json" + sed -i -e "s/%PAGES_URL%/$CI_PAGES_URL/g" "$targetdir/manifest.json" + sed -i -e "s/%PROJECT_URL%/$CI_PROJECT_URL/g" "$targetdir/manifest.json" - case "$target" in - thunderbird) - (cd "$targetdir" ; zip -r "$outputfile" *) - ;; - firefox) - if [ "$beta" ] ; then - channel=unlisted - else - channel=listed - fi - (cd "$targetdir" ; $WEB_EXT -a "$BUILDDIR" sign --channel=$channel) - mv "$BUILDDIR"/atp_safe_links_cleaner* "$outputfile" - ;; - esac - echo "[-] output to '$outputfile'" - - # (cd "$targetdir" ; zip -r "$outputfile" *) done diff --git a/shared/manifest.part.json b/shared/manifest.part.json index 4b818da..c431463 100644 --- a/shared/manifest.part.json +++ b/shared/manifest.part.json @@ -4,7 +4,7 @@ "description": "__MSG_extensionDescription__", "version": "%VERSION%", "author": "David Byers", - "homepage_url": "https://gitlab.liu.se/safelinks/safelinks-cleaner/", + "homepage_url": "%PROJECT_URL%", "default_locale": "en", "icons": { "48": "icon.svg", diff --git a/thunderbird/manifest.beta.part.json b/thunderbird/manifest.beta.part.json index e506fb6..668fbf1 100644 --- a/thunderbird/manifest.beta.part.json +++ b/thunderbird/manifest.beta.part.json @@ -1,7 +1,7 @@ { "applications": { "gecko": { - "update_url": "https://safelinks.gitlab-pages.liu.se/safelinks-cleaner-thunderbird/%XPIFILE%" + "update_url": "%PAGES_URL%/%XPIFILE%" } } } -- GitLab