Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e074fef
first test
arthurpassos Dec 16, 2022
7b48c67
.
arthurpassos Dec 16, 2022
ea12951
.
arthurpassos Dec 16, 2022
a57f27c
aa
arthurpassos Dec 16, 2022
f3dc5c8
cancel dhpa64 for now
arthurpassos Dec 16, 2022
a28f44e
.
arthurpassos Dec 16, 2022
031988e
,
arthurpassos Dec 16, 2022
a27efb8
,
arthurpassos Dec 16, 2022
1228d1a
,
arthurpassos Dec 16, 2022
f7932ac
,
arthurpassos Dec 16, 2022
e32addb
,
arthurpassos Dec 16, 2022
8ac8587
a
arthurpassos Dec 18, 2022
530ccbb
a
arthurpassos Dec 18, 2022
d7e2171
a
arthurpassos Dec 18, 2022
e34475e
a
arthurpassos Dec 18, 2022
ac5f1a0
a
arthurpassos Dec 19, 2022
05d7de2
a
arthurpassos Dec 19, 2022
e6f24ec
a
arthurpassos Dec 19, 2022
8955cd8
a
arthurpassos Dec 19, 2022
04ca68f
a
arthurpassos Jan 3, 2023
13c071e
a
arthurpassos Jan 3, 2023
a5334ac
a
arthurpassos Jan 3, 2023
7cb68a8
a
arthurpassos Jan 3, 2023
bef2fd2
a
arthurpassos Jan 4, 2023
24d919e
a
arthurpassos Jan 4, 2023
cd8af6a
a
arthurpassos Jan 4, 2023
df3523c
a
arthurpassos Jan 5, 2023
40c209b
a
arthurpassos Jan 5, 2023
075c70e
a
arthurpassos Jan 5, 2023
3d6553a
a
arthurpassos Jan 5, 2023
2c038f1
a
arthurpassos Jan 6, 2023
605d0e1
a
arthurpassos Jan 6, 2023
6a0e2e0
a
arthurpassos Jan 6, 2023
452e642
a
arthurpassos Jan 6, 2023
d6de686
a
arthurpassos Jan 6, 2023
9b4a342
working as epxected, just a cleanup
arthurpassos Jan 6, 2023
64d5b55
sha256 instead of 512
arthurpassos Jan 11, 2023
42d46b7
remove comment
arthurpassos Jan 12, 2023
bbf76c9
Add comment specifying files
arthurpassos Jan 19, 2023
ae171d4
changing 512 to 256
MyroTk May 31, 2023
10c29f1
merge fix
MyroTk May 31, 2023
dba9adf
Update env_helper.py
MyroTk Jun 2, 2023
cf062bd
Update env_helper.py
MyroTk Jun 5, 2023
b860787
Update sign_release.py
MyroTk Jun 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion .github/workflows/release_branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,48 @@ jobs:
./*/_instances/*/logs/*.log
./*/*/_instances/*/logs/*.log
./*/*/_instances/*.log


SignRelease:
needs: [BuilderDebRelease]
runs-on: [ self-hosted ]
steps:
- name: Set envs
run: |
cat >> "$GITHUB_ENV" << 'EOF'
TEMP_PATH=${{runner.temp}}/signed
REPORTS_PATH=${{runner.temp}}/reports_dir
EOF
- name: Clear repository
run: |
sudo rm -fr "$GITHUB_WORKSPACE" && mkdir "$GITHUB_WORKSPACE"
- name: Check out repository code
uses: actions/checkout@v2
- name: Download json reports
uses: actions/download-artifact@v2
with:
path: ${{ env.REPORTS_PATH }}
- name: Sign release
env:
GPG_BINARY_SIGNING_KEY: ${{ secrets.GPG_BINARY_SIGNING_KEY }}
GPG_BINARY_SIGNING_PASSPHRASE: ${{ secrets.GPG_BINARY_SIGNING_PASSPHRASE }}
REPORTS_PATH: ${{ env.REPORTS_PATH }}
run: |
cd "$GITHUB_WORKSPACE/tests/ci"
python3 sign_release.py
- name: Upload signed hashes
uses: actions/upload-artifact@v2
with:
name: signed-hashes
path: ${{ env.TEMP_PATH }}/*.gpg
- name: Cleanup
if: always()
run: |
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
sudo rm -fr "$TEMP_PATH"
###########################################################################################
################################ FINISH CHECK #############################################
###########################################################################################
FinishCheck:
needs:
- DockerHubPush
Expand All @@ -996,6 +1037,7 @@ jobs:
- IntegrationTestsRelease0
- IntegrationTestsRelease1
- CompatibilityCheck
- SignRelease
- regression_common
- benchmark
- ldap
Expand Down
3 changes: 3 additions & 0 deletions tests/ci/ci_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@
"required_build": "package_aarch64",
"test_grep_exclude_filter": "constant_column_search",
},
"Sign release (actions)": {
"required_build": "package_release"
}
},
} # type: dict

Expand Down
94 changes: 94 additions & 0 deletions tests/ci/sign_release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/usr/bin/env python3
import sys
import os
import logging
from env_helper import 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

GPG_BINARY_SIGNING_KEY = os.getenv("GPG_BINARY_SIGNING_KEY")
GPG_BINARY_SIGNING_PASSPHRASE = os.getenv("GPG_BINARY_SIGNING_PASSPHRASE")

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()