1# Licensed to the Apache Software Foundation (ASF) under one
2# or more contributor license agreements.  See the NOTICE file
3# distributed with this work for additional information
4# regarding copyright ownership.  The ASF licenses this file
5# to you under the Apache License, Version 2.0 (the
6# "License"); you may not use this file except in compliance
7# with the License.  You may obtain a copy of the License at
8#
9#   http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing,
12# software distributed under the License is distributed on an
13# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14# KIND, either express or implied.  See the License for the
15# specific language governing permissions and limitations
16# under the License.
17
18ARROW_DIR="${SOURCE_DIR}/../.."
19
20update_versions() {
21  local base_version=$1
22  local next_version=$2
23  local type=$3
24
25  case ${type} in
26    release)
27      local version=${base_version}
28      local r_version=${base_version}
29      ;;
30    snapshot)
31      local version=${next_version}-SNAPSHOT
32      local r_version=${base_version}.9000
33      ;;
34  esac
35
36  pushd "${ARROW_DIR}/c_glib"
37  sed -i.bak -E -e \
38    "s/^version = '.+'/version = '${version}'/" \
39    meson.build
40  rm -f meson.build.bak
41  git add meson.build
42  popd
43
44  pushd "${ARROW_DIR}/ci/scripts"
45  sed -i.bak -E -e \
46    "s/^pkgver=.+/pkgver=${r_version}/" \
47    PKGBUILD
48  rm -f PKGBUILD.bak
49  git add PKGBUILD
50  popd
51
52  pushd "${ARROW_DIR}/cpp"
53  sed -i.bak -E -e \
54    "s/^set\(ARROW_VERSION \".+\"\)/set(ARROW_VERSION \"${version}\")/" \
55    CMakeLists.txt
56  rm -f CMakeLists.txt.bak
57  git add CMakeLists.txt
58
59  sed -i.bak -E -e \
60    "s/\"version-string\": \".+\"/\"version-string\": \"${version}\"/" \
61    vcpkg.json
62  rm -f vcpkg.json.bak
63  git add vcpkg.json
64  popd
65
66  pushd "${ARROW_DIR}/java"
67  mvn versions:set -DnewVersion=${version}
68  find . -type f -name pom.xml.versionsBackup -delete
69  git add "pom.xml"
70  git add "**/pom.xml"
71  popd
72
73  pushd "${ARROW_DIR}/csharp"
74  sed -i.bak -E -e \
75    "s/^    <Version>.+<\/Version>/    <Version>${version}<\/Version>/" \
76    Directory.Build.props
77  rm -f Directory.Build.props.bak
78  git add Directory.Build.props
79  popd
80
81  pushd "${ARROW_DIR}/dev/tasks/homebrew-formulae"
82  sed -i.bak -E -e \
83    "s/arrow-[0-9.]+[0-9]+/arrow-${r_version}/g" \
84    autobrew/apache-arrow.rb
85  rm -f autobrew/apache-arrow.rb.bak
86  git add autobrew/apache-arrow.rb
87  sed -i.bak -E -e \
88    "s/arrow-[0-9.\-]+[0-9SNAPHOT]+/arrow-${version}/g" \
89    apache-arrow.rb
90  rm -f apache-arrow.rb.bak
91  git add apache-arrow.rb
92  popd
93
94  pushd "${ARROW_DIR}/js"
95  sed -i.bak -E -e \
96    "s/^  \"version\": \".+\"/  \"version\": \"${version}\"/" \
97    package.json
98  rm -f package.json.bak
99  git add package.json
100  popd
101
102  pushd "${ARROW_DIR}/matlab"
103  sed -i.bak -E -e \
104    "s/^set\(MLARROW_VERSION \".+\"\)/set(MLARROW_VERSION \"${version}\")/" \
105    CMakeLists.txt
106  rm -f CMakeLists.txt.bak
107  git add CMakeLists.txt
108  popd
109
110  pushd "${ARROW_DIR}/python"
111  sed -i.bak -E -e \
112    "s/^default_version = '.+'/default_version = '${version}'/" \
113    setup.py
114  rm -f setup.py.bak
115  git add setup.py
116  popd
117
118  pushd "${ARROW_DIR}/r"
119  sed -i.bak -E -e \
120    "s/^Version: .+/Version: ${r_version}/" \
121    DESCRIPTION
122  rm -f DESCRIPTION.bak
123  git add DESCRIPTION
124  # Replace dev version with release version
125  sed -i.bak -E -e \
126    "0,/^# arrow /s/^# arrow .+/# arrow ${base_version}/" \
127    NEWS.md
128  if [ ${type} = "snapshot" ]; then
129    # Add a news entry for the new dev version
130    sed -i.bak -E -e \
131      "0,/^# arrow /s/^(# arrow .+)/# arrow ${r_version}\n\n\1/" \
132      NEWS.md
133  fi
134  rm -f NEWS.md.bak
135  git add NEWS.md
136  popd
137
138  pushd "${ARROW_DIR}/ruby"
139  sed -i.bak -E -e \
140    "s/^  VERSION = \".+\"/  VERSION = \"${version}\"/g" \
141    */*/*/version.rb
142  rm -f */*/*/version.rb.bak
143  git add */*/*/version.rb
144  popd
145}
146