diff options
-rw-r--r-- | .gitlab-ci.yml | 20 | ||||
-rw-r--r-- | Makefile | 59 | ||||
-rw-r--r-- | tools/do_release.sh | 73 | ||||
-rw-r--r-- | tools/get_p2_url.py | 21 |
4 files changed, 153 insertions, 20 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..0896758 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,20 @@ +stages: + - build + - release + +on-schedule: + stage: build + image: python3 + only: + - schedules + script: + - sh tools/do_release.sh + +release: + stage: release + image: python3 + script: + - pip3 install gitlab-release + - gitlab-release --zip "release-${CI_COMMIT_TAG}.zip" * + only: + - tags @@ -4,38 +4,61 @@ BUILDDIR ?= build WGET ?= wget PYTHON ?= python3 -$(BUILDDIR): - mkdir -p $(BUILDDIR) - .PRECIOUS: $(BUILDDIR)/%.jar +.PRECIOUS: $(BUILDDIR)/%.jar.version $(BUILDDIR)/%.jar: mkdir -p $(BUILDDIR) - $(WGET) --tries=10 -N -O $@ $$($(PYTHON) tools/get_p2_url.py $*) + $(WGET) --tries=10 -O $@ $$($(PYTHON) tools/get_p2_url.py --write-version $@.version $*) touch $@ +OUTPUTS := svd mx_mcu_db prog_db chip_db + +all: $(OUTPUTS) + $(BUILDDIR)/%.dir: $(BUILDDIR)/%.jar mkdir -p $@ rm -rf $@ - unzip -d $@ $< + unzip -q -d $@ $< .PHONY: update_svd -update_svd: $(BUILDDIR)/com.st.stm32cube.ide.mcu.productdb.debug.dir - rm -rf svd - mkdir -p svd - cp $</resources/cmsis/STMicroelectronics_CMSIS_SVD/{*.svd,License.html} svd/ +svd: $(BUILDDIR)/com.st.stm32cube.ide.mcu.productdb.debug.dir + rm -rf $@ + mkdir -p $@ + cp $</resources/cmsis/STMicroelectronics_CMSIS_SVD/{*.svd,License.html} $@/ + cp $(BUILDDIR)/com.st.stm32cube.ide.mcu.productdb.debug.jar.version $@/source_file_versions.txt .PHONY: update_xml -update_xml: $(BUILDDIR)/com.st.stm32cube.common.mx.dir - rm -rf mx_mcu_db - mkdir -p mx_mcu_db - cp $</about.html mx_mcu_db/License.html - cp -r $</db/mcu/* mx_mcu_db/ +mx_mcu_db: $(BUILDDIR)/com.st.stm32cube.common.mx.dir + rm -rf $@ + mkdir -p $@ + cp $</about.html $@/License.html + cp -r $</db/mcu/* $@/ + cp $(BUILDDIR)/com.st.stm32cube.common.mx.jar.version $@/source_file_versions.txt -update_prog_db: $(BUILDDIR)/com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.linux64.dir +prog_db: $(BUILDDIR)/com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.linux64.dir + rm -rf $@ + mkdir -p $@ + cp $</about.html $@/License.html + cp $</tools/Data_Base/*.xml $@/ + cp $(BUILDDIR)/com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.linux64.jar.version $@/source_file_versions.txt + +$(BUILDDIR)/STM32CubeMX.unpacked: build/com.st.stm32cube.common.mx.dir + unzip -q -d $@ $</STM32CubeMX.jar -x '/*' + +chip_db: $(BUILDDIR)/STM32CubeMX.unpacked + rm -rf $@ + mkdir -p $@ + cp $</LICENSE.txt $@/ + cp $</devices/* $@/ + cp $(BUILDDIR)/com.st.stm32cube.common.mx.jar.version $@/source_file_versions.txt + +.PHONY: clean +clean: + rm -rf svd + rm -rf mx_mcu_db rm -rf prog_db - mkdir -p prog_db - cp $</about.html prog_db/License.html - cp $</tools/Data_Base/*.xml prog_db/ + rm -rf chip_db + rm -rf build # The following file contains garbage data on the µC's memories. #stm32targets.xml: $(BUILDDIR)/com.st.stm32cube.ide.mcu.productdb.dir diff --git a/tools/do_release.sh b/tools/do_release.sh new file mode 100644 index 0000000..1c692a7 --- /dev/null +++ b/tools/do_release.sh @@ -0,0 +1,73 @@ +#!/bin/sh +set -euo pipefail + +SOURCE_BRANCH=$(git branch --show-current) +MAKE_TAGS_CAUSE=${MAKE_TAGS_CAUSE:-"Manual command-line makefile invocation"} + +GIT_AUTHOR_NAME=${GIT_AUTHOR_NAME:-'STM32Square Auto-Release Script'} +GIT_AUTHOR_EMAIL=${GIT_AUTHOR_EMAIL:-'autorelease@stm32square.jaseg.de'} + +if [ ! -z ${GITLAB_USER_EMAIL+x} ]; then + GIT_COMMITTER_NAME="$GITLAB_USER_NAME" + GIT_COMMITTER_EMAIL="$GITLAB_USER_EMAIL" +fi + +TIMESTAMP=${TIMESTAMP:-$(date +%y-%m-%d)} + +git checkout release +#make clean +git merge -X theirs $SOURCE_BRANCH +git add svd mx_mcu_db prog_db chip_db +git commit --allow-empty -m "STM32Square Auto-Release $TIMESTAMP + +This is an automatic release commit. Generation was invoked from: +$MAKE_TAGS_CAUSE + +Component versions: + +$(cat build/com.st.stm32cube.ide.mcu.productdb.debug.jar.version) +SHA256: $(sha256sum build/com.st.stm32cube.ide.mcu.productdb.debug.jar) + +$(cat build/com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.linux64.jar.version) +SHA256: $(sha256sum build/com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.linux64.jar) + +$(cat build/com.st.stm32cube.common.mx.jar.version) +SHA256: $(sha256sum build/com.st.stm32cube.common.mx.jar)" + +get_version () { + grep "$1 version:" build/$2.jar.version|cut -d: -f2|egrep -o '\S*' +} + +strip_buildid () { + echo "$1"|rev|cut -d. -f2-|rev +} + +IDE_VERSION=$(get_version IDE com.st.stm32cube.common.mx) + +MX_BUILD=$(get_version Artifact com.st.stm32cube.common.mx) +MX_VERSION=$(strip_buildid $MX_BUILD) + +CUBEPROG_BUILD=$(get_version Artifact com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.linux64) +CUBEPROG_VERSION=$(strip_buildid $CUBEPROG_BUILD) + +PRODUCTDB_BUILD=$(get_version Artifact com.st.stm32cube.ide.mcu.productdb.debug) +PRODUCTDB_VERSION=$(strip_buildid $PRODUCTDB_BUILD) + +git tag -a "v-nightly-$TIMESTAMP" -m "Nightly auto-release with tree $(git rev-parse HEAD:)" + +# Ignore failures in the following lines: We only create a tag for each version the first time we see it. +git tag -a "v-ide-$IDE_VERSION" -m "Auto-release for STM32 Cube IDE version $IDE_VERSION" || true + +git tag -a "v-mx-$MX_BUILD" -m "Auto-release for STM32 Cube MX build $MX_BUILD" || true +git tag -a "v-mx-$MX_VERSION" -m "Auto-release for STM32 Cube MX version $MX_VERSION" || true + +git tag -a "v-cubeprog-$CUBEPROG_BUILD" -m "Auto-release for STM32 Cube Programmer build $CUBEPROG_BUILD" || true +git tag -a "v-cubeprog-$CUBEPROG_VERSION" -m "Auto-release for STM32 Cube Programmer version $CUBEPROG_VERSION" || true + +git tag -a "v-productdb-$PRODUCTDB_BUILD" -m "Auto-release for STM32 Product Database build $PRODUCTDB_BUILD" || true +git tag -a "v-productdb-$PRODUCTDB_VERSION" -m "Auto-release for STM32 Product Database version $PRODUCTDB_VERSION" || true + +if [ ! -z ${GITLAB_ACCESS_TOKEN+x} ]; then + git remote add -f ci-origin https://oauth2:${GITLAB_ACCESS_TOKEN}@gitlab.com/${CI_PROJECT_PATH} + git push --tags --force ci-origin master:release +fi diff --git a/tools/get_p2_url.py b/tools/get_p2_url.py index 23b2d0b..f2162cd 100644 --- a/tools/get_p2_url.py +++ b/tools/get_p2_url.py @@ -2,6 +2,7 @@ import requests import re from bs4 import BeautifulSoup +import sys import lzma from urllib.parse import urlparse from contextlib import suppress @@ -37,12 +38,25 @@ if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('-u', '--update-site', default='http://sw-center.st.com/stm32cubeide/updatesite1') parser.add_argument('artifact_id') + parser.add_argument('-v', '--version', action='store_true') + parser.add_argument('--write-version', type=argparse.FileType('w')) args = parser.parse_args() + if args.write_version: + args.version = True + version_file = args.write_version + else: + version_file = sys.stdout + + if args.version: + print(f'[Artifact {args.artifact_id}]', file=version_file) + res = fucked_up_get(f'{args.update_site}/compositeContent.xml') res.raise_for_status() soup = BeautifulSoup(res.content, features='html.parser') latest_version = soup.find('repository')['version'] + if args.version: + print('IDE version:', latest_version, file=version_file) res = fucked_up_get(f'{args.update_site}/{latest_version}/artifacts.xml.xz') res.raise_for_status() @@ -50,9 +64,12 @@ if __name__ == '__main__': artifact = soup.find('artifact', recursive=True, id=args.artifact_id) art_id, art_ver, art_cls = artifact['id'], artifact['version'], artifact['classifier'] + if args.version: + print('Artifact version:', artifact['version'], file=version_file) filename = f'{art_id}_{art_ver}.jar' - url = f'{args.update_site}/{latest_version}/plugins/{filename}' - print(f'{url}') + + if not args.version or args.write_version: + print(f'{url}') |