Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
80 changes: 80 additions & 0 deletions .github/workflows/update-android-sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Update Android SDK

on:
workflow_dispatch:
inputs:
version:
description: "Android SDK version (e.g., 3.17.0)"
required: true
type: string
workflow_call:
inputs:
version:
description: "Android SDK version (e.g., 3.17.0)"
required: true
type: string
secrets:
token:
required: true

jobs:
update-android-sdk:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Determine version
id: version
env:
INPUT_VERSION: ${{ inputs.version }}
run: |
VERSION="${INPUT_VERSION#v}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "branch=chore/update-android-sdk-${VERSION}" >> "$GITHUB_OUTPUT"

- uses: actions/checkout@v4
with:
ref: master
repository: atomicfi/atomic-transact-react-native
token: ${{ secrets.token || secrets.GITHUB_TOKEN }}

- name: Update Android SDK version
env:
VERSION: ${{ steps.version.outputs.version }}
run: ./scripts/update-android-sdk.sh "$VERSION"

- name: Check for changes
id: changes
run: |
if git diff --quiet && git diff --cached --quiet; then
echo "has_changes=false" >> "$GITHUB_OUTPUT"
else
echo "has_changes=true" >> "$GITHUB_OUTPUT"
fi

- name: Create Pull Request
if: steps.changes.outputs.has_changes == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.version.outputs.version }}
BRANCH: ${{ steps.version.outputs.branch }}
run: |

git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

git checkout -b "$BRANCH"
git add android/build.gradle
git commit -m "chore: upgrade Android SDK to ${VERSION}"
git push origin "$BRANCH"

gh pr create \
--title "chore: upgrade Android SDK to ${VERSION}" \
--body "Automated upgrade of Android SDK Maven dependency to version ${VERSION}.

**Release notes**: https://github.com/atomicfi/atomic-transact-android/releases/tag/${VERSION}" \
--base master \
--head "$BRANCH" \
--reviewer atomicfi/sdk
40 changes: 40 additions & 0 deletions scripts/update-android-sdk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
set -euo pipefail

# Updates the Android SDK (Maven) dependency version in build.gradle.
# Usage: ./scripts/update-android-sdk.sh <version>
# Example: ./scripts/update-android-sdk.sh 3.17.0

VERSION="${1:?Usage: $0 <version>}"

# Strip leading 'v' if present
VERSION="${VERSION#v}"

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
BUILD_GRADLE="${PROJECT_DIR}/android/build.gradle"

if [ ! -f "$BUILD_GRADLE" ]; then
echo "Error: build.gradle not found at ${BUILD_GRADLE}" >&2
exit 1
fi

CURRENT_VERSION=$(sed -n 's/.*def transact_version = "\([^"]*\)".*/\1/p' "$BUILD_GRADLE")

if [ "$CURRENT_VERSION" = "$VERSION" ]; then
echo "Already at version ${VERSION}. Skipping."
exit 0
fi

echo "Updating Android SDK from ${CURRENT_VERSION} to ${VERSION}..."

sed -i '' "s/def transact_version = \"${CURRENT_VERSION}\"/def transact_version = \"${VERSION}\"/" "$BUILD_GRADLE"

# Verify the update
NEW_VERSION=$(sed -n 's/.*def transact_version = "\([^"]*\)".*/\1/p' "$BUILD_GRADLE")
if [ "$NEW_VERSION" != "$VERSION" ]; then
echo "Error: Version update failed. Expected ${VERSION}, got ${NEW_VERSION}" >&2
exit 1
fi

echo "Android SDK updated to version ${VERSION} successfully."
Loading