aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2020-11-18 13:21:38 +0100
committerjaseg <git@jaseg.de>2020-11-18 13:21:38 +0100
commit0a678f936b569bbc2dc36c745bb966bc3cee061e (patch)
treee7a8ad40ac56d86082f39a130fe7b7b2a50d986c /tools
parent43d49d978ea441e0987eda471ba5744a74ee3c79 (diff)
downloadstm32square-0a678f936b569bbc2dc36c745bb966bc3cee061e.tar.gz
stm32square-0a678f936b569bbc2dc36c745bb966bc3cee061e.tar.bz2
stm32square-0a678f936b569bbc2dc36c745bb966bc3cee061e.zip
Add auto-release infrastructure
Diffstat (limited to 'tools')
-rw-r--r--tools/do_release.sh73
-rw-r--r--tools/get_p2_url.py21
2 files changed, 92 insertions, 2 deletions
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}')