|
| 1 | +#!/usr/bin/env -S bash -e |
| 2 | + |
| 3 | + |
| 4 | +function usage() { |
| 5 | + echo "Usage:" |
| 6 | + echo |
| 7 | + echo " $0 [options] <project> <release_version>" |
| 8 | + echo |
| 9 | + echo " <project> One of [search,validator,ogm,orm]" |
| 10 | + echo " <release_version> The version to release (e.g. 6.0.1)" |
| 11 | + echo |
| 12 | + echo " Options" |
| 13 | + echo |
| 14 | + echo " -h Show this help and exit." |
| 15 | + echo " -d Dry run; do not push, deploy or publish anything." |
| 16 | +} |
| 17 | + |
| 18 | +#-------------------------------------------- |
| 19 | +# Option parsing |
| 20 | + |
| 21 | +function exec_or_dry_run() { |
| 22 | + "${@}" |
| 23 | +} |
| 24 | +PUSH_CHANGES=true |
| 25 | + |
| 26 | +while getopts 'dhb:' opt; do |
| 27 | + case "$opt" in |
| 28 | + h) |
| 29 | + usage |
| 30 | + exit 0 |
| 31 | + ;; |
| 32 | + d) |
| 33 | + # Dry run |
| 34 | + echo "DRY RUN: will not push/deploy/publish anything." |
| 35 | + PUSH_CHANGES=false |
| 36 | + function exec_or_dry_run() { |
| 37 | + echo "DRY RUN; would have executed:" "${@}" |
| 38 | + } |
| 39 | + ;; |
| 40 | + \?) |
| 41 | + usage |
| 42 | + exit 1 |
| 43 | + ;; |
| 44 | + esac |
| 45 | +done |
| 46 | + |
| 47 | +shift $((OPTIND - 1)) |
| 48 | + |
| 49 | +SCRIPTS_DIR="$(readlink -f ${BASH_SOURCE[0]} | xargs dirname)" |
| 50 | + |
| 51 | +PROJECT=$1 |
| 52 | +RELEASE_VERSION=$2 |
| 53 | +WORKSPACE=${WORKSPACE:-'.'} |
| 54 | + |
| 55 | +if [ -z "$PROJECT" ]; then |
| 56 | + echo "ERROR: Project not supplied" |
| 57 | + exit 1 |
| 58 | +fi |
| 59 | +if [ -z "$RELEASE_VERSION" ]; then |
| 60 | + echo "ERROR: Release version argument not supplied" |
| 61 | + exit 1 |
| 62 | +fi |
| 63 | + |
| 64 | +if [ "$PROJECT" == "search" ]; then |
| 65 | + JIRA_KEY="HSEARCH" |
| 66 | + PROJECT_NAME="Search" |
| 67 | +elif [ "$PROJECT" == "validator" ]; then |
| 68 | + JIRA_KEY="HV" |
| 69 | + PROJECT_NAME="Validator" |
| 70 | +elif [ "$PROJECT" == "ogm" ]; then |
| 71 | + JIRA_KEY="OGM" |
| 72 | + PROJECT_NAME="OGM" |
| 73 | +elif [ "$PROJECT" == "orm" ]; then |
| 74 | + JIRA_KEY="HHH" |
| 75 | + PROJECT_NAME="ORM" |
| 76 | +elif [ "$PROJECT" == "reactive" ]; then |
| 77 | + JIRA_KEY="HREACT" |
| 78 | + PROJECT_NAME="Reactive" |
| 79 | +else |
| 80 | + echo "ERROR: Unknown project name $PROJECT" |
| 81 | + usage |
| 82 | + exit 1 |
| 83 | +fi |
| 84 | + |
| 85 | +RELEASE_VERSION_FAMILY=$(echo "$RELEASE_VERSION" | sed -E 's/^([0-9]+\.[0-9]+).*/\1/') |
| 86 | +RELEASE_VERSION_BASIS=$(echo "$RELEASE_VERSION" | sed -E 's/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/') |
| 87 | + |
| 88 | +if [ "$PUSH_CHANGES" == 'true' ] && [ -z "$GITHUB_API_TOKEN" ]; then |
| 89 | + echo "ERROR: Environment variable GITHUB_API_TOKEN must not be empty" |
| 90 | + exit 1 |
| 91 | +fi |
| 92 | + |
| 93 | +docsUrl="https://docs.jboss.org/hibernate/orm/${RELEASE_VERSION_FAMILY}" |
| 94 | +javadocsUrl="${docsUrl}/javadocs" |
| 95 | +migrationGuideUrl="${docsUrl}/migration-guide/migration-guide.html" |
| 96 | +introGuideUrl="${docsUrl}/introduction/html_single/Hibernate_Introduction.html" |
| 97 | +userGuideUrl="${docsUrl}/userguide/html_single/Hibernate_User_Guide.html" |
| 98 | + |
| 99 | +releaseName="Hibernate ${PROJECT_NAME} ${RELEASE_VERSION}" |
| 100 | +releaseBody="""\ |
| 101 | +# Hibernate ${PROJECT_NAME} ${RELEASE_VERSION} released |
| 102 | +
|
| 103 | +Today, we published a new maintenance release of Hibernate ${PROJECT_NAME} ${RELEASE_VERSION_FAMILY}: ${RELEASE_VERSION}. |
| 104 | +
|
| 105 | +## What's new |
| 106 | +
|
| 107 | +This release introduces a few minor improvements as well as bug fixes. |
| 108 | +
|
| 109 | +You can find the full list of ${RELEASE_VERSION} changes [here](https://hibernate.atlassian.net/issues/?jql=project%20%3D%20${JIRA_KEY}%20AND%20fixVersion%20%3D%20${RELEASE_VERSION_BASIS}). |
| 110 | +
|
| 111 | +## Conclusion |
| 112 | +
|
| 113 | +For additional details, see: |
| 114 | +
|
| 115 | +- the [release page](https://hibernate.org/orm/releases/${RELEASE_VERSION_FAMILY}/) |
| 116 | +- the [Migration Guide](${migrationGuideUrl}) |
| 117 | +- the [Introduction Guide](${introGuideUrl}) |
| 118 | +- the [User Guide](${userGuideUrl}) |
| 119 | +
|
| 120 | +See also the following resources related to supported APIs: |
| 121 | +
|
| 122 | +- the [compatibility policy](https://hibernate.org/community/compatibility-policy/) |
| 123 | +- the [incubating API report](${docsUrl}/incubating/incubating.txt) (\`@Incubating\`) |
| 124 | +- the [deprecated API report](${docsUrl}/deprecated/deprecated.txt) (\`@Deprecated\` + \`@Remove\`) |
| 125 | +- the [internal API report](${docsUrl}/internals/internal.txt) (internal packages, \`@Internal\`) |
| 126 | +
|
| 127 | +Visit the [website](https://hibernate.org/community/) for details on getting in touch with us.""" |
| 128 | + |
| 129 | +response=$(exec_or_dry_run curl -L -s -w "\n%{http_code}" -X POST \ |
| 130 | + -H 'Accept: application/vnd.github+json' \ |
| 131 | + -H 'X-GitHub-Api-Version: 2022-11-28' \ |
| 132 | + -H "Authorization: Bearer \$GITHUB_API_TOKEN" \ |
| 133 | + -d '{"tag_name":"'${RELEASE_VERSION}'","name":"'${releaseName}'","make_latest":"legacy","body":"'${releaseBody}'"}' \ |
| 134 | + 'https://api.github.com/repos/hibernate/hibernate-orm/releases') |
| 135 | + |
| 136 | +if [ "$PUSH_CHANGES" == true ]; then |
| 137 | + githubCreateReleaseResponseCode=$(tail -n1 <<< "$response") # get the last line |
| 138 | + githubCreateReleaseResponse=$(sed '$ d' <<< "$response") # get all but the last line which contains the status code |
| 139 | + |
| 140 | + if [ "$githubCreateReleaseResponseCode" != 201 ]; then |
| 141 | + echo "$githubCreateReleaseResponse" |
| 142 | + echo "ERROR: Release failed because GitHub release could not be created" |
| 143 | + exit 1 |
| 144 | + fi |
| 145 | +else |
| 146 | + echo $response |
| 147 | +fi |
0 commit comments