Loading create_new_tag.sh 0 → 100644 +141 −0 Original line number Diff line number Diff line #!/bin/bash REPO="git@gitlab.e.foundation:e/os/android.git" apt install xmlstarlet create_branch (){ git checkout -b $1 git remote -v git push $2 $1 } iterate_remote () { projects=`xmlstarlet select --template --value-of /manifest/project[@remote=\"$1\"]/@name $2` for project in $projects; do git clone git@gitlab.e.foundation:$project current_project cd current_project echo "creating branch "$new_version" on "$project create_branch $new_version origin cd .. rm -rf current_project done } parse_manifests () { for filename in *.xml; do iterate_remote e $filename iterate_remote e-priv $filename done } parse_and_update_project_manifest () { git clone $1 -b $CI_COMMIT_REF_NAME manifests cd manifests parse_manifests create_branch $new_version origin cd .. rm -rf manifests } sync_main_manifest(){ cd "$SRC_DIR" repo init --depth 1 -u $REPO -b $1 repo sync -c --force-sync --force-sync --force-remove-dirty --prune } # Identify new tag name if [ -z "$NEW_TAG" ]; then cd $CI_PROJECT_DIR echo "Retrieving last tag" current_version=`echo $CI_COMMIT_REF_NAME | sed 's/.*\-//'` latest_version=`git for-each-ref --sort=creatordate --format '%(refname)' refs/tags | grep "\-$current_version" | grep -v "beta" | grep -v "rc" | grep -ve ".*\..*\..*" | sed 's/.*\///' | tail -1` latest_version="${latest_version#*\.}" latest_version="${latest_version%\.*}" latest_version="${latest_version%\-*}" new_version=v1.$((latest_version+1))-$current_version echo "New version: "$new_version cd "$SRC_DIR" else new_version=$NEW_TAG fi if [ "$PREVERSION" == "beta" ] then git clone $REPO current_project -b $CI_COMMIT_REF_NAME cd current_project sed -i 's/'$CI_COMMIT_REF_NAME'/'$new_version'/' default.xml git add default.xml git commit -m "creating "$new_version" manifest" echo "creating branch "$new_version" on main manifest" create_branch $new_version origin git push origin $new_version cd .. rm -rf current_project sync_main_manifest $CI_COMMIT_REF_NAME echo "==> Creating new branches on /e/ projects" repo forall -e -v -c 'if [ "${REPO_REMOTE}" = "e" ] || [ "${REPO_REMOTE}" = "e-priv" ] ; then pwd if [ "${REPO_REMOTE}" = "e" ]; then git remote add e-priv ssh://git@gitlab.e.foundation:2222/${REPO_PROJECT} git fetch e-priv fi; git remote -v echo "Creating branch "'$new_version'" on "$2 git checkout -b "'$new_version'" git push e-priv "'$new_version'" fi ;' # Not using repo sync in case of some conflicts between devices manifests mkdir working-dir cd working-dir echo ">> Get custom local manifests" parse_and_update_project_manifest git@gitlab.e.foundation:e/os/local_manifests.git echo ">> Get custom vendor manifests" parse_and_update_project_manifest git@gitlab.e.foundation:e/devices/manifests.git else sync_main_manifest $new_version fi repo manifest -r -o $CI_PROJECT_DIR/default.xml cd $CI_PROJECT_DIR git add . git commit -m "Update $CI_COMMIT_REF_NAME manifest" || true git push origin HEAD:$CI_COMMIT_REF_NAME apt install -y xmlstarlet if [ -z "$PREVERSION" ] then git tag v1.$((latest_version+1))-$current_version else git tag v1.$((latest_version+1))-${PREVERSION}-$current_version fi git remote -v git push --tags cd "$SRC_DIR" templates/.gitlab-ci.yml +10 −13 Original line number Diff line number Diff line Loading @@ -17,7 +17,8 @@ stages: before_script: - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' - eval $(ssh-agent -s) - echo "$SSH_E_ROBOT_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null # - echo "$SSH_E_ROBOT_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null - echo "$SSH_AL_KEY" | tr -d '\r' | ssh-add - > /dev/null - mkdir -p ~/.ssh - chmod 700 ~/.ssh - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts Loading @@ -26,20 +27,15 @@ stages: - git config --global user.name "$GITLAB_USER_NAME" - git config --global user.email "$GITLAB_USER_EMAIL" script: - mkdir "$SRC_DIR/$CI_COMMIT_REF_NAME" || true - cd "$SRC_DIR/$CI_COMMIT_REF_NAME" - repo init --depth 1 -u $REPO -b $CI_COMMIT_REF_NAME - repo sync -c --force-sync --force-sync --force-remove-dirty --prune - repo manifest -r -o $CI_PROJECT_DIR/default.xml - cd $CI_PROJECT_DIR - git add . - git commit -m "Update $CI_COMMIT_REF_NAME manifest" || true - git push origin HEAD:$CI_COMMIT_REF_NAME - mkdir "$SRC_DIR" || true - cd "$SRC_DIR" - curl -s https://gitlab.e.foundation/e/os/releases/-/raw/master/create_new_tag.sh -o create_new_tag.sh && chmod +x create_new_tag.sh - bash -x create_new_tag.sh rules: - if: '$CI_PIPELINE_SOURCE == "schedule"' when: always - when: manual tags: - generate-e-manifest - create-tag .check-version: image: "registry.gitlab.e.foundation/e/tools/docker-tools:latest" Loading @@ -63,6 +59,7 @@ stages: TAG_NAME: ${CI_COMMIT_TAG} PUBLISH_STAGING_AUTOMATICALLY: "true" USER_BUILD: "false" KEEP_LOCAL_MANIFEST_BRANCH: "true" trigger: project: "e/priv/os/build" branch: ${BUILD_BRANCH} Loading Loading
create_new_tag.sh 0 → 100644 +141 −0 Original line number Diff line number Diff line #!/bin/bash REPO="git@gitlab.e.foundation:e/os/android.git" apt install xmlstarlet create_branch (){ git checkout -b $1 git remote -v git push $2 $1 } iterate_remote () { projects=`xmlstarlet select --template --value-of /manifest/project[@remote=\"$1\"]/@name $2` for project in $projects; do git clone git@gitlab.e.foundation:$project current_project cd current_project echo "creating branch "$new_version" on "$project create_branch $new_version origin cd .. rm -rf current_project done } parse_manifests () { for filename in *.xml; do iterate_remote e $filename iterate_remote e-priv $filename done } parse_and_update_project_manifest () { git clone $1 -b $CI_COMMIT_REF_NAME manifests cd manifests parse_manifests create_branch $new_version origin cd .. rm -rf manifests } sync_main_manifest(){ cd "$SRC_DIR" repo init --depth 1 -u $REPO -b $1 repo sync -c --force-sync --force-sync --force-remove-dirty --prune } # Identify new tag name if [ -z "$NEW_TAG" ]; then cd $CI_PROJECT_DIR echo "Retrieving last tag" current_version=`echo $CI_COMMIT_REF_NAME | sed 's/.*\-//'` latest_version=`git for-each-ref --sort=creatordate --format '%(refname)' refs/tags | grep "\-$current_version" | grep -v "beta" | grep -v "rc" | grep -ve ".*\..*\..*" | sed 's/.*\///' | tail -1` latest_version="${latest_version#*\.}" latest_version="${latest_version%\.*}" latest_version="${latest_version%\-*}" new_version=v1.$((latest_version+1))-$current_version echo "New version: "$new_version cd "$SRC_DIR" else new_version=$NEW_TAG fi if [ "$PREVERSION" == "beta" ] then git clone $REPO current_project -b $CI_COMMIT_REF_NAME cd current_project sed -i 's/'$CI_COMMIT_REF_NAME'/'$new_version'/' default.xml git add default.xml git commit -m "creating "$new_version" manifest" echo "creating branch "$new_version" on main manifest" create_branch $new_version origin git push origin $new_version cd .. rm -rf current_project sync_main_manifest $CI_COMMIT_REF_NAME echo "==> Creating new branches on /e/ projects" repo forall -e -v -c 'if [ "${REPO_REMOTE}" = "e" ] || [ "${REPO_REMOTE}" = "e-priv" ] ; then pwd if [ "${REPO_REMOTE}" = "e" ]; then git remote add e-priv ssh://git@gitlab.e.foundation:2222/${REPO_PROJECT} git fetch e-priv fi; git remote -v echo "Creating branch "'$new_version'" on "$2 git checkout -b "'$new_version'" git push e-priv "'$new_version'" fi ;' # Not using repo sync in case of some conflicts between devices manifests mkdir working-dir cd working-dir echo ">> Get custom local manifests" parse_and_update_project_manifest git@gitlab.e.foundation:e/os/local_manifests.git echo ">> Get custom vendor manifests" parse_and_update_project_manifest git@gitlab.e.foundation:e/devices/manifests.git else sync_main_manifest $new_version fi repo manifest -r -o $CI_PROJECT_DIR/default.xml cd $CI_PROJECT_DIR git add . git commit -m "Update $CI_COMMIT_REF_NAME manifest" || true git push origin HEAD:$CI_COMMIT_REF_NAME apt install -y xmlstarlet if [ -z "$PREVERSION" ] then git tag v1.$((latest_version+1))-$current_version else git tag v1.$((latest_version+1))-${PREVERSION}-$current_version fi git remote -v git push --tags cd "$SRC_DIR"
templates/.gitlab-ci.yml +10 −13 Original line number Diff line number Diff line Loading @@ -17,7 +17,8 @@ stages: before_script: - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' - eval $(ssh-agent -s) - echo "$SSH_E_ROBOT_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null # - echo "$SSH_E_ROBOT_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null - echo "$SSH_AL_KEY" | tr -d '\r' | ssh-add - > /dev/null - mkdir -p ~/.ssh - chmod 700 ~/.ssh - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts Loading @@ -26,20 +27,15 @@ stages: - git config --global user.name "$GITLAB_USER_NAME" - git config --global user.email "$GITLAB_USER_EMAIL" script: - mkdir "$SRC_DIR/$CI_COMMIT_REF_NAME" || true - cd "$SRC_DIR/$CI_COMMIT_REF_NAME" - repo init --depth 1 -u $REPO -b $CI_COMMIT_REF_NAME - repo sync -c --force-sync --force-sync --force-remove-dirty --prune - repo manifest -r -o $CI_PROJECT_DIR/default.xml - cd $CI_PROJECT_DIR - git add . - git commit -m "Update $CI_COMMIT_REF_NAME manifest" || true - git push origin HEAD:$CI_COMMIT_REF_NAME - mkdir "$SRC_DIR" || true - cd "$SRC_DIR" - curl -s https://gitlab.e.foundation/e/os/releases/-/raw/master/create_new_tag.sh -o create_new_tag.sh && chmod +x create_new_tag.sh - bash -x create_new_tag.sh rules: - if: '$CI_PIPELINE_SOURCE == "schedule"' when: always - when: manual tags: - generate-e-manifest - create-tag .check-version: image: "registry.gitlab.e.foundation/e/tools/docker-tools:latest" Loading @@ -63,6 +59,7 @@ stages: TAG_NAME: ${CI_COMMIT_TAG} PUBLISH_STAGING_AUTOMATICALLY: "true" USER_BUILD: "false" KEEP_LOCAL_MANIFEST_BRANCH: "true" trigger: project: "e/priv/os/build" branch: ${BUILD_BRANCH} Loading