Skip to content

Commit

Permalink
Provide linkable ref in release job
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartinesp committed Nov 16, 2023
1 parent d7f33cf commit e3416d3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/release_sdk_parallel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
16 changes: 0 additions & 16 deletions scripts/build-rust-for-target.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
6 changes: 4 additions & 2 deletions scripts/release_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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)

Expand Down

0 comments on commit e3416d3

Please sign in to comment.