diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7fac4f6c..c062452d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: alpine:latest +image: smartmeio/arancino-library-build stages: @@ -30,90 +30,61 @@ start: expire_in: 1d only: - - branches - tags except: - master + - branches ################################# ####### PACKAGE ####### ################################# -####### Package Staging ####### -package_staging: - stage: package - - script: - - apk add zip grep coreutils - #create some variables into temp folder - - DATE="$(cat tmp/date.txt)" - - TIME="$(cat tmp/time.txt)" - - PKG_NAME=$PLATFORM_NAME-$DATE-$TIME-$CI_COMMIT_REF_NAME-${CI_COMMIT_SHA:0:8} - - echo $PKG_NAME > tmp/pgk_name.txt - - echo $CI_PROJECT_NAME-snapshot > tmp/repo_name.txt - - echo $DATE/$CI_COMMIT_REF_NAME-${CI_COMMIT_SHA:0:8} > tmp/target_path.txt - - - cd .. - #tar files and move temp folder back - - tar --exclude=tmp --exclude=.git* --exclude=*.DS_Store* -cvjf $PKG_NAME.tar.bz2 $CI_PROJECT_NAME - - #move tar into temp folder - - cd $CI_PROJECT_NAME - - mv ../$PKG_NAME.tar.bz2 tmp/ - - #create files containing sha 256 checksum and size in bytes of the tar file - - sha256sum tmp/$PKG_NAME.tar.bz2 | awk '{print $1}' > tmp/SHA256.txt - - du -b tmp/$PKG_NAME.tar.bz2 | awk {'print $1}' > tmp/SIZE.txt - - echo FILENAME $PKG_NAME.tar.bz2 - - echo SHA-256 `cat tmp/SHA256.txt` - - echo SIZE `cat tmp/SIZE.txt` - - echo PKG_NAME `cat tmp/pgk_name.txt` - - dependencies: - - start - - artifacts: - paths: - - tmp/ - - only: - - branches - - except: - - tags - - master - ####### Package Release ####### package_release: stage: package script: - - apk add zip grep coreutils - #create some variables into temp folder - - PKG_NAME=$PLATFORM_NAME-$CI_COMMIT_REF_NAME - - echo $PKG_NAME > tmp/pgk_name.txt - - echo $CI_PROJECT_NAME > tmp/repo_name.txt - - echo $CI_COMMIT_REF_NAME > tmp/target_path.txt - - - sed -i "s:\(ARANCINO_CORE_VERSION\) .*:\1 \"$CI_COMMIT_REF_NAME\":" ./cores/arancino/Arduino.h - - sed -i "s:\(version\)=.*:\1=$CI_COMMIT_REF_NAME:" ./platform.txt + # create some variables into temp folder + - PKG_NAME=$PLATFORM_NAME-$CI_COMMIT_TAG + - PKG_NAME_PIO=framework-arduino-samd-arancino-$CI_COMMIT_TAG + + - echo $PKG_NAME > tmp/pkg_name.txt + - echo $PKG_NAME_PIO > tmp/pkg_name_pio.txt + - echo $CI_COMMIT_TAG > tmp/target_path.txt + + - sed -i "s:\(ARANCINO_CORE_VERSION\) .*:\1 \"$CI_COMMIT_TAG\":" ./cores/arancino/Arduino.h + - sed -i "s:\(version\)=.*:\1=$CI_COMMIT_TAG:" ./platform.txt + - jq --arg tag_ver ${CI_COMMIT_TAG} '.version = $tag_ver' package.json|sponge package.json - cd .. - #tar files and move temp folder back + # tar files and move temp folder back - tar --exclude=tmp --exclude=.git* --exclude=*.DS_Store* -cvjf $PKG_NAME.tar.bz2 $CI_PROJECT_NAME - - #move tar into temp folder + + # pio packaging + - cp -r $CI_PROJECT_NAME framework-arduino-samd-arancino + - tar --exclude=tmp --exclude=.git* --exclude=*.DS_Store* -cvjf $PKG_NAME_PIO.tar.bz2 framework-arduino-samd-arancino + + # move tar into temp folder - cd $CI_PROJECT_NAME - mv ../$PKG_NAME.tar.bz2 tmp/ - - #create files containing sha 256 checksum and size in bytes of the tar file + - mv ../$PKG_NAME_PIO.tar.bz2 tmp/ + + # create files containing sha 256 checksum and size in bytes of the tar file - sha256sum tmp/$PKG_NAME.tar.bz2 | awk '{print $1}' > tmp/SHA256.txt - du -b tmp/$PKG_NAME.tar.bz2 | awk {'print $1}' > tmp/SIZE.txt - echo FILENAME $PKG_NAME.tar.bz2 - echo SHA-256 `cat tmp/SHA256.txt` - echo SIZE `cat tmp/SIZE.txt` - - echo PKG_NAME `cat tmp/pgk_name.txt` + - echo PKG_NAME `cat tmp/pkg_name.txt` + + # same step above but for PIO + - sha256sum tmp/$PKG_NAME_PIO.tar.bz2 | awk '{print $1}' > tmp/SHA256_pio.txt + - du -b tmp/$PKG_NAME_PIO.tar.bz2 | awk {'print $1}' > tmp/SIZE_pio.txt + - echo FILENAME_PIO $PKG_NAME_PIO.tar.bz2 + - echo SHA-256-PIO `cat tmp/SHA256_pio.txt` + - echo SIZE_PIO `cat tmp/SIZE_pio.txt` + - echo PKG_NAME_PIO `cat tmp/pkg_name_pio.txt` dependencies: - start @@ -121,7 +92,6 @@ package_release: artifacts: paths: - tmp/ - except: - branches - master @@ -135,31 +105,32 @@ package_release: ####### Upload Staging and Release ####### upload: - stage: upload - variables: - GIT_STRATEGY: none + before_script: + - eval `python3 check-version-tag.py ${CI_COMMIT_TAG}` - script: + script: - DATE="$(cat tmp/date.txt)" - TIME="$(cat tmp/time.txt)" - - PKG_NAME="$(cat tmp/pgk_name.txt)" - - REPO_NAME="$(cat tmp/repo_name.txt)" + - PKG_NAME="$(cat tmp/pkg_name.txt)" + - PKG_NAME_PIO="$(cat tmp/pkg_name_pio.txt)" - TARGET_PATH="$(cat tmp/target_path.txt)" - - apk add curl + - > + if [[ ${PRE_RELEASE} == "test" ]]; then + REPO_NAME=${REPO_NAME}-snapshot + REPO_NAME_PIO=${REPO_NAME_PIO}-snapshot + fi # Upload to Artifactory - curl -u $REPO_USR:$REPO_PWD -T tmp/$PKG_NAME.tar.bz2 "${REPO_BASE_URL}/artifactory/${REPO_NAME}/${TARGET_PATH}/${PKG_NAME}.tar.bz2" - -#dependencies: -# - package + - curl -u $REPO_USR:$REPO_PWD -T tmp/$PKG_NAME_PIO.tar.bz2 "${REPO_BASE_URL}/artifactory/${REPO_NAME_PIO}/${TARGET_PATH}/${PKG_NAME_PIO}.tar.bz2" only: - - branches - tags except: - master + - branches ################################# ####### CLEANUP ####### @@ -171,16 +142,16 @@ cleanup: variables: GIT_STRATEGY: none - + script: - echo "Cleaning up" - rm -rf tmp/ - + when: always only: - - branches - tags except: - - master \ No newline at end of file + - master + - branches diff --git a/CHANGELOG b/CHANGELOG index 246e687f..a16f16b1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,10 @@ +#### v 1.2.2 - 2021.03.11 + +* main features of previous release +* ArduinoOTA tool updated to release v1.0.10 [#et1342](https://app.clickup.com/t/et1342) +* Dual Compatibility with PlatformIO (platform and tools) [#agym78](https://app.clickup.com/t/agym78) +* now the CI/CD script is only triggered by creation of tags + #### v 1.2.1 - 2021.01.14 * Dropping `build.memory_wrapping_flags` entry which is not anymore supported by FreeRTOS_samd library diff --git a/check-version-tag.py b/check-version-tag.py new file mode 100644 index 00000000..6ae080c2 --- /dev/null +++ b/check-version-tag.py @@ -0,0 +1,51 @@ +import semantic_version as semver, sys +import re +import shutil, glob, os +from tempfile import mkstemp +from sh import sed + +pre_release_release_list = ["test", "rc", "beta", "alpha"] + +# vertical = None +# 1.0.0-test.3 +# 1.0.0-alpha.1 +# 1.0.0-beta.2 +# 1.0.0-rc.1 +# 1.0.0 + +def create_file(filename, content): + file = open(filename, "w+") + file.write(content) + file.close() + +def lsbfiles(dir): + # note you have subdirs and files flipped in your code + for root, subdirs, files in os.walk(dir): + for file in files: + if file.startswith('lsb'): + yield(os.path.join(root,file)) + +if __name__ == '__main__': + # get all arguments + args = sys.argv + # global vertical + # first argument is the tag name, it represents the version number. + tag = args[1] + v = semver.Version(tag) + + # print("release is : "+str(v.major)+'.'+str(v.minor)+'.'+str(v.patch)) + + try: + if v.prerelease[0] in pre_release_release_list: + # print("pre-release is : "+v.prerelease[0]+'.'+v.prerelease[1]) + # print("pre-release is : "+v.prerelease[0]+'.'+re.sub("-.*$", "", v.prerelease[1])) + pass + except IndexError: + pass + + try: + print("export PRE_RELEASE='{}'".format(v.prerelease[0])) + except IndexError: + print("export PRE_RELEASE='{}'".format("")) + + exit(0)