Commit f2bec0fd authored by Jerome Chauveau's avatar Jerome Chauveau
Browse files

Mise en place build automatique de la release (CI)

parent 73228783
Loading
Loading
Loading
Loading

.gitlab-ci.yml

0 → 100644
+57 −0
Original line number Diff line number Diff line
stages:
  - build
  - upload
  - release

variables:
  REGISTRY_PROJECT_ID: "855"
#  ASSET: "test_ci-${PACKAGE_VERSION}-release.txt"
# PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/MaX/${PACKAGE_VERSION}"

build:
  stage: build
  image: node:latest
  rules:
    - if: $CI_COMMIT_TAG
  before_script:
    - apt-get update
    - apt-get install -y zip git python3 mkdocs
    - yarn install --prefer-offline
  script:
    - echo $SHELL
    - MAX_VERSION=$(node -p -e "require('./package.json').version")
    - cd tools
    - ./build.sh
    - echo $MAX_VERSION > dist/version
    - mv dist ../max-build
  artifacts:
    paths:
      - max-build/

upload:
  stage: upload
  image: curlimages/curl:latest
  rules:
    - if: $CI_COMMIT_TAG
  script:
    - MAX_VERSION=$(cat max-build/version)
    - ASSET="max-v${MAX_VERSION}.zip"
    - PACKAGE_REGISTRY_URL=${CI_API_V4_URL}/projects/${REGISTRY_PROJECT_ID}/packages/generic/MaX/${MAX_VERSION}
    - echo "will upload "$ASSET" at "${PACKAGE_REGISTRY_URL}/${ASSET}
    - |
      curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file max-build/${ASSET} "${PACKAGE_REGISTRY_URL}/${ASSET}"

release:
  # Caution, as of 2021-02-02 these assets links require a login, see:
  # https://gitlab.com/gitlab-org/gitlab/-/issues/299384
  stage: release
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  rules:
    - if: $CI_COMMIT_TAG
  script:
    - MAX_VERSION=$(cat max-build/version)
    - ASSET="max-v${MAX_VERSION}.zip"
    - PACKAGE_REGISTRY_URL=${CI_API_V4_URL}/projects/${REGISTRY_PROJECT_ID}/packages/generic/MaX/${MAX_VERSION}
    - |
      release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \
        --assets-link "{\"name\":\"${ASSET}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${ASSET}\"}"
+11 −4
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
#builts max release ' zip

DIRECTORY=$(cd `dirname $0` && pwd)

echo "Working directory = "$DIRECTORY

if [ -d dist ]
then
@@ -33,6 +33,7 @@ cp $DIRECTORY/../legal.txt $RELEASE_FOLDER
cp $DIRECTORY/../README.md $RELEASE_FOLDER
cp -Lr $DIRECTORY/../plugins $RELEASE_FOLDER
MAX_PLUGINS_DIR=$RELEASE_FOLDER/plugins
echo 'Target plugin dir = '$MAX_PLUGINS_DIR
for i in `ls $MAX_PLUGINS_DIR`
do
  touch $MAX_PLUGINS_DIR/$i/.ignore
@@ -53,14 +54,20 @@ sed -i "2s/.*/MAX_VERSION=$MAX_VERSION/g" $RELEASE_FOLDER/tools/max.sh
echo "MaX "$MAX_VERSION >  $RELEASE_FOLDER/VERSION

#gets and builds documentation
if [ -z $MAX_DOC_TOKEN ]
then
  echo 'Warning : environment variable MAX_DOC_TOKEN is not defined.'
  git clone git@git.unicaen.fr:pdn-certic/max-documentation.git
else
  echo 'Environment variable $MAX_DOC_TOKEN is correctly defined !'
  git clone https://gitlab-ci-token:$MAX_DOC_TOKEN@git.unicaen.fr/pdn-certic/max-documentation.git
fi

cd max-documentation

#override default documentation compil option for local use
cp ../mkdocs_local_config.yml mkdocs.yml

mkdocs build

mv site ../$RELEASE_FOLDER/documentation
cd ..
rm -rf max-documentation