//
//  Licensed to the Apache Software Foundation (ASF) under one or more
//  contributor license agreements.  See the NOTICE file distributed with
//  this work for additional information regarding copyright ownership.
//  The ASF licenses this file to You under the Apache License, Version 2.0
//  (the "License"); you may not use this file except in compliance with
//  the License.  You may obtain a copy of the License at
//
//      https://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
//
:imagesdir: ../images/
:icons: font

= Validating a staged release



TIP: On MacOS and Linux the first 4 steps can be automated. For details please read the section about tooling after this chapter.

[%interactive]
* [ ] Download all staged artifacts under the url specified in the release vote email into a directory we'll now call `download-dir`.
* [ ] Verify the signature is correct:
Additional Apache tutorial on how to verify downloads can be found http://www.apache.org/info/verification.html[here].
[subs="attributes"]
----
gpg --verify apache-plc4x-{current-full-version}-source-release.zip.asc apache-plc4x-#{current-full-version}-source-release.zip
----
[%interactive]
* [ ] Check if the check is successful.
* [ ] Check if the signature references an Apache email address.
* [ ] Verify the SHA512 hashes:
[subs="attributes"]
----
Mac/Linux: shasum -a512 apache-plc4x-{current-full-version}-source-release.zip

Windows (PowerShell): Get-FileHash -Algorithm SHA512 .\apache-plc4x-code-generation-{current-full-version}-source-release.zip | Format-List
----
[%interactive]
* [ ] Unzip the archive:
[subs="attributes"]
----
unzip apache-plc4x-{current-full-version}-source-release.zip
----
[%interactive]
* [ ] Verify the existence of `LICENSE`, `NOTICE`, `README`, `RELEASE_NOTES` files in the extracted source bundle.
* [ ] Verify the content of `LICENSE`, `NOTICE`, `README`, `RELEASE_NOTES` files in the extracted source bundle.

TIP: (Especially pay attention to the year in the `NOTICE` file if this is the first release of the year)

[%interactive]
* [ ] [RM] Verify the staged source README, RELEASE_NOTE files correspond to those in the extracted source bundle.
* [ ] [RM] Run RAT externally to ensure there are no surprises.
[subs="attributes"]
----
java -jar apache-rat-0.13.jar apache-plc4x-{current-full-version}-source-release.zip > rat.log
----
[%interactive]
* [ ] Search for `SNAPSHOT` references:
[subs="attributes"]
----
find . -type f -name 'pom.xml' -exec grep -l "SNAPSHOT" {} \;
----
[%interactive]
* [ ] Search for `Copyright` references, and if they are in headers, make sure these files containing them are mentioned in the LICENSE file.
* [ ] Build the project according to the information in the README.md file.
* [ ] [RM] Build the project with all `with-xyz` profiles and tests enabled and an empty maven local repo: by appending `-Dmaven.repo.local=../.m2` (On windows use `-D"maven.repo.local"="../.m2"`).

== Using RAT

Even if we are using RAT to ensure sources have headers in place, still the project can contain exclusions that hide things from the check.

The only way to avoid missing important files is by running `RAT` externally.

If you haven't got it, yet please download it form https://creadur.apache.org/rat/download_rat.cgi[here].

Also do I like to run RAT against the zip archive containing the source release as this way you avoid the problem of eventually scanning the binaries produced by the build (If you run RAT after building, it will complain about every jar and ever class file).

[subs="attributes"]
----
java -jar apache-rat-0.13.jar apache-plc4x-{current-full-version}-source-release.zip > rat.log
----

By piping the result into a text file gives you the chance to investigate the content more easily.

== Release Tooling

`tools/validate-release.sh` checks the hardest part for you: that the artifacts staged in Nexus can
be reproduced from the staged sources.

Unpack the `apache-plc4x-{current-full-version}-source-release.zip` you downloaded above and run it
from inside the unpacked directory:

[subs="attributes"]
----
   ./tools/validate-release.sh
----

It builds the project inside the same Docker container the release was built in and then compares
the result against the staging repository with `artifact:compare`.
It refuses to run on a `SNAPSHOT` version, so it cannot accidentally be pointed at a development
checkout, and it needs at least 12 GB of memory available to Docker.

Only the Java artifacts are compared - the C, .Net and Python ones are either platform specific or
not published to Maven at all, so there is nothing staged to compare them against.

NOTE: The signature and hash checks above are still done by hand; there is no script for those any
more.

== Template for the email for voting

----
+1/-1 (binding)

Name

[] Download all staged artifacts under the url specified in the release vote email.
[] Verify the signature is correct.
[] Check if the signature references an Apache email address.
[] Verify the SHA512 hashes.
[] Unzip the archive.
[] Verify the existence of LICENSE, NOTICE, README, RELEASE_NOTES files in the extracted source bundle.
[] Verify the content of LICENSE, NOTICE, README, RELEASE_NOTES files in the extracted source bundle.
[] [RM] Verify the staged source README, RELEASE_NOTE files correspond to those in the extracted source bundle.
[] [RM] Run RAT externally to ensure there are no surprises.
[] Search for SNAPSHOT references
[] Search for Copyright references, and if they are in headers, make sure these files containing them are mentioned in the LICENSE file.
[] Build the project according to the information in the README.md file.
[] [RM] Build the project with all with-xyz profiles and tests enabled and an empty maven local repo.
----

If everything is ok, I put "OK" int the square brackets.
If there are minor issues, I put "MINOR" in there and, if it's a short reason, I put an explanation at the end of the line. If it's longer I put a longer section after the checklist.
If there are major issues, I put "FAIL" in there and comment the same way as with minor issues.