diff --git a/.github/workflows/release_sdk_parallel.yml b/.github/workflows/release_sdk_parallel.yml index 7f8e3c6..17b14de 100644 --- a/.github/workflows/release_sdk_parallel.yml +++ b/.github/workflows/release_sdk_parallel.yml @@ -82,6 +82,12 @@ jobs: run: | python3 ./scripts/build-rust-for-target.py --module SDK --version ${{ github.event.inputs.sdk-version }} --ref ${{ github.event.inputs.rust-checkout-ref }} --target ${{ matrix.target }} + - name: Set linkable git ref + run: | + pushd ../matrix-rust-sdk + echo LINKABLE_REF=$(git show-ref --verify refs/heads/${{ github.event.inputs.rust-checkout-ref }}) >> $GITHUB_OUTPUT + popd + - name: Upload target artifacts if: success() || failure() uses: actions/upload-artifact@v3 @@ -167,7 +173,7 @@ jobs: SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - python3 ./scripts/release_sdk.py --module SDK --version ${{ github.event.inputs.sdk-version }} + python3 ./scripts/release_sdk.py --module SDK --version ${{ github.event.inputs.sdk-version }} --linkable-ref ${{ needs.build_targets.outputs.LINKABLE_REF }} - name: Upload results # TODO: delete this if: success() || failure() diff --git a/scripts/build-rust-for-target.py b/scripts/build-rust-for-target.py index ec2ae49..0a004a5 100755 --- a/scripts/build-rust-for-target.py +++ b/scripts/build-rust-for-target.py @@ -54,21 +54,6 @@ def clone_repo_and_checkout_ref(directory, git_url, ref): text=True, ) -def get_linkable_ref(directory, ref): - result = subprocess.run( - ["git", "show-ref", "--verify", f"refs/heads/{ref}"], - cwd=directory, - capture_output=True, - text=True - ) - if result.returncode == 0: - # The reference is a valid branch name, return the corresponding commit hash - return result.stdout.strip().split()[0] - - # The reference is not a valid branch name, return the reference itself - return ref - - def is_provided_version_higher(major: int, minor: int, patch: int, provided_version: str) -> bool: provided_major, provided_minor, provided_patch = map(int, provided_version.split('.')) if provided_major > major: @@ -136,5 +121,4 @@ def execute_build_script(script_directory: str, sdk_path: str, module: Module, t if skip_clone is False: clone_repo_and_checkout_ref(sdk_path, sdk_git_url, args.ref) -linkable_ref = get_linkable_ref(sdk_path, args.ref) execute_build_script(current_dir, sdk_path, args.module, args.target) diff --git a/scripts/release_sdk.py b/scripts/release_sdk.py index 43663a9..05ec09e 100644 --- a/scripts/release_sdk.py +++ b/scripts/release_sdk.py @@ -171,6 +171,8 @@ def build_aar_files(script_directory: str, module: Module): help="Choose a module (SDK or CRYPTO)") parser.add_argument("-v", "--version", type=str, required=True, help="Version as a string (e.g. '1.0.0')") +parser.add_argument("-l", "--linkable-ref", type=str, required=True, + help="The git ref to link to in the matrix-rust-sdk project") args = parser.parse_args() @@ -188,12 +190,12 @@ def build_aar_files(script_directory: str, module: Module): override_version_in_build_version_file(build_version_file_path, args.version) -commit_message = f"Bump {args.module.name} version to {args.version} (matrix-rust-sdk to {linkable_ref})" +commit_message = f"Bump {args.module.name} version to {args.version} (matrix-rust-sdk to {args.linkable_ref})" print(f"Commit message: {commit_message}") # commit_and_push_changes(project_root, commit_message) release_name = f"{args.module.name.lower()}-v{args.version}" -release_notes = f"https://github.com/matrix-org/matrix-rust-sdk/tree/{linkable_ref}" +release_notes = f"https://github.com/matrix-org/matrix-rust-sdk/tree/{args.linkable_ref}" asset_path = get_asset_path(project_root, args.module) asset_name = get_asset_name(args.module)