Merge branch 'main' into merge-to-main
diff --git a/CHANGES.txt b/CHANGES.txt
index 8d7f98a..5f6e297 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,9 +1,34 @@
 Unreleased Changes (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
 
+  PHP
+  * Fix building packaged PHP extension (#9727)
+  * Fixed composer.json to only advertise compatibility with PHP 7.0+.  (#9819)
+
+  Ruby
+  * Disable the aarch64 build on macOS until it can be fixed. (#9816)
+
+  Other
+  * Fix versioning issues in 3.20.0
+
+  C++
+  * Refactor generated message class layout
+  * Optimize tokenizer ParseInteger by removing division
+  * Reserve exactly the right amount of capacity in ExtensionSet::MergeFrom
+
   Compiler
+  * Protoc outputs the list of suggested field numbers when invalid field
+    numbers are specified in the .proto file.
   * Require package names to be less than 512 bytes in length
 
-2022-04-05 version 3.20.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
+  Java
+  * 6x speedup in ArrayEncoder.writeUInt32NotTag
+
+  Python
+  * Added UnknownFieldSet(message) for pure Python. The old
+    message.UnknownFields() will be deprecated after UnknownFieldSet(message) is
+    added for cpp extension.
+
+2022-04-21 version 3.20.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
 
   PHP
   * Fix building packaged PHP extension (#9727)
@@ -11,25 +36,6 @@
   Other
   * Fix versioning issues in 3.20.0
 
-Unreleased Changes
-
-C++
-  * Refactor generated message class layout
-  * Optimize tokenizer ParseInteger by removing division
-  * Reserve exactly the right amount of capacity in ExtensionSet::MergeFrom
-
-Compiler
-  * Protoc outputs the list of suggested field numbers when invalid field
-    numbers are specified in the .proto file.
-
-Java
-  * 6x speedup in ArrayEncoder.writeUInt32NotTag
-
-Python
-  * Added UnknownFieldSet(message) for pure Python. The old
-    message.UnknownFields() will be deprecated after UnknownFieldSet(message) is
-    added for cpp extension.
-
 2022-03-04 version 3.20.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
 
   Ruby
@@ -97,6 +103,8 @@
     JSON serializations with UTF-8 or other non-ASCII encodings.
   * Added experimental support for directly assigning numpy scalars and array.
   * Improve the calculation of public_dependencies in DescriptorPool.
+  * [Breaking Change] Disallow setting fields to numpy singleton arrays or repeated fields to numpy
+    multi-dimensional arrays. Numpy arrays should be indexed or flattened explicitly before assignment.
 
   Compiler
   * Migrate IsDefault(const std::string*) and UnsafeSetDefault(const std::string*)
diff --git a/Makefile.am b/Makefile.am
index 98fd2ef..dcc2107 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -816,10 +816,10 @@
   Protobuf.podspec
 
 php_EXTRA_DIST=                                                       \
-  composer.json                                                       \
   php/README.md                                                       \
   php/REFCOUNTING.md                                                  \
   php/composer.json                                                   \
+  php/composer.json.dist                                              \
   php/ext/google/protobuf/arena.c                                     \
   php/ext/google/protobuf/arena.h                                     \
   php/ext/google/protobuf/array.c                                     \
diff --git a/Protobuf-C++.podspec b/Protobuf-C++.podspec
index a347abe..7804459 100644
--- a/Protobuf-C++.podspec
+++ b/Protobuf-C++.podspec
@@ -1,6 +1,6 @@
 Pod::Spec.new do |s|
   s.name     = 'Protobuf-C++'
-  s.version  = '3.20.1-rc1'
+  s.version  = '3.20.1'
   s.summary  = 'Protocol Buffers v3 runtime library for C++.'
   s.homepage = 'https://github.com/google/protobuf'
   s.license  = 'BSD-3-Clause'
diff --git a/Protobuf.podspec b/Protobuf.podspec
index 6c6b37b..d3d540c 100644
--- a/Protobuf.podspec
+++ b/Protobuf.podspec
@@ -5,7 +5,7 @@
 # dependent projects use the :git notation to refer to the library.
 Pod::Spec.new do |s|
   s.name     = 'Protobuf'
-  s.version  = '3.20.1-rc1'
+  s.version  = '3.20.1'
   s.summary  = 'Protocol Buffers v.3 runtime library for Objective-C.'
   s.homepage = 'https://github.com/protocolbuffers/protobuf'
   s.license  = 'BSD-3-Clause'
diff --git a/configure.ac b/configure.ac
index 5de1ce2..7c5c2c7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,7 +17,7 @@
 # In the SVN trunk, the version should always be the next anticipated release
 # version with the "-pre" suffix.  (We used to use "-SNAPSHOT" but this pushed
 # the size of one file name in the dist tarfile over the 99-char limit.)
-AC_INIT([Protocol Buffers],[3.20.1-rc-1],[protobuf@googlegroups.com],[protobuf])
+AC_INIT([Protocol Buffers],[3.20.1],[protobuf@googlegroups.com],[protobuf])
 
 AM_MAINTAINER_MODE([enable])
 
diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec
index 29b698e..1d34a5e 100644
--- a/csharp/Google.Protobuf.Tools.nuspec
+++ b/csharp/Google.Protobuf.Tools.nuspec
@@ -5,7 +5,7 @@
     <title>Google Protocol Buffers tools</title>
     <summary>Tools for Protocol Buffers - Google's data interchange format.</summary>
     <description>See project site for more info.</description>
-    <version>3.20.1-rc1</version>
+    <version>3.20.1</version>
     <authors>Google Inc.</authors>
     <owners>protobuf-packages</owners>
     <licenseUrl>https://github.com/protocolbuffers/protobuf/blob/main/LICENSE</licenseUrl>
diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj
index 14a83a0..79af7f3 100644
--- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj
+++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj
@@ -4,7 +4,7 @@
     <Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description>
     <Copyright>Copyright 2015, Google Inc.</Copyright>
     <AssemblyTitle>Google Protocol Buffers</AssemblyTitle>
-    <VersionPrefix>3.20.1-rc1</VersionPrefix>
+    <VersionPrefix>3.20.1</VersionPrefix>
     <!-- C# 7.2 is required for Span/BufferWriter/ReadOnlySequence -->
     <LangVersion>7.2</LangVersion>
     <Authors>Google Inc.</Authors>
diff --git a/java/README.md b/java/README.md
index 34b5437..c5c0bfa 100644
--- a/java/README.md
+++ b/java/README.md
@@ -23,7 +23,7 @@
 <dependency>
   <groupId>com.google.protobuf</groupId>
   <artifactId>protobuf-java</artifactId>
-  <version>3.20.1-rc-1</version>
+  <version>3.20.1</version>
 </dependency>
 ```
 
@@ -37,7 +37,7 @@
 <dependency>
   <groupId>com.google.protobuf</groupId>
   <artifactId>protobuf-java-util</artifactId>
-  <version>3.20.1-rc-1</version>
+  <version>3.20.1</version>
 </dependency>
 ```
 
@@ -45,7 +45,7 @@
 
 If you are using Gradle, add the following to your `build.gradle` file's dependencies:
 ```
-    implementation 'com.google.protobuf:protobuf-java:3.20.1-rc-1'
+    implementation 'com.google.protobuf:protobuf-java:3.20.1'
 ```
 Again, be sure to check that the version number matches (or is newer than) the version number of protoc that you are using.
 
diff --git a/java/bom/pom.xml b/java/bom/pom.xml
index fa31209..045dc28 100644
--- a/java/bom/pom.xml
+++ b/java/bom/pom.xml
@@ -4,7 +4,7 @@
 
   <groupId>com.google.protobuf</groupId>
   <artifactId>protobuf-bom</artifactId>
-  <version>3.20.1-rc-1</version>
+  <version>3.20.1</version>
   <packaging>pom</packaging>
 
   <name>Protocol Buffers [BOM]</name>
diff --git a/java/core/pom.xml b/java/core/pom.xml
index 7fd02c5..bc0726c 100644
--- a/java/core/pom.xml
+++ b/java/core/pom.xml
@@ -4,7 +4,7 @@
   <parent>
     <groupId>com.google.protobuf</groupId>
     <artifactId>protobuf-parent</artifactId>
-    <version>3.20.1-rc-1</version>
+    <version>3.20.1</version>
   </parent>
 
   <artifactId>protobuf-java</artifactId>
diff --git a/java/kotlin-lite/pom.xml b/java/kotlin-lite/pom.xml
index 2f2ddb6..d0ef96d 100644
--- a/java/kotlin-lite/pom.xml
+++ b/java/kotlin-lite/pom.xml
@@ -4,7 +4,7 @@
   <parent>
     <groupId>com.google.protobuf</groupId>
     <artifactId>protobuf-parent</artifactId>
-    <version>3.20.1-rc-1</version>
+    <version>3.20.1</version>
   </parent>
 
   <artifactId>protobuf-kotlin-lite</artifactId>
diff --git a/java/kotlin/pom.xml b/java/kotlin/pom.xml
index d16a1e4..591c4ae 100644
--- a/java/kotlin/pom.xml
+++ b/java/kotlin/pom.xml
@@ -4,7 +4,7 @@
   <parent>
     <groupId>com.google.protobuf</groupId>
     <artifactId>protobuf-parent</artifactId>
-    <version>3.20.1-rc-1</version>
+    <version>3.20.1</version>
   </parent>
 
   <artifactId>protobuf-kotlin</artifactId>
diff --git a/java/lite.md b/java/lite.md
index 759d50b..0620a66 100644
--- a/java/lite.md
+++ b/java/lite.md
@@ -29,7 +29,7 @@
 <dependency>
   <groupId>com.google.protobuf</groupId>
   <artifactId>protobuf-javalite</artifactId>
-  <version>3.20.1-rc-1</version>
+  <version>3.20.1</version>
 </dependency>
 ```
 
diff --git a/java/lite/pom.xml b/java/lite/pom.xml
index a2444f0..8055508 100644
--- a/java/lite/pom.xml
+++ b/java/lite/pom.xml
@@ -4,7 +4,7 @@
   <parent>
     <groupId>com.google.protobuf</groupId>
     <artifactId>protobuf-parent</artifactId>
-    <version>3.20.1-rc-1</version>
+    <version>3.20.1</version>
   </parent>
 
   <artifactId>protobuf-javalite</artifactId>
diff --git a/java/pom.xml b/java/pom.xml
index b3ef5a3..3c44917 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -4,7 +4,7 @@
 
   <groupId>com.google.protobuf</groupId>
   <artifactId>protobuf-parent</artifactId>
-  <version>3.20.1-rc-1</version>
+  <version>3.20.1</version>
   <packaging>pom</packaging>
 
   <name>Protocol Buffers [Parent]</name>
diff --git a/java/util/pom.xml b/java/util/pom.xml
index 75b50aa..cd5f96e 100644
--- a/java/util/pom.xml
+++ b/java/util/pom.xml
@@ -4,7 +4,7 @@
   <parent>
     <groupId>com.google.protobuf</groupId>
     <artifactId>protobuf-parent</artifactId>
-    <version>3.20.1-rc-1</version>
+    <version>3.20.1</version>
   </parent>
 
   <artifactId>protobuf-java-util</artifactId>
diff --git a/js/package.json b/js/package.json
index 555d057..f3c0e72 100644
--- a/js/package.json
+++ b/js/package.json
@@ -1,6 +1,6 @@
 {
   "name": "google-protobuf",
-  "version": "3.20.1-rc.1",
+  "version": "3.20.1",
   "description": "Protocol Buffers for JavaScript",
   "main": "google-protobuf.js",
   "files": [
diff --git a/kokoro/release/ruby/macos/ruby/ruby_build_environment.sh b/kokoro/release/ruby/macos/ruby/ruby_build_environment.sh
index c3fcd3c..2a9cb16 100755
--- a/kokoro/release/ruby/macos/ruby/ruby_build_environment.sh
+++ b/kokoro/release/ruby/macos/ruby/ruby_build_environment.sh
@@ -91,7 +91,8 @@
 for v in 3.1.0 ; do
   ccache -c
   rake -f "$CROSS_RUBY31" cross-ruby VERSION="$v" HOST=x86_64-darwin MAKE="$MAKE"
-  rake -f "$CROSS_RUBY31" cross-ruby VERSION="$v" HOST=aarch64-darwin MAKE="$MAKE"
+  # Disabled until it can be fixed: https://github.com/protocolbuffers/protobuf/issues/9804
+  # rake -f "$CROSS_RUBY31" cross-ruby VERSION="$v" HOST=aarch64-darwin MAKE="$MAKE"
 done
 
 set +x # rvm commands are very verbose
@@ -101,7 +102,8 @@
 for v in 3.0.0 2.7.0 ; do
   ccache -c
   rake -f "$CROSS_RUBY" cross-ruby VERSION="$v" HOST=x86_64-darwin MAKE="$MAKE"
-  rake -f "$CROSS_RUBY" cross-ruby VERSION="$v" HOST=aarch64-darwin MAKE="$MAKE"
+  # Disabled until it can be fixed: https://github.com/protocolbuffers/protobuf/issues/9804
+  # rake -f "$CROSS_RUBY" cross-ruby VERSION="$v" HOST=aarch64-darwin MAKE="$MAKE"
 done
 set +x
 rvm use 2.5.0
@@ -110,7 +112,8 @@
 for v in 2.6.0 2.5.1; do
   ccache -c
   rake -f "$CROSS_RUBY" cross-ruby VERSION="$v" HOST=x86_64-darwin MAKE="$MAKE"
-  rake -f "$CROSS_RUBY" cross-ruby VERSION="$v" HOST=aarch64-darwin MAKE="$MAKE"
+  # Disabled until it can be fixed: https://github.com/protocolbuffers/protobuf/issues/9804
+  # rake -f "$CROSS_RUBY" cross-ruby VERSION="$v" HOST=aarch64-darwin MAKE="$MAKE"
 done
 set +x
 rvm use 2.7.0
diff --git a/composer.json b/php/composer.json.dist
similarity index 66%
rename from composer.json
rename to php/composer.json.dist
index 2c64ad2..70af0a0 100644
--- a/composer.json
+++ b/php/composer.json.dist
@@ -6,18 +6,18 @@
   "homepage": "https://developers.google.com/protocol-buffers/",
   "license": "BSD-3-Clause",
   "require": {
-    "php": ">=5.5.0"
+    "php": ">=7.0.0"
   },
   "require-dev": {
-    "phpunit/phpunit": ">=4.8.0"
+    "phpunit/phpunit": ">=5.0.0"
   },
   "suggest": {
     "ext-bcmath": "Need to support JSON deserialization"
   },
   "autoload": {
     "psr-4": {
-      "Google\\Protobuf\\": "php/src/Google/Protobuf",
-      "GPBMetadata\\Google\\Protobuf\\": "php/src/GPBMetadata/Google/Protobuf"
+      "Google\\Protobuf\\": "src/Google/Protobuf",
+      "GPBMetadata\\Google\\Protobuf\\": "src/GPBMetadata/Google/Protobuf"
     }
   }
 }
diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml
index 77cee35..0acb23c 100644
--- a/php/ext/google/protobuf/package.xml
+++ b/php/ext/google/protobuf/package.xml
@@ -10,10 +10,10 @@
   <email>protobuf-opensource@google.com</email>
   <active>yes</active>
  </lead>
- <date>2022-04-05</date>
- <time>17:06:47</time>
+ <date>2022-04-20</date>
+ <time>22:01:25</time>
  <version>
-  <release>3.20.1RC1</release>
+  <release>3.20.1</release>
   <api>3.20.1</api>
  </version>
  <stability>
@@ -1268,5 +1268,20 @@
    <notes>
    </notes>
   </release>
+  <release>
+   <version>
+    <release>3.20.1</release>
+    <api>3.20.1</api>
+   </version>
+   <stability>
+    <release>stable</release>
+    <api>stable</api>
+   </stability>
+   <date>2022-04-20</date>
+   <time>22:01:25</time>
+   <license uri="https://opensource.org/licenses/BSD-3-Clause">BSD-3-Clause</license>
+   <notes>
+   </notes>
+  </release>
  </changelog>
 </package>
diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h
index f20e8ee..97adedb 100644
--- a/php/ext/google/protobuf/protobuf.h
+++ b/php/ext/google/protobuf/protobuf.h
@@ -127,7 +127,7 @@
   ZEND_ARG_INFO(0, value)
 ZEND_END_ARG_INFO()
 
-#define PHP_PROTOBUF_VERSION "3.20.1RC1"
+#define PHP_PROTOBUF_VERSION "3.20.1"
 
 // ptr -> PHP object cache. This is a weak map that caches lazily-created
 // wrapper objects around upb types:
diff --git a/php/release.sh b/php/release.sh
index 9a4b139..f75906a 100755
--- a/php/release.sh
+++ b/php/release.sh
@@ -10,24 +10,17 @@
 
 VERSION=$1
 
+rm -rf protobuf-php
 git clone https://github.com/protocolbuffers/protobuf-php.git
-git clone https://github.com/protocolbuffers/protobuf.git
 
 # Clean old files
-pushd protobuf-php
-rm -rf src
-popd
-
-# Checkout the target version
-pushd protobuf/php
-git checkout -b $VERSION
-popd
+rm -rf protobuf-php/src
 
 # Copy files
-pushd protobuf-php
-mv ../protobuf/php/src src
-mv ../protobuf/composer.json composer.json
-sed -i 's|php/src|src|g' composer.json
+cp -r php/src protobuf-php
+cp php/composer.json.dist protobuf-php/composer.json
+
+cd protobuf-php
 git add .
 git commit -m "$VERSION"
 if [ $(git tag -l "$VERSION") ]; then
@@ -35,7 +28,3 @@
 else
   git tag "$VERSION"
 fi
-popd
-
-# Clean up
-rm -rf protobuf
diff --git a/protobuf_version.bzl b/protobuf_version.bzl
index 404a643..98cf837 100644
--- a/protobuf_version.bzl
+++ b/protobuf_version.bzl
@@ -1 +1 @@
-PROTOBUF_VERSION = '3.20.1-rc-1'
+PROTOBUF_VERSION = '3.20.1'
diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml
index 31f7b85..e03216b 100644
--- a/protoc-artifacts/pom.xml
+++ b/protoc-artifacts/pom.xml
@@ -8,7 +8,7 @@
   </parent>
   <groupId>com.google.protobuf</groupId>
   <artifactId>protoc</artifactId>
-  <version>3.20.1-rc-1</version>
+  <version>3.20.1</version>
   <packaging>pom</packaging>
   <name>Protobuf Compiler</name>
   <description>
diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py
index 3cacc4f..03f3b29 100644
--- a/python/google/protobuf/__init__.py
+++ b/python/google/protobuf/__init__.py
@@ -30,4 +30,4 @@
 
 # Copyright 2007 Google Inc. All Rights Reserved.
 
-__version__ = '3.20.1rc1'
+__version__ = '3.20.1'
diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec
index 3197368..cd7aaaa 100644
--- a/ruby/google-protobuf.gemspec
+++ b/ruby/google-protobuf.gemspec
@@ -1,6 +1,6 @@
 Gem::Specification.new do |s|
   s.name        = "google-protobuf"
-  s.version     = "3.20.1.rc.1"
+  s.version     = "3.20.1"
   git_tag       = "v#{s.version.to_s.sub('.rc.', '-rc')}" # Converts X.Y.Z.rc.N to vX.Y.Z-rcN, used for the git tag
   s.licenses    = ["BSD-3-Clause"]
   s.summary     = "Protocol Buffers"
diff --git a/ruby/pom.xml b/ruby/pom.xml
index de421ef..0e7c3fd 100644
--- a/ruby/pom.xml
+++ b/ruby/pom.xml
@@ -9,7 +9,7 @@
 
     <groupId>com.google.protobuf.jruby</groupId>
     <artifactId>protobuf-jruby</artifactId>
-    <version>3.20.1-rc-1</version>
+    <version>3.20.1</version>
     <name>Protocol Buffer JRuby native extension</name>
     <description>
       Protocol Buffers are a way of encoding structured data in an efficient yet
@@ -76,7 +76,7 @@
         <dependency>
           <groupId>com.google.protobuf</groupId>
           <artifactId>protobuf-java-util</artifactId>
-          <version>3.20.1-rc-1</version>
+          <version>3.20.1</version>
         </dependency>
         <dependency>
             <groupId>org.jruby</groupId>
diff --git a/ruby/src/main/java/com/google/protobuf/jruby/RubyDescriptor.java b/ruby/src/main/java/com/google/protobuf/jruby/RubyDescriptor.java
index b809253..c09fe92 100644
--- a/ruby/src/main/java/com/google/protobuf/jruby/RubyDescriptor.java
+++ b/ruby/src/main/java/com/google/protobuf/jruby/RubyDescriptor.java
@@ -215,8 +215,8 @@
     klass.include(new IRubyObject[] {messageExts});
     klass.instance_variable_set(runtime.newString(Utils.DESCRIPTOR_INSTANCE_VAR), this);
     klass.defineAnnotatedMethods(RubyMessage.class);
-    // Workaround for https://github.com/jruby/jruby/issues/7154
-    klass.searchMethod("respond_to?").setIsBuiltin(false);
+        // Workaround for https://github.com/jruby/jruby/issues/7154
+        klass.searchMethod("respond_to?").setIsBuiltin(false);
     return klass;
   }
 
diff --git a/ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.java b/ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.java
index 301b957..1e949a5 100644
--- a/ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.java
+++ b/ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.java
@@ -860,6 +860,7 @@
               this.builder.getDescriptorForType().findFieldByName(TYPE);
           if (typeBytesSymbol.equals(fields.get(enumFieldDescriptorForType))) {
             isDefaultStringForBytes = true;
+                    }
           }
         }
         builder.setField(