diff --git a/.docker/Dockerfile.ci-container b/.docker/Dockerfile.ci-container index d68cecd225..c56e686888 100644 --- a/.docker/Dockerfile.ci-container +++ b/.docker/Dockerfile.ci-container @@ -14,9 +14,14 @@ RUN apt-get install -y \ gnupg \ git \ zip \ + python3 \ + python3-pip \ + python-dev \ + libffi-dev \ sudo -RUN ln -s /usr/bin/python3 /bin/python +RUN pip3 install --upgrade pip +RUN pip3 install paramiko RUN apt install -y \ software-properties-common \ diff --git a/.github/actions/deps-install/action.yml b/.github/actions/deps-install/action.yml index bc87d7c418..25ed15bf50 100644 --- a/.github/actions/deps-install/action.yml +++ b/.github/actions/deps-install/action.yml @@ -48,3 +48,14 @@ runs: run: | sudo apt-get update -y sudo apt-get install -y libudev-dev + + - name: Install python3 + uses: actions/setup-python@v5 + if: contains(inputs.deps, 'python3') + with: + python-version: 3 + + - name: Install `paramiko` pip package + if: contains(inputs.deps, 'paramiko') + shell: bash + run: pip install paramiko diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml index 18c500440b..c060051f74 100644 --- a/.github/workflows/dev-build.yml +++ b/.github/workflows/dev-build.yml @@ -74,18 +74,14 @@ jobs: zip $NAME target/release/kdf -j mv $NAME ./$BRANCH_NAME/ - - name: Upload output + - name: Upload build artifact env: - AVAILABLE: ${{ secrets.FILE_SERVER_KEY }} - if: ${{ env.AVAILABLE != '' }} - uses: easingthemes/ssh-deploy@v5.0.3 - with: - REMOTE_HOST: ${{ secrets.FILE_SERVER_HOST }} - REMOTE_USER: ${{ secrets.FILE_SERVER_USERNAME }} - REMOTE_PORT: ${{ secrets.FILE_SERVER_PORT }} - SSH_PRIVATE_KEY: ${{ secrets.FILE_SERVER_KEY }} - SOURCE: "${{ env.BRANCH_NAME }}/" - TARGET: "/uploads/${{ env.BRANCH_NAME }}" + FILE_SERVER_HOST: ${{ secrets.FILE_SERVER_HOST }} + FILE_SERVER_USERNAME: ${{ secrets.FILE_SERVER_USERNAME }} + FILE_SERVER_PORT: ${{ secrets.FILE_SERVER_PORT }} + FILE_SERVER_KEY: ${{ secrets.FILE_SERVER_KEY }} + if: ${{ env.FILE_SERVER_KEY != '' }} + run: python3 ./scripts/ci/upload_artifact.py "${{ env.BRANCH_NAME }}" "/uploads/${{ env.BRANCH_NAME }}" - name: Login to dockerhub if: github.event_name != 'pull_request' && github.ref == 'refs/heads/dev' @@ -113,7 +109,7 @@ jobs: - name: Install build deps uses: ./.github/actions/deps-install with: - deps: ('protoc') + deps: ('protoc', 'python3', 'paramiko') - name: Calculate commit hash for PR commit if: github.event_name == 'pull_request' @@ -151,18 +147,14 @@ jobs: zip $NAME target/x86_64-apple-darwin/release/kdf -j mv $NAME ./$BRANCH_NAME/ - - name: Upload output + - name: Upload build artifact env: - AVAILABLE: ${{ secrets.FILE_SERVER_KEY }} - if: ${{ env.AVAILABLE != '' }} - uses: easingthemes/ssh-deploy@v5.0.3 - with: - REMOTE_HOST: ${{ secrets.FILE_SERVER_HOST }} - REMOTE_USER: ${{ secrets.FILE_SERVER_USERNAME }} - REMOTE_PORT: ${{ secrets.FILE_SERVER_PORT }} - SSH_PRIVATE_KEY: ${{ secrets.FILE_SERVER_KEY }} - SOURCE: "${{ env.BRANCH_NAME }}/" - TARGET: "/uploads/${{ env.BRANCH_NAME }}" + FILE_SERVER_HOST: ${{ secrets.FILE_SERVER_HOST }} + FILE_SERVER_USERNAME: ${{ secrets.FILE_SERVER_USERNAME }} + FILE_SERVER_PORT: ${{ secrets.FILE_SERVER_PORT }} + FILE_SERVER_KEY: ${{ secrets.FILE_SERVER_KEY }} + if: ${{ env.FILE_SERVER_KEY != '' }} + run: python3 ./scripts/ci/upload_artifact.py "${{ env.BRANCH_NAME }}" "/uploads/${{ env.BRANCH_NAME }}" win-x86-64: timeout-minutes: 60 @@ -177,7 +169,7 @@ jobs: - name: Install build deps uses: ./.github/actions/deps-install with: - deps: ('protoc') + deps: ('protoc', 'python3', 'paramiko') - name: Calculate commit hash for PR commit if: github.event_name == 'pull_request' @@ -217,18 +209,14 @@ jobs: 7z a $NAME .\target\release\kdf.exe .\target\release\*.dll mv $NAME ./$Env:BRANCH_NAME/ - - name: Upload output + - name: Upload build artifact env: - AVAILABLE: ${{ secrets.FILE_SERVER_KEY }} - if: ${{ env.AVAILABLE != '' }} - uses: garygrossgarten/github-action-scp@v0.8.0 - with: - host: ${{ secrets.FILE_SERVER_HOST }} - username: ${{ secrets.FILE_SERVER_USERNAME }} - port: ${{ secrets.FILE_SERVER_PORT }} - privateKey: ${{ secrets.FILE_SERVER_KEY }} - local: ${{ env.BRANCH_NAME }} - remote: "/uploads/${{ env.BRANCH_NAME }}" + FILE_SERVER_HOST: ${{ secrets.FILE_SERVER_HOST }} + FILE_SERVER_USERNAME: ${{ secrets.FILE_SERVER_USERNAME }} + FILE_SERVER_PORT: ${{ secrets.FILE_SERVER_PORT }} + FILE_SERVER_KEY: ${{ secrets.FILE_SERVER_KEY }} + if: ${{ env.FILE_SERVER_KEY != '' }} + run: python3 ./scripts/ci/upload_artifact.py "${{ env.BRANCH_NAME }}" "/uploads/${{ env.BRANCH_NAME }}" mac-dylib-x86-64: timeout-minutes: 60 @@ -244,7 +232,7 @@ jobs: - name: Install build deps uses: ./.github/actions/deps-install with: - deps: ('protoc') + deps: ('protoc', 'python3', 'paramiko') - name: Calculate commit hash for PR commit if: github.event_name == 'pull_request' @@ -284,18 +272,14 @@ jobs: zip $NAME target/x86_64-apple-darwin/release/libkdf.a -j mv $NAME ./$BRANCH_NAME/ - - name: Upload output + - name: Upload build artifact env: - AVAILABLE: ${{ secrets.FILE_SERVER_KEY }} - if: ${{ env.AVAILABLE != '' }} - uses: easingthemes/ssh-deploy@v5.0.3 - with: - REMOTE_HOST: ${{ secrets.FILE_SERVER_HOST }} - REMOTE_USER: ${{ secrets.FILE_SERVER_USERNAME }} - REMOTE_PORT: ${{ secrets.FILE_SERVER_PORT }} - SSH_PRIVATE_KEY: ${{ secrets.FILE_SERVER_KEY }} - SOURCE: "${{ env.BRANCH_NAME }}/" - TARGET: "/uploads/${{ env.BRANCH_NAME }}" + FILE_SERVER_HOST: ${{ secrets.FILE_SERVER_HOST }} + FILE_SERVER_USERNAME: ${{ secrets.FILE_SERVER_USERNAME }} + FILE_SERVER_PORT: ${{ secrets.FILE_SERVER_PORT }} + FILE_SERVER_KEY: ${{ secrets.FILE_SERVER_KEY }} + if: ${{ env.FILE_SERVER_KEY != '' }} + run: python3 ./scripts/ci/upload_artifact.py "${{ env.BRANCH_NAME }}" "/uploads/${{ env.BRANCH_NAME }}" wasm: timeout-minutes: 60 @@ -352,18 +336,14 @@ jobs: mkdir $BRANCH_NAME mv $NAME ./$BRANCH_NAME/ - - name: Upload output + - name: Upload build artifact env: - AVAILABLE: ${{ secrets.FILE_SERVER_KEY }} - if: ${{ env.AVAILABLE != '' }} - uses: easingthemes/ssh-deploy@v5.0.3 - with: - REMOTE_HOST: ${{ secrets.FILE_SERVER_HOST }} - REMOTE_USER: ${{ secrets.FILE_SERVER_USERNAME }} - REMOTE_PORT: ${{ secrets.FILE_SERVER_PORT }} - SSH_PRIVATE_KEY: ${{ secrets.FILE_SERVER_KEY }} - SOURCE: "${{ env.BRANCH_NAME }}/" - TARGET: "/uploads/${{ env.BRANCH_NAME }}" + FILE_SERVER_HOST: ${{ secrets.FILE_SERVER_HOST }} + FILE_SERVER_USERNAME: ${{ secrets.FILE_SERVER_USERNAME }} + FILE_SERVER_PORT: ${{ secrets.FILE_SERVER_PORT }} + FILE_SERVER_KEY: ${{ secrets.FILE_SERVER_KEY }} + if: ${{ env.FILE_SERVER_KEY != '' }} + run: python3 ./scripts/ci/upload_artifact.py "${{ env.BRANCH_NAME }}" "/uploads/${{ env.BRANCH_NAME }}" ios-aarch64: timeout-minutes: 60 @@ -379,7 +359,7 @@ jobs: - name: Install build deps uses: ./.github/actions/deps-install with: - deps: ('protoc') + deps: ('protoc', 'python3', 'paramiko') - name: Calculate commit hash for PR commit if: github.event_name == 'pull_request' @@ -419,18 +399,14 @@ jobs: zip $NAME target/aarch64-apple-ios/release/libkdf.a -j mv $NAME ./$BRANCH_NAME/ - - name: Upload output + - name: Upload build artifact env: - AVAILABLE: ${{ secrets.FILE_SERVER_KEY }} - if: ${{ env.AVAILABLE != '' }} - uses: easingthemes/ssh-deploy@v5.0.3 - with: - REMOTE_HOST: ${{ secrets.FILE_SERVER_HOST }} - REMOTE_USER: ${{ secrets.FILE_SERVER_USERNAME }} - REMOTE_PORT: ${{ secrets.FILE_SERVER_PORT }} - SSH_PRIVATE_KEY: ${{ secrets.FILE_SERVER_KEY }} - SOURCE: "${{ env.BRANCH_NAME }}/" - TARGET: "/uploads/${{ env.BRANCH_NAME }}" + FILE_SERVER_HOST: ${{ secrets.FILE_SERVER_HOST }} + FILE_SERVER_USERNAME: ${{ secrets.FILE_SERVER_USERNAME }} + FILE_SERVER_PORT: ${{ secrets.FILE_SERVER_PORT }} + FILE_SERVER_KEY: ${{ secrets.FILE_SERVER_KEY }} + if: ${{ env.FILE_SERVER_KEY != '' }} + run: python3 ./scripts/ci/upload_artifact.py "${{ env.BRANCH_NAME }}" "/uploads/${{ env.BRANCH_NAME }}" android-aarch64: timeout-minutes: 60 @@ -500,18 +476,14 @@ jobs: zip $NAME target/aarch64-linux-android/release/libkdf.a -j mv $NAME ./$BRANCH_NAME/ - - name: Upload output + - name: Upload build artifact env: - AVAILABLE: ${{ secrets.FILE_SERVER_KEY }} - if: ${{ env.AVAILABLE != '' }} - uses: easingthemes/ssh-deploy@v5.0.3 - with: - REMOTE_HOST: ${{ secrets.FILE_SERVER_HOST }} - REMOTE_USER: ${{ secrets.FILE_SERVER_USERNAME }} - REMOTE_PORT: ${{ secrets.FILE_SERVER_PORT }} - SSH_PRIVATE_KEY: ${{ secrets.FILE_SERVER_KEY }} - SOURCE: "${{ env.BRANCH_NAME }}/" - TARGET: "/uploads/${{ env.BRANCH_NAME }}" + FILE_SERVER_HOST: ${{ secrets.FILE_SERVER_HOST }} + FILE_SERVER_USERNAME: ${{ secrets.FILE_SERVER_USERNAME }} + FILE_SERVER_PORT: ${{ secrets.FILE_SERVER_PORT }} + FILE_SERVER_KEY: ${{ secrets.FILE_SERVER_KEY }} + if: ${{ env.FILE_SERVER_KEY != '' }} + run: python3 ./scripts/ci/upload_artifact.py "${{ env.BRANCH_NAME }}" "/uploads/${{ env.BRANCH_NAME }}" android-armv7: timeout-minutes: 60 @@ -581,18 +553,14 @@ jobs: zip $NAME target/armv7-linux-androideabi/release/libkdf.a -j mv $NAME ./$BRANCH_NAME/ - - name: Upload output + - name: Upload build artifact env: - AVAILABLE: ${{ secrets.FILE_SERVER_KEY }} - if: ${{ env.AVAILABLE != '' }} - uses: easingthemes/ssh-deploy@v5.0.3 - with: - REMOTE_HOST: ${{ secrets.FILE_SERVER_HOST }} - REMOTE_USER: ${{ secrets.FILE_SERVER_USERNAME }} - REMOTE_PORT: ${{ secrets.FILE_SERVER_PORT }} - SSH_PRIVATE_KEY: ${{ secrets.FILE_SERVER_KEY }} - SOURCE: "${{ env.BRANCH_NAME }}/" - TARGET: "/uploads/${{ env.BRANCH_NAME }}" + FILE_SERVER_HOST: ${{ secrets.FILE_SERVER_HOST }} + FILE_SERVER_USERNAME: ${{ secrets.FILE_SERVER_USERNAME }} + FILE_SERVER_PORT: ${{ secrets.FILE_SERVER_PORT }} + FILE_SERVER_KEY: ${{ secrets.FILE_SERVER_KEY }} + if: ${{ env.FILE_SERVER_KEY != '' }} + run: python3 ./scripts/ci/upload_artifact.py "${{ env.BRANCH_NAME }}" "/uploads/${{ env.BRANCH_NAME }}" deployment-commitment: if: github.event_name != 'pull_request' && github.ref == 'refs/heads/dev' diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 8d867bc31b..259f9f8465 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -68,15 +68,14 @@ jobs: zip $NAME target/release/kdf -j mv $NAME ./$BRANCH_NAME/ - - name: Upload output - uses: easingthemes/ssh-deploy@v5.0.3 - with: - REMOTE_HOST: ${{ secrets.FILE_SERVER_HOST }} - REMOTE_USER: ${{ secrets.FILE_SERVER_USERNAME }} - REMOTE_PORT: ${{ secrets.FILE_SERVER_PORT }} - SSH_PRIVATE_KEY: ${{ secrets.FILE_SERVER_KEY }} - SOURCE: "${{ env.BRANCH_NAME }}/" - TARGET: "/uploads/${{ env.BRANCH_NAME }}" + - name: Upload build artifact + env: + FILE_SERVER_HOST: ${{ secrets.FILE_SERVER_HOST }} + FILE_SERVER_USERNAME: ${{ secrets.FILE_SERVER_USERNAME }} + FILE_SERVER_PORT: ${{ secrets.FILE_SERVER_PORT }} + FILE_SERVER_KEY: ${{ secrets.FILE_SERVER_KEY }} + if: ${{ env.FILE_SERVER_KEY != '' }} + run: python3 ./scripts/ci/upload_artifact.py "${{ env.BRANCH_NAME }}" "/uploads/${{ env.BRANCH_NAME }}" - name: Login to dockerhub run: docker login --username ${{ secrets.DOCKER_HUB_USERNAME }} --password ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} docker.io @@ -101,7 +100,7 @@ jobs: - name: Install build deps uses: ./.github/actions/deps-install with: - deps: ('protoc') + deps: ('protoc', 'python3', 'paramiko') - name: Calculate commit hash for PR commit if: github.event_name == 'pull_request' @@ -133,15 +132,14 @@ jobs: zip $NAME target/x86_64-apple-darwin/release/kdf -j mv $NAME ./$BRANCH_NAME/ - - name: Upload output - uses: easingthemes/ssh-deploy@v5.0.3 - with: - REMOTE_HOST: ${{ secrets.FILE_SERVER_HOST }} - REMOTE_USER: ${{ secrets.FILE_SERVER_USERNAME }} - REMOTE_PORT: ${{ secrets.FILE_SERVER_PORT }} - SSH_PRIVATE_KEY: ${{ secrets.FILE_SERVER_KEY }} - SOURCE: "${{ env.BRANCH_NAME }}/" - TARGET: "/uploads/${{ env.BRANCH_NAME }}" + - name: Upload build artifact + env: + FILE_SERVER_HOST: ${{ secrets.FILE_SERVER_HOST }} + FILE_SERVER_USERNAME: ${{ secrets.FILE_SERVER_USERNAME }} + FILE_SERVER_PORT: ${{ secrets.FILE_SERVER_PORT }} + FILE_SERVER_KEY: ${{ secrets.FILE_SERVER_KEY }} + if: ${{ env.FILE_SERVER_KEY != '' }} + run: python3 ./scripts/ci/upload_artifact.py "${{ env.BRANCH_NAME }}" "/uploads/${{ env.BRANCH_NAME }}" win-x86-64: timeout-minutes: 60 @@ -156,7 +154,7 @@ jobs: - name: Install build deps uses: ./.github/actions/deps-install with: - deps: ('protoc') + deps: ('protoc', 'python3', 'paramiko') - name: Calculate commit hash for PR commit if: github.event_name == 'pull_request' @@ -190,15 +188,14 @@ jobs: 7z a $NAME .\target\release\kdf.exe .\target\release\*.dll mv $NAME ./$Env:BRANCH_NAME/ - - name: Upload output - uses: garygrossgarten/github-action-scp@v0.8.0 - with: - host: ${{ secrets.FILE_SERVER_HOST }} - username: ${{ secrets.FILE_SERVER_USERNAME }} - port: ${{ secrets.FILE_SERVER_PORT }} - privateKey: ${{ secrets.FILE_SERVER_KEY }} - local: ${{ env.BRANCH_NAME }} - remote: "/uploads/${{ env.BRANCH_NAME }}" + - name: Upload build artifact + env: + FILE_SERVER_HOST: ${{ secrets.FILE_SERVER_HOST }} + FILE_SERVER_USERNAME: ${{ secrets.FILE_SERVER_USERNAME }} + FILE_SERVER_PORT: ${{ secrets.FILE_SERVER_PORT }} + FILE_SERVER_KEY: ${{ secrets.FILE_SERVER_KEY }} + if: ${{ env.FILE_SERVER_KEY != '' }} + run: python3 ./scripts/ci/upload_artifact.py "${{ env.BRANCH_NAME }}" "/uploads/${{ env.BRANCH_NAME }}" mac-dylib-x86-64: timeout-minutes: 60 @@ -213,7 +210,7 @@ jobs: - name: Install build deps uses: ./.github/actions/deps-install with: - deps: ('protoc') + deps: ('protoc', 'python3', 'paramiko') - name: Calculate commit hash for PR commit if: github.event_name == 'pull_request' @@ -247,15 +244,14 @@ jobs: zip $NAME target/x86_64-apple-darwin/release/libkdf.a -j mv $NAME ./$BRANCH_NAME/ - - name: Upload output - uses: easingthemes/ssh-deploy@v5.0.3 - with: - REMOTE_HOST: ${{ secrets.FILE_SERVER_HOST }} - REMOTE_USER: ${{ secrets.FILE_SERVER_USERNAME }} - REMOTE_PORT: ${{ secrets.FILE_SERVER_PORT }} - SSH_PRIVATE_KEY: ${{ secrets.FILE_SERVER_KEY }} - SOURCE: "${{ env.BRANCH_NAME }}/" - TARGET: "/uploads/${{ env.BRANCH_NAME }}" + - name: Upload build artifact + env: + FILE_SERVER_HOST: ${{ secrets.FILE_SERVER_HOST }} + FILE_SERVER_USERNAME: ${{ secrets.FILE_SERVER_USERNAME }} + FILE_SERVER_PORT: ${{ secrets.FILE_SERVER_PORT }} + FILE_SERVER_KEY: ${{ secrets.FILE_SERVER_KEY }} + if: ${{ env.FILE_SERVER_KEY != '' }} + run: python3 ./scripts/ci/upload_artifact.py "${{ env.BRANCH_NAME }}" "/uploads/${{ env.BRANCH_NAME }}" wasm: timeout-minutes: 60 @@ -309,15 +305,14 @@ jobs: mkdir $BRANCH_NAME mv $NAME ./$BRANCH_NAME/ - - name: Upload output - uses: easingthemes/ssh-deploy@v5.0.3 - with: - REMOTE_HOST: ${{ secrets.FILE_SERVER_HOST }} - REMOTE_USER: ${{ secrets.FILE_SERVER_USERNAME }} - REMOTE_PORT: ${{ secrets.FILE_SERVER_PORT }} - SSH_PRIVATE_KEY: ${{ secrets.FILE_SERVER_KEY }} - SOURCE: "${{ env.BRANCH_NAME }}/" - TARGET: "/uploads/${{ env.BRANCH_NAME }}" + - name: Upload build artifact + env: + FILE_SERVER_HOST: ${{ secrets.FILE_SERVER_HOST }} + FILE_SERVER_USERNAME: ${{ secrets.FILE_SERVER_USERNAME }} + FILE_SERVER_PORT: ${{ secrets.FILE_SERVER_PORT }} + FILE_SERVER_KEY: ${{ secrets.FILE_SERVER_KEY }} + if: ${{ env.FILE_SERVER_KEY != '' }} + run: python3 ./scripts/ci/upload_artifact.py "${{ env.BRANCH_NAME }}" "/uploads/${{ env.BRANCH_NAME }}" ios-aarch64: timeout-minutes: 60 @@ -333,7 +328,7 @@ jobs: - name: Install build deps uses: ./.github/actions/deps-install with: - deps: ('protoc') + deps: ('protoc', 'python3', 'paramiko') - name: Calculate commit hash for PR commit if: github.event_name == 'pull_request' @@ -367,15 +362,14 @@ jobs: zip $NAME target/aarch64-apple-ios/release/libkdf.a -j mv $NAME ./$BRANCH_NAME/ - - name: Upload output - uses: easingthemes/ssh-deploy@v5.0.3 - with: - REMOTE_HOST: ${{ secrets.FILE_SERVER_HOST }} - REMOTE_USER: ${{ secrets.FILE_SERVER_USERNAME }} - REMOTE_PORT: ${{ secrets.FILE_SERVER_PORT }} - SSH_PRIVATE_KEY: ${{ secrets.FILE_SERVER_KEY }} - SOURCE: "${{ env.BRANCH_NAME }}/" - TARGET: "/uploads/${{ env.BRANCH_NAME }}" + - name: Upload build artifact + env: + FILE_SERVER_HOST: ${{ secrets.FILE_SERVER_HOST }} + FILE_SERVER_USERNAME: ${{ secrets.FILE_SERVER_USERNAME }} + FILE_SERVER_PORT: ${{ secrets.FILE_SERVER_PORT }} + FILE_SERVER_KEY: ${{ secrets.FILE_SERVER_KEY }} + if: ${{ env.FILE_SERVER_KEY != '' }} + run: python3 ./scripts/ci/upload_artifact.py "${{ env.BRANCH_NAME }}" "/uploads/${{ env.BRANCH_NAME }}" android-aarch64: timeout-minutes: 60 @@ -439,15 +433,14 @@ jobs: zip $NAME target/aarch64-linux-android/release/libkdf.a -j mv $NAME ./$BRANCH_NAME/ - - name: Upload output - uses: easingthemes/ssh-deploy@v5.0.3 - with: - REMOTE_HOST: ${{ secrets.FILE_SERVER_HOST }} - REMOTE_USER: ${{ secrets.FILE_SERVER_USERNAME }} - REMOTE_PORT: ${{ secrets.FILE_SERVER_PORT }} - SSH_PRIVATE_KEY: ${{ secrets.FILE_SERVER_KEY }} - SOURCE: "${{ env.BRANCH_NAME }}/" - TARGET: "/uploads/${{ env.BRANCH_NAME }}" + - name: Upload build artifact + env: + FILE_SERVER_HOST: ${{ secrets.FILE_SERVER_HOST }} + FILE_SERVER_USERNAME: ${{ secrets.FILE_SERVER_USERNAME }} + FILE_SERVER_PORT: ${{ secrets.FILE_SERVER_PORT }} + FILE_SERVER_KEY: ${{ secrets.FILE_SERVER_KEY }} + if: ${{ env.FILE_SERVER_KEY != '' }} + run: python3 ./scripts/ci/upload_artifact.py "${{ env.BRANCH_NAME }}" "/uploads/${{ env.BRANCH_NAME }}" android-armv7: timeout-minutes: 60 @@ -511,12 +504,11 @@ jobs: zip $NAME target/armv7-linux-androideabi/release/libkdf.a -j mv $NAME ./$BRANCH_NAME/ - - name: Upload output - uses: easingthemes/ssh-deploy@v5.0.3 - with: - REMOTE_HOST: ${{ secrets.FILE_SERVER_HOST }} - REMOTE_USER: ${{ secrets.FILE_SERVER_USERNAME }} - REMOTE_PORT: ${{ secrets.FILE_SERVER_PORT }} - SSH_PRIVATE_KEY: ${{ secrets.FILE_SERVER_KEY }} - SOURCE: "${{ env.BRANCH_NAME }}/" - TARGET: "/uploads/${{ env.BRANCH_NAME }}" + - name: Upload build artifact + env: + FILE_SERVER_HOST: ${{ secrets.FILE_SERVER_HOST }} + FILE_SERVER_USERNAME: ${{ secrets.FILE_SERVER_USERNAME }} + FILE_SERVER_PORT: ${{ secrets.FILE_SERVER_PORT }} + FILE_SERVER_KEY: ${{ secrets.FILE_SERVER_KEY }} + if: ${{ env.FILE_SERVER_KEY != '' }} + run: python3 ./scripts/ci/upload_artifact.py "${{ env.BRANCH_NAME }}" "/uploads/${{ env.BRANCH_NAME }}" diff --git a/scripts/ci/upload_artifact.py b/scripts/ci/upload_artifact.py new file mode 100755 index 0000000000..649e13acb0 --- /dev/null +++ b/scripts/ci/upload_artifact.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 + +import os +import paramiko +import sys +from io import StringIO + +def upload_files(remote_host, remote_user, remote_port, ssh_private_key, source, target): + privkey = StringIO(ssh_private_key) + ssh_key = paramiko.Ed25519Key.from_private_key(privkey) + ssh = paramiko.SSHClient() + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + + try: + ssh.connect(remote_host, port=remote_port, username=remote_user, pkey=ssh_key) + + sftp = ssh.open_sftp() + for root, dirs, files in os.walk(source): + relative_dir_path = os.path.relpath(root, source) + remote_dir_path = os.path.join(target, relative_dir_path).replace("\\", "/") + try: + sftp.mkdir(remote_dir_path) + except OSError: + pass # Directory probably already exists + + for filename in files: + local_path = os.path.join(root, filename) + remote_path = os.path.join(target, relative_dir_path, filename).replace("\\", "/") + sftp.put(local_path, remote_path) + + print("Upload finished successfully") + ssh.close() + + except Exception as e: + print("Upload failed: " + str(e)) + sys.exit(1) + +def main(): + if len(sys.argv) != 3: + print("Usage: `python upload_artifact.py `") + sys.exit(1) + + source = sys.argv[1] + target = sys.argv[2] + + remote_host = os.getenv('FILE_SERVER_HOST') + remote_user = os.getenv('FILE_SERVER_USERNAME') + remote_port = int(os.getenv('FILE_SERVER_PORT', 22)) + ssh_private_key = os.getenv('FILE_SERVER_KEY') + + if not (remote_host or remote_user or remote_port or ssh_private_key): + print("Missing environment variables for SSH connection") + sys.exit(1) + + upload_files(remote_host, remote_user, remote_port, ssh_private_key, source, target) + +if __name__ == "__main__": + main()