forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 13
SignRelease cherrypick #266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 42 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
e074fef
first test
arthurpassos 7b48c67
.
arthurpassos ea12951
.
arthurpassos a57f27c
aa
arthurpassos f3dc5c8
cancel dhpa64 for now
arthurpassos a28f44e
.
arthurpassos 031988e
,
arthurpassos a27efb8
,
arthurpassos 1228d1a
,
arthurpassos f7932ac
,
arthurpassos e32addb
,
arthurpassos 8ac8587
a
arthurpassos 530ccbb
a
arthurpassos d7e2171
a
arthurpassos e34475e
a
arthurpassos ac5f1a0
a
arthurpassos 05d7de2
a
arthurpassos e6f24ec
a
arthurpassos 8955cd8
a
arthurpassos 04ca68f
a
arthurpassos 13c071e
a
arthurpassos a5334ac
a
arthurpassos 7cb68a8
a
arthurpassos bef2fd2
a
arthurpassos 24d919e
a
arthurpassos cd8af6a
a
arthurpassos df3523c
a
arthurpassos 40c209b
a
arthurpassos 075c70e
a
arthurpassos 3d6553a
a
arthurpassos 2c038f1
a
arthurpassos 605d0e1
a
arthurpassos 6a0e2e0
a
arthurpassos 452e642
a
arthurpassos d6de686
a
arthurpassos 9b4a342
working as epxected, just a cleanup
arthurpassos 64d5b55
sha256 instead of 512
arthurpassos 42d46b7
remove comment
arthurpassos bbf76c9
Add comment specifying files
arthurpassos ae171d4
changing 512 to 256
MyroTk 10c29f1
merge fix
MyroTk dba9adf
Update env_helper.py
MyroTk cf062bd
Update env_helper.py
MyroTk b860787
Update sign_release.py
MyroTk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| #!/usr/bin/env python3 | ||
| import sys | ||
| import os | ||
| import logging | ||
| from env_helper import GPG_BINARY_SIGNING_KEY, GPG_BINARY_SIGNING_PASSPHRASE, TEMP_PATH, REPO_COPY, REPORTS_PATH | ||
| from s3_helper import S3Helper | ||
| from pr_info import PRInfo | ||
| from build_download_helper import download_builds_filter | ||
| import hashlib | ||
|
|
||
|
|
||
| CHECK_NAME = "Sign release (actions)" | ||
|
|
||
| def hash_file(file_path): | ||
| BLOCK_SIZE = 65536 # The size of each read from the file | ||
|
|
||
| file_hash = hashlib.sha256() # Create the hash object, can use something other than `.sha256()` if you wish | ||
| with open(file_path, 'rb') as f: # Open the file to read it's bytes | ||
| fb = f.read(BLOCK_SIZE) # Read from the file. Take in the amount declared above | ||
| while len(fb) > 0: # While there is still data being read from the file | ||
| file_hash.update(fb) # Update the hash | ||
| fb = f.read(BLOCK_SIZE) # Read the next block from the file | ||
|
|
||
| hash_file_path = file_path + '.sha256' | ||
| with open(hash_file_path, 'x') as f: | ||
| digest = file_hash.hexdigest() | ||
| f.write(digest) | ||
| print(f'Hashed {file_path}: {digest}') | ||
|
|
||
| return hash_file_path | ||
|
|
||
| def sign_file(file_path): | ||
| priv_key_file_path = 'priv.key' | ||
| with open(priv_key_file_path, 'x') as f: | ||
| f.write(GPG_BINARY_SIGNING_KEY) | ||
|
|
||
| out_file_path = f'{file_path}.gpg' | ||
|
|
||
| os.system(f'echo {GPG_BINARY_SIGNING_PASSPHRASE} | gpg --batch --import {priv_key_file_path}') | ||
| os.system(f'gpg -o {out_file_path} --pinentry-mode=loopback --batch --yes --passphrase {GPG_BINARY_SIGNING_PASSPHRASE} --sign {file_path}') | ||
| print(f"Signed {file_path}") | ||
| os.remove(priv_key_file_path) | ||
|
|
||
| return out_file_path | ||
|
|
||
| def main(): | ||
| reports_path = REPORTS_PATH | ||
|
|
||
| if not os.path.exists(TEMP_PATH): | ||
| os.makedirs(TEMP_PATH) | ||
|
|
||
| pr_info = PRInfo() | ||
|
|
||
| logging.info("Repo copy path %s", REPO_COPY) | ||
|
|
||
| s3_helper = S3Helper("https://s3.amazonaws.com") | ||
|
|
||
| s3_path_prefix = f"{pr_info.number}/{pr_info.sha}/" + CHECK_NAME.lower().replace( | ||
| " ", "_" | ||
| ).replace("(", "_").replace(")", "_").replace(",", "_") | ||
|
|
||
| # downloads `package_release` artifacts generated | ||
| download_builds_filter(CHECK_NAME, reports_path, TEMP_PATH) | ||
|
|
||
| for f in os.listdir(TEMP_PATH): | ||
| full_path = os.path.join(TEMP_PATH, f) | ||
| hashed_file_path = hash_file(full_path) | ||
| signed_file_path = sign_file(hashed_file_path) | ||
| s3_path = f'{s3_path_prefix}/{os.path.basename(signed_file_path)}' | ||
| s3_helper.upload_build_file_to_s3(signed_file_path, s3_path) | ||
| print(f'Uploaded file {signed_file_path} to {s3_path}') | ||
|
|
||
| # Signed hashes are: | ||
| # clickhouse-client_22.3.15.2.altinitystable_amd64.deb.sha512.gpg clickhouse-keeper_22.3.15.2.altinitystable_x86_64.apk.sha512.gpg | ||
| # clickhouse-client-22.3.15.2.altinitystable-amd64.tgz.sha512.gpg clickhouse-keeper-22.3.15.2.altinitystable.x86_64.rpm.sha512.gpg | ||
| # clickhouse-client_22.3.15.2.altinitystable_x86_64.apk.sha512.gpg clickhouse-keeper-dbg_22.3.15.2.altinitystable_amd64.deb.sha512.gpg | ||
| # clickhouse-client-22.3.15.2.altinitystable.x86_64.rpm.sha512.gpg clickhouse-keeper-dbg-22.3.15.2.altinitystable-amd64.tgz.sha512.gpg | ||
| # clickhouse-common-static_22.3.15.2.altinitystable_amd64.deb.sha512.gpg clickhouse-keeper-dbg_22.3.15.2.altinitystable_x86_64.apk.sha512.gpg | ||
| # clickhouse-common-static-22.3.15.2.altinitystable-amd64.tgz.sha512.gpg clickhouse-keeper-dbg-22.3.15.2.altinitystable.x86_64.rpm.sha512.gpg | ||
| # clickhouse-common-static_22.3.15.2.altinitystable_x86_64.apk.sha512.gpg clickhouse-keeper.sha512.gpg | ||
| # clickhouse-common-static-22.3.15.2.altinitystable.x86_64.rpm.sha512.gpg clickhouse-library-bridge.sha512.gpg | ||
| # clickhouse-common-static-dbg_22.3.15.2.altinitystable_amd64.deb.sha512.gpg clickhouse-odbc-bridge.sha512.gpg | ||
| # clickhouse-common-static-dbg-22.3.15.2.altinitystable-amd64.tgz.sha512.gpg clickhouse-server_22.3.15.2.altinitystable_amd64.deb.sha512.gpg | ||
| # clickhouse-common-static-dbg_22.3.15.2.altinitystable_x86_64.apk.sha512.gpg clickhouse-server-22.3.15.2.altinitystable-amd64.tgz.sha512.gpg | ||
| # clickhouse-common-static-dbg-22.3.15.2.altinitystable.x86_64.rpm.sha512.gpg clickhouse-server_22.3.15.2.altinitystable_x86_64.apk.sha512.gpg | ||
| # clickhouse-keeper_22.3.15.2.altinitystable_amd64.deb.sha512.gpg clickhouse-server-22.3.15.2.altinitystable.x86_64.rpm.sha512.gpg | ||
| # clickhouse-keeper-22.3.15.2.altinitystable-amd64.tgz.sha512.gpg clickhouse.sha512.gpg | ||
|
|
||
| sys.exit(0) | ||
|
|
||
| if __name__ == "__main__": | ||
| main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't that mean that signing keys are available to every other step too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is better to move that code to sign_release.py ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The signing keys are in the environment, so they are already available to all steps.
Will move the import.