Release Android SDK #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release Android SDK | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version bump type (or "current" to re-release)' | |
| required: true | |
| type: choice | |
| options: | |
| - current | |
| - patch | |
| - minor | |
| - major | |
| default: patch | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Calculate version | |
| id: version | |
| run: | | |
| CURRENT_VERSION=$(jq -r '.android' locanara-versions.json) | |
| echo "Current version: $CURRENT_VERSION" | |
| if [ "${{ github.event.inputs.version }}" = "current" ]; then | |
| NEW_VERSION="$CURRENT_VERSION" | |
| else | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION" | |
| case "${{ github.event.inputs.version }}" in | |
| major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;; | |
| minor) MINOR=$((MINOR + 1)); PATCH=0 ;; | |
| patch) PATCH=$((PATCH + 1)) ;; | |
| esac | |
| NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}" | |
| fi | |
| echo "New version: $NEW_VERSION" | |
| echo "VERSION=$NEW_VERSION" >> $GITHUB_ENV | |
| echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| - name: Commit version update | |
| if: github.event.inputs.version != 'current' | |
| run: | | |
| # Update version files | |
| jq --arg version "$VERSION" '.android = $version' locanara-versions.json > tmp.json | |
| mv tmp.json locanara-versions.json | |
| cp locanara-versions.json packages/site/locanara-versions.json | |
| # Sync versions to all package.json files | |
| bun run version:sync | |
| # Commit directly to main | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add locanara-versions.json packages/site/locanara-versions.json package.json packages/gql/package.json packages/android/package.json | |
| if git diff --staged --quiet; then | |
| echo "No version changes to commit" | |
| else | |
| git commit -m "chore: bump android SDK to $VERSION" | |
| git pull --rebase origin main || true | |
| git push origin main | |
| fi | |
| - name: Build and publish to Maven Central | |
| working-directory: packages/android | |
| env: | |
| ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} | |
| ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} | |
| ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }} | |
| ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_KEY_PASSWORD }} | |
| run: | | |
| ./gradlew :locanara:publishAllPublicationsToMavenCentralRepository \ | |
| -Psdk.version=$VERSION | |
| - name: Create Git tag | |
| run: | | |
| TAG_NAME="android-$VERSION" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # Delete existing tag if re-releasing | |
| if [ "${{ github.event.inputs.version }}" = "current" ]; then | |
| git push origin --delete "$TAG_NAME" 2>/dev/null || true | |
| git tag -d "$TAG_NAME" 2>/dev/null || true | |
| fi | |
| git tag -a "$TAG_NAME" -m "Android SDK $VERSION" | |
| git push origin "$TAG_NAME" | |
| - name: Create release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG_NAME="android-$VERSION" | |
| # Delete existing release if re-releasing | |
| if [ "${{ github.event.inputs.version }}" = "current" ]; then | |
| gh release delete "$TAG_NAME" --yes 2>/dev/null || true | |
| fi | |
| gh release create "$TAG_NAME" \ | |
| --title "Android SDK $VERSION" \ | |
| --notes "Locanara Android SDK v$VERSION | |
| ## Installation (Maven Central) | |
| \`\`\`kotlin | |
| // build.gradle.kts | |
| implementation(\"com.locanara:locanara:$VERSION\") | |
| \`\`\` | |
| ## Features | |
| - Gemini Nano (ML Kit GenAI) | |
| ## Requirements | |
| - Android 8+ (API 26+) | |
| " | |
| - name: Summary | |
| run: | | |
| echo "## Android SDK Released" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Version:** $VERSION" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Installation (Maven Central)" >> $GITHUB_STEP_SUMMARY | |
| echo '```kotlin' >> $GITHUB_STEP_SUMMARY | |
| echo "implementation(\"com.locanara:locanara:$VERSION\")" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |