diff --git a/.gitlab/ci/build_release_jobs.yml b/.gitlab/ci/build_release_jobs.yml index 1fa34fc1..f4be4076 100644 --- a/.gitlab/ci/build_release_jobs.yml +++ b/.gitlab/ci/build_release_jobs.yml @@ -8,7 +8,8 @@ steam_linux: - if: "$CI_COMMIT_TAG" artifacts: paths: - - build-x64-linux-release/bin + - build-x64-linux-release/ScreenPlay-$CI_COMMIT_TAG-x64-linux-release.zip + - build-x64-linux-release/ScreenPlay-$CI_COMMIT_TAG-x64-linux-release.zip.sha256.txt steam_windows: stage: release_build @@ -20,8 +21,8 @@ steam_windows: - if: "$CI_COMMIT_TAG" artifacts: paths: - - build-x64-windows-release/ - build-x64-windows-release/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip + - build-x64-windows-release/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip.sha256.txt steam_osx: stage: release_build @@ -33,32 +34,39 @@ steam_osx: - if: "$CI_COMMIT_TAG" artifacts: paths: - - build-64-osx-universal-release/ - - build-64-osx-universal-release/bin/ScreenPlay.app + - build-64-osx-universal-release/ScreenPlay-$CI_COMMIT_TAG-x64-osx-universal-release.zip + - build-64-osx-universal-release/ScreenPlay-$CI_COMMIT_TAG-x64-osx-universal-release.zip.sha256.txt release_job: stage: release image: registry.gitlab.com/gitlab-org/release-cli:latest - script: - - | - is_pre_release=false - if [[ "$CI_COMMIT_TAG" =~ -dev[0-9]+$ || "$CI_COMMIT_TAG" =~ -beta[0-9]+$ || "$CI_COMMIT_TAG" =~ -rc[0-9]+$ ]]; then - is_pre_release=true - fi - if $is_pre_release; then - release_name="ScreenPlay Pre-release $CI_COMMIT_TAG" - description="🎉 A Wild ScreenPlay Pre-release Appeared!" - pre_release_flag="--pre-release" - else - release_name="ScreenPlay Release $CI_COMMIT_TAG" - description="🎉 A Wild ScreenPlay Release Appeared!" - pre_release_flag="" - fi - release-cli create --name "$release_name" \ - --description "$description" \ - --tag-name $CI_COMMIT_TAG \ - --ref $CI_COMMIT_REF_NAME \ - $pre_release_flag \ - --assets-link '[{"name":"🐧 Linux x64 build","url":"$CI_PIPELINE_URL/artifacts/file/build-x64-linux-release/bin"},{"name":"🪟 Windows x64 build","url":"$CI_PIPELINE_URL/artifacts/file/build-x64-windows-release/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip"},{"name":"🍏 OSX universal build","url":"$CI_PIPELINE_URL/artifacts/file/build-64-osx-universal-release/bin/ScreenPlay.app"}]' rules: - - if: "$CI_COMMIT_TAG" + - if: "$CI_COMMIT_TAG" # Run this job when a tag is created + when: on_success # Only when all previous jobs succeed + script: + # 1. Combining sha256 files into a SHA512-SUMS.txt + - echo "Combining sha256 files into a SHA512-SUMS.txt" + - python3 Tools/publish_ci.py + # 2. Connect to kelteseth.com and handle the folder + - echo "Managing remote folder" + - apt-get update && apt-get install -y sshpass + - sshpass -p $GETSP_PASSWORD ssh $GETSP_USERNAME@kelteseth.com "if [ -d /getsp.de/$CI_COMMIT_TAG ]; then rm -r /getsp.de/$CI_COMMIT_TAG; else mkdir /getsp.de/$CI_COMMIT_TAG; fi" + # 3. Upload files to the remote folder + - echo "Uploading files" + - sshpass -p $GETSP_PASSWORD scp build-x64-linux-release/ScreenPlay-$CI_COMMIT_TAG-x64-linux-release.zip $GETSP_USERNAME@kelteseth.com:/getsp.de/$CI_COMMIT_TAG/ + - sshpass -p $GETSP_PASSWORD scp build-x64-windows-release/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip $GETSP_USERNAME@kelteseth.com:/getsp.de/$CI_COMMIT_TAG/ + - sshpass -p $GETSP_PASSWORD scp build-64-osx-universal-release/ScreenPlay-$CI_COMMIT_TAG-x64-osx-universal-release.zip $GETSP_USERNAME@kelteseth.com:/getsp.de/$CI_COMMIT_TAG/ + - sshpass -p $GETSP_PASSWORD scp SHA512-SUMS.txt $GETSP_USERNAME@kelteseth.com:/getsp.de/$CI_COMMIT_TAG/ + + release: + tag_name: $CI_COMMIT_TAG + name: "ScreenPlay $CI_COMMIT_TAG Released!" + description: "🎉 A Wild ScreenPlay Release Appeared!" + assets: + links: + - name: 🐧 Linux x64 build + url: "https://getsp.de/$CI_COMMIT_TAG/ScreenPlay-$CI_COMMIT_TAG-x64-linux-release.zip" + - name: 🪟 Windows x64 build + url: "https://getsp.de/$CI_COMMIT_TAG/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip" + - name: 🍏 OSX universal build + url: "https://getsp.de/$CI_COMMIT_TAG/ScreenPlay-$CI_COMMIT_TAG-x64-osx-universal-release.zip" diff --git a/.gitlab/ci/check_jobs.yml b/.gitlab/ci/check_jobs.yml index 561c60c3..82e5f039 100644 --- a/.gitlab/ci/check_jobs.yml +++ b/.gitlab/ci/check_jobs.yml @@ -1,6 +1,9 @@ formatting: stage: check allow_failure: true + rules: + - if: $CI_COMMIT_TAG + when: never image: name: ubuntu:23.10 tags: diff --git a/Tools/build.py b/Tools/build.py index bcced70b..74f03713 100755 --- a/Tools/build.py +++ b/Tools/build.py @@ -111,12 +111,11 @@ def execute( build_installer_duration = time.time() - step_time print(f"⏱️ build_installer_duration: {build_installer_duration}s") - # Create a zip file for scoop & chocolatey - if platform.system() == "Windows": - step_time = time.time() - build_result = zip(build_config, build_result) - zip_duration = time.time() - step_time - print(f"⏱️ zip_duration: {zip_duration}s") + # Create a zip file of the build + step_time = time.time() + build_result = zip(build_config, build_result) + zip_duration = time.time() - step_time + print(f"⏱️ zip_duration: {zip_duration}s") duration = time.time() - start_time print(f"⏱️ Build completed in: {duration}s") diff --git a/Tools/publish_ci.py b/Tools/publish_ci.py new file mode 100644 index 00000000..579b9bd3 --- /dev/null +++ b/Tools/publish_ci.py @@ -0,0 +1,24 @@ +import hashlib +import os + + +def combine_sha256(): + files = [ + "build-x64-linux-release/ScreenPlay-" + + os.environ['CI_COMMIT_TAG'] + "-x64-linux-release.zip", + "build-x64-windows-release/ScreenPlay-" + + os.environ['CI_COMMIT_TAG'] + "-x64-windows-release.zip", + "build-64-osx-universal-release/ScreenPlay-" + + os.environ['CI_COMMIT_TAG'] + "-x64-osx-universal-release.zip" + ] + + with open('SHA512-SUMS.txt', 'w') as f_out: + for file in files: + with open(f"{file}.sha256.txt", 'r') as f_in: + sha256_hash = f_in.read().strip() + sha512_hash = hashlib.sha512(sha256_hash.encode()).hexdigest() + f_out.write(f"{sha512_hash} {file}\n") + + +if __name__ == "__main__": + combine_sha256()