aboutsummaryrefslogtreecommitdiff
path: root/tools/do_release.sh
blob: e282a55b2431b5d781e56b1c59b98adb72b9efc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/sh
set -euo pipefail

SOURCE_BRANCH=$(git branch --show-current)
RELEASE_TRIGGER=${RELEASE_TRIGGER:-"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:
$RELEASE_TRIGGER

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