Commit acc065c6 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

Update .gitlab-ci.yml file

parent 87a95dbe
Loading
Loading
Loading
Loading
Loading
+75 −3
Original line number Diff line number Diff line
@@ -27,6 +27,11 @@
# * Deploy built artifacts from master branch only.

variables:
  SITE_LOCATION: "updatesite/org.etsi.mts.tdl.updatesite/target"
  ARCHIVE_NAME: "org.etsi.mts.tdl.updatesite-1.0.0-SNAPSHOT.zip"
  SITE_ARCHIVE: "${SITE_LOCATION}/${ARCHIVE_NAME}"
  SITE_PATH: "${SITE_LOCATION}/repository/"
  PACKAGE_NAME: "TOP IDE Interim Build"
  # `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
  MAVEN_OPTS: >-
    -Xmx2048m
@@ -68,7 +73,7 @@ cache:
.verify:
  stage: test
  script:
    - cd org.etsi.mts.tld.parent
    - cd org.etsi.mts.tdl.parent
    - 'mvn $MAVEN_CLI_OPTS verify'
  except:
    variables:
@@ -99,6 +104,9 @@ stages: # List of stages for jobs, and their order of execution
  - build
  - test
  - deploy
  - prepare
  - upload
  - release

build-job:       # This job runs in the build stage, which runs first.
  stage: build
@@ -109,8 +117,8 @@ build-job: # This job runs in the build stage, which runs first.
    - echo "Compile complete."
  artifacts:
    paths:
      - updatesite/org.etsi.mts.tdl.updatesite/target/org.etsi.mts.tdl.updatesite-1.0.0-SNAPSHOT.zip
      - updatesite/org.etsi.mts.tdl.updatesite/target/repository
      - $SITE_ARCHIVE
      - $SITE_PATH

unit-test-job:   # This job runs in the test stage.
  stage: test    # It only starts when the job in the build stage completes successfully.
@@ -132,3 +140,67 @@ deploy-job: # This job runs in the deploy stage.
  script:
    - echo "Deploying application..."
    - echo "Application successfully deployed."


# Adapted from OpenAPI2TDL converter
prepare:
  stage: prepare
  # rules:
    # - if: $CI_COMMIT_TAG
      # when: never
    # - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  script:
    - VERSION=`date +%Y%m%d.%H.%M`
    - echo "EXTRA_DESCRIPTION=automatic-release" >> variables.env
    - echo "VERSION=$VERSION" >> variables.env
    - echo "PACKAGE_REGISTRY_URL=${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/ide/${VERSION}" >> variables.env
    - cat variables.env
  artifacts:
    reports:
      dotenv: variables.env   # Use artifacts:reports:dotenv to expose the variables to other jobs

# https://gitlab.com/gitlab-org/release-cli/-/tree/master/docs/examples/release-assets-as-generic-package/
upload:
  stage: upload
  image: curlimages/curl:latest
  needs:
    - job: prepare
      artifacts: true
    - job: build
      artifacts: true
  # rules:
    # - if: $CI_COMMIT_TAG
      # when: never
    # - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  script:
    - echo "${PACKAGE_REGISTRY_URL}/${ARCHIVE_NAME}"
    - |
      curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file ${SITE_ARCHIVE} ${PACKAGE_REGISTRY_URL}/${ARCHIVE_NAME}
    # - |
      # curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/${MACOS_GUI_JAR} ${PACKAGE_REGISTRY_URL}/${MACOS_GUI_JAR}
    # - |
      # curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/${WINDOWS_GUI_JAR} ${PACKAGE_REGISTRY_URL}/${WINDOWS_GUI_JAR}
    # - |
      # curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/${CLI_JAR} ${PACKAGE_REGISTRY_URL}/${CLI_JAR}
    # - |
      # curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/${LIB_JAR} ${PACKAGE_REGISTRY_URL}/${LIB_JAR}

release:
  stage: release
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  needs:
    - job: prepare
      artifacts: true
  # rules:
    # - if: $CI_COMMIT_TAG
      # when: never
    # - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  script:
    - |
      release-cli create --name "Release $VERSION" --tag-name $VERSION --ref $CI_COMMIT_SHA \
        --assets-link "{\"name\":\"${PACKAGE_NAME}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${ARCHIVE_NAME}\"}" \
        # --assets-link "{\"name\":\"${MACOS_GUI_JAR}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${MACOS_GUI_JAR}\"}" \
        # --assets-link "{\"name\":\"${WINDOWS_GUI_JAR}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${WINDOWS_GUI_JAR}\"}" \
        # --assets-link "{\"name\":\"${CLI_JAR}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${CLI_JAR}\"}" \
        # --assets-link "{\"name\":\"${LIB_JAR}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LIB_JAR}\"}"