xref: /aosp_15_r20/external/cpu_features/scripts/make_release.sh (revision eca53ba6d2e951e174b64682eaf56a36b8204c89)
1*eca53ba6SRoland Levillain#!/usr/bin/env bash
2*eca53ba6SRoland Levillain
3*eca53ba6SRoland Levillainset -e # Fail on error
4*eca53ba6SRoland Levillainset -u # Treat unset variables as an error and exit immediately
5*eca53ba6SRoland Levillain
6*eca53ba6SRoland LevillainACTION='\033[1;90m'
7*eca53ba6SRoland LevillainFINISHED='\033[1;96m'
8*eca53ba6SRoland LevillainNOCOLOR='\033[0m'
9*eca53ba6SRoland LevillainERROR='\033[0;31m'
10*eca53ba6SRoland Levillain
11*eca53ba6SRoland Levillainecho -e "${ACTION}Checking environnement${NOCOLOR}"
12*eca53ba6SRoland Levillainif [[ ! $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
13*eca53ba6SRoland Levillainthen
14*eca53ba6SRoland Levillain    echo -e "${ERROR}Invalid version number. Aborting. ${NOCOLOR}"
15*eca53ba6SRoland Levillain    exit 1
16*eca53ba6SRoland Levillainfi
17*eca53ba6SRoland Levillain
18*eca53ba6SRoland Levillaindeclare -r VERSION=$1
19*eca53ba6SRoland Levillaindeclare -r GIT_TAG="v$1"
20*eca53ba6SRoland Levillain
21*eca53ba6SRoland LevillainBRANCH=$(git rev-parse --abbrev-ref HEAD)
22*eca53ba6SRoland Levillainif [[ "${BRANCH}" != "main" ]]
23*eca53ba6SRoland Levillainthen
24*eca53ba6SRoland Levillain    echo -e "${ERROR}Not on main. Aborting. ${NOCOLOR}"
25*eca53ba6SRoland Levillain    echo
26*eca53ba6SRoland Levillain    exit 1
27*eca53ba6SRoland Levillainfi
28*eca53ba6SRoland Levillain
29*eca53ba6SRoland Levillaingit fetch
30*eca53ba6SRoland LevillainHEADHASH=$(git rev-parse HEAD)
31*eca53ba6SRoland LevillainUPSTREAMHASH=$(git rev-parse main@{upstream})
32*eca53ba6SRoland Levillain
33*eca53ba6SRoland Levillainif [[ "${HEADHASH}" != "${UPSTREAMHASH}" ]]
34*eca53ba6SRoland Levillainthen
35*eca53ba6SRoland Levillain    echo -e "${ERROR}Not up to date with origin. Aborting.${NOCOLOR}"
36*eca53ba6SRoland Levillain    echo
37*eca53ba6SRoland Levillain    exit 1
38*eca53ba6SRoland Levillainfi
39*eca53ba6SRoland Levillain
40*eca53ba6SRoland Levillaingit update-index -q --refresh
41*eca53ba6SRoland Levillainif ! git diff-index --quiet HEAD --
42*eca53ba6SRoland Levillainthen
43*eca53ba6SRoland Levillain    echo -e "${ERROR}Branch has uncommited changes. Aborting.${NOCOLOR}"
44*eca53ba6SRoland Levillain    exit 1
45*eca53ba6SRoland Levillainfi
46*eca53ba6SRoland Levillain
47*eca53ba6SRoland Levillainif [ ! -z "$(git ls-files --exclude-standard --others)" ]
48*eca53ba6SRoland Levillainthen
49*eca53ba6SRoland Levillain    echo -e "${ERROR}Branch has untracked files. Aborting.${NOCOLOR}"
50*eca53ba6SRoland Levillain    exit 1
51*eca53ba6SRoland Levillainfi
52*eca53ba6SRoland Levillain
53*eca53ba6SRoland Levillaindeclare -r LATEST_GIT_TAG=$(git describe --tags --abbrev=0)
54*eca53ba6SRoland Levillaindeclare -r LATEST_VERSION=${LATEST_GIT_TAG#"v"}
55*eca53ba6SRoland Levillain
56*eca53ba6SRoland Levillainif ! dpkg --compare-versions "${VERSION}" "gt" "${LATEST_VERSION}"
57*eca53ba6SRoland Levillainthen
58*eca53ba6SRoland Levillain    echo -e "${ERROR}Invalid version ${VERSION} <= ${LATEST_VERSION} (latest). Aborting.${NOCOLOR}"
59*eca53ba6SRoland Levillain    exit 1
60*eca53ba6SRoland Levillainfi
61*eca53ba6SRoland Levillain
62*eca53ba6SRoland Levillainecho -e "${ACTION}Modifying CMakeLists.txt${NOCOLOR}"
63*eca53ba6SRoland Levillainsed -i "s/CpuFeatures VERSION ${LATEST_VERSION}/CpuFeatures VERSION ${VERSION}/g" CMakeLists.txt
64*eca53ba6SRoland Levillain
65*eca53ba6SRoland Levillainecho -e "${ACTION}Commit new revision${NOCOLOR}"
66*eca53ba6SRoland Levillaingit add CMakeLists.txt
67*eca53ba6SRoland Levillaingit commit -m"Release ${GIT_TAG}"
68*eca53ba6SRoland Levillain
69*eca53ba6SRoland Levillainecho -e "${ACTION}Create new tag${NOCOLOR}"
70*eca53ba6SRoland Levillaingit tag ${GIT_TAG}
71*eca53ba6SRoland Levillain
72*eca53ba6SRoland Levillainecho -e "${FINISHED}Manual steps:${NOCOLOR}"
73*eca53ba6SRoland Levillainecho -e "${FINISHED} - Push the tag upstream 'git push origin ${GIT_TAG}'${NOCOLOR}"
74*eca53ba6SRoland Levillainecho -e "${FINISHED} - Create a new release https://github.com/google/cpu_features/releases/new${NOCOLOR}"
75*eca53ba6SRoland Levillainecho -e "${FINISHED} - Update the Release Notes 'gren release --override'${NOCOLOR}"
76