Skip to content
Snippets Groups Projects
.gitlab-ci.yml 3.21 KiB
Newer Older
  • Learn to ignore specific revisions
  • David Byers's avatar
    David Byers committed
    ---
    stages:
    
    David Byers's avatar
    David Byers committed
      - build
    
      - collect
    
    David Byers's avatar
    David Byers committed
      - deploy
    
    
    David Byers's avatar
    David Byers committed
    # Anchors
    
    David Byers's avatar
    David Byers committed
    .release_rules: &release_rules
      rules:
        - if: "$CI_COMMIT_TAG =~ /^release-/ && $CI_COMMIT_BRANCH == 'master'"
          when: always
        - when: never
    
    David Byers's avatar
    David Byers committed
    
    
    # Stage: prepare
    #
    # Builds unpacked extensions from the source files.
    
    .prepare:
    
      stage: prepare
      image: python:3.7-stretch
      script:
    
    David Byers's avatar
    David Byers committed
        - python3 scripts/update-version.py -k "$SSH_TAGGING_KEY" -o version -v
    
        - bash scripts/build.sh --version "$(cat version)"
      artifacts:
        paths:
    
    David Byers's avatar
    David Byers committed
          - version
    
    David Byers's avatar
    David Byers committed
          - build/**
    
    David Byers's avatar
    David Byers committed
    
    prepare:beta:
      extends: .prepare
    
    David Byers's avatar
    David Byers committed
    prepare:release:
      extends: .prepare
      <<: *release_rules
    
    
    # Stage: build
    #
    # Builds packages from the prepared unpacked extensions.
    
    David Byers's avatar
    David Byers committed
    .build:firefox:
      stage: build
    
      image: node:lts-buster
    
      cache:
        paths:
          - $CI_PROJECT_DIR/.cache/npm
      before_script:
        - mkdir -p "$CI_PROJECT_DIR/.cache/npm"
    
    David Byers's avatar
    David Byers committed
      script:
    
        - npm install --global web-ext --cache "$CI_PROJECT_DIR/.cache/npm" --prefer-offline --no-audit
    
    David Byers's avatar
    David Byers committed
        - cd build/firefox
    
        - web-ext -a . sign --channel=$CHANNEL
    
    David Byers's avatar
    David Byers committed
        - mv atp_safe_links_cleaner* ../../safelinks-cleaner-firefox-$VARIANT.xpi
    
    David Byers's avatar
    David Byers committed
      artifacts:
    
    David Byers's avatar
    David Byers committed
        paths:
    
    David Byers's avatar
    David Byers committed
          - safelinks-cleaner-firefox.xpi
    
    David Byers's avatar
    David Byers committed
    build:firefox:beta:
      extends: .build:firefox
    
    David Byers's avatar
    David Byers committed
        CHANNEL: unlisted
    
    David Byers's avatar
    David Byers committed
        VARIANT: beta
    
    David Byers's avatar
    David Byers committed
      rules:
    
    David Byers's avatar
    David Byers committed
        - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "beta"'
    
    David Byers's avatar
    David Byers committed
          changes:
    
    David Byers's avatar
    David Byers committed
            - shared/**
            - firefox/**
    
    David Byers's avatar
    David Byers committed
          when: always
    
        - if: '$CI_COMMIT_MESSAGE =~ /#force-build:(all|firefox)/ && $CI_COMMIT_BRANCH == "beta"'
    
    David Byers's avatar
    David Byers committed
          when: always
    
    David Byers's avatar
    David Byers committed
        - when: never
    
    David Byers's avatar
    David Byers committed
    
    
    David Byers's avatar
    David Byers committed
    build:firefox:release:
    
    David Byers's avatar
    David Byers committed
      extends: .build:firefox
    
    David Byers's avatar
    David Byers committed
        CHANNEL: listed
    
    David Byers's avatar
    David Byers committed
        VARIANT: release
      <<: *release_rules
    
    David Byers's avatar
    David Byers committed
    .build:thunderbird:
    
    David Byers's avatar
    David Byers committed
      stage: build
    
      image: python:3.7-stretch
      script:
        - apt-get -y update
        - apt-get -y install zip
        - cd build/thunderbird
    
    David Byers's avatar
    David Byers committed
        - zip -r ../../safelinks-cleaner-thunderbird-$VARIANT.xpi *
    
    David Byers's avatar
    David Byers committed
          - safelinks-cleaner-thunderbird-$VARIANT.xpi
    
    .build:thunderbird:beta:
      extends: .build:thunderbird
      variables:
        VARIANT: beta
    
    David Byers's avatar
    David Byers committed
      rules:
        - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "beta"'
    
    David Byers's avatar
    David Byers committed
          changes:
    
    David Byers's avatar
    David Byers committed
            - shared/**
            - thunderbird/**
    
    David Byers's avatar
    David Byers committed
          when: always
    
        - if: '$CI_COMMIT_MESSAGE =~ /#force-build:(all|thunderbird)/ && $CI_COMMIT_BRANCH == "beta"'
    
    David Byers's avatar
    David Byers committed
          when: always
    
    David Byers's avatar
    David Byers committed
        - when: never
    
    David Byers's avatar
    David Byers committed
    .build:thunderbird:release:
      extends: .build:thunderbird
      variables:
        VARIANT: release
      <<: *release_rules
    
    
    # Stage: collect/deploy
    #
    # Wait for build artifacts then deploy new beta version to pages.
    
    David Byers's avatar
    David Byers committed
    
    
    David Byers's avatar
    David Byers committed
    .collect:
    
      stage: collect
    
    David Byers's avatar
    David Byers committed
    pages:
    
    David Byers's avatar
    David Byers committed
      stage: deploy
    
    David Byers's avatar
    David Byers committed
      script:
        - cp -r site .public
    
    David Byers's avatar
    David Byers committed
        - sed -i -e "s/%BUILDDATE%/$(date +'%Y-%m-%d %H:%M')/g" .public/index.html
    
        - sed -i -e "s/VERSION%/$(cat version)/g" .public/index.html
    
    David Byers's avatar
    David Byers committed
        - cp safelinks-cleaner-*.xpi .public
    
    David Byers's avatar
    David Byers committed
        - mv .public public
        - ls -lr public
    
    David Byers's avatar
    David Byers committed
      needs:
    
    David Byers's avatar
    David Byers committed
        - job: .collect
    
    David Byers's avatar
    David Byers committed
        - project: $CI_PROJECT_PATH
          job: build:thunderbird:beta
          ref: $CI_COMMIT_REF_NAME
          artifacts: true
        - project: $CI_PROJECT_PATH
          job: build:firefox:beta
          ref: $CI_COMMIT_REF_NAME
          artifacts: true
    
    David Byers's avatar
    David Byers committed
      only:
        - beta
    
    David Byers's avatar
    David Byers committed
      artifacts:
        paths:
          - public/