//
//  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

In the `tools` directory we have a little script that can help with downloading and checking the hashes and signatures automatically.

In order to execute this, please change directories into the projects base directory and execute the following command:

[subs="attributes"]
----
tools/download_staged_release.sh {current-full-version} 1
----

This will download all the files into a directory: `downloaded-plc4x-{current-full-version}1`.

After that it will calculate the SHA512 hash and compare it with the staged hash.

Last not least it will validate the PGP key and print out some information on it.

== 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.