Skip to content

Commit

Permalink
Change maven artifactId to sdk-android (#235)
Browse files Browse the repository at this point in the history
* Remove github_actor

* Use custom git commands instead

* Grab from cargo file instead

* Add workflow for cleaning up old packages

* Only specify min-versions-to-keep

* Update name

---------

Co-authored-by: Matt Bishop <[email protected]>
  • Loading branch information
Hinton and withinfocus authored Sep 21, 2023
1 parent 2519876 commit 0185899
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 22 deletions.
15 changes: 1 addition & 14 deletions .github/workflows/build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,10 @@ jobs:
working-directory: languages/kotlin
run: ./build-schemas.sh

- name: Login to Azure - CI Subscription
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
with:
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}

- name: Retrieve bot secrets
id: retrieve-bot-secrets
uses: bitwarden/gh-actions/get-keyvault-secrets@8fccdaea2810d5dfb13753b6dd93bbd3a63ff82e
with:
keyvault: bitwarden-ci
secrets: "github-pat-bitwarden-devops-bot-packages-scope"

- name: Publish
uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # v2.8.0
with:
arguments: sdk:publish
build-root-directory: languages/kotlin
env:
GITHUB_ACTOR: "bitwarden-devops-bot"
GITHUB_TOKEN: ${{ steps.retrieve-bot-secrets.outputs.github-pat-bitwarden-devops-bot-packages-scope }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25 changes: 25 additions & 0 deletions .github/workflows/delete-old-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Delete old packages

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

defaults:
run:
shell: bash

jobs:
delete:
name: Cleanup Android SDK
runs-on: ubuntu-22.04
steps:
- uses: actions/delete-package-versions@0d39a63126868f5eefaa47169615edd3c0f61e20 # v4.1.1
with:
package-name: com.bitwarden.sdk-android
package-type: maven
min-versions-to-keep: 25

# Ignore versions only containing version numbers
ignore-versions: '^\\d*\\.\\d*\\.\\d*$'
2 changes: 1 addition & 1 deletion languages/kotlin/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ android {
}

dependencies {
// implementation 'com.bitwarden.sdk'
// implementation 'com.bitwarden.sdk-android'
implementation project(':sdk')

implementation 'androidx.core:core-ktx:1.8.0'
Expand Down
24 changes: 17 additions & 7 deletions languages/kotlin/sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
id 'maven-publish'
id 'com.palantir.git-version' version '3.0.0'
}

android {
Expand Down Expand Up @@ -42,14 +41,25 @@ publishing {
publications {
maven(MavenPublication) {
groupId = 'com.bitwarden'
artifactId = 'sdk'
artifactId = 'sdk-android'

def details = versionDetails()
// Determine the version from the git history.
//
// PRs: use the branch name.
// Master: Grab it from `crates/bitwarden/Cargo.toml`

if (details.branchName == null) {
version = "master-SNAPSHOT"
def branchName = "git branch --show-current".execute().text.trim()

if (branchName == null) {
def content = ['grep', '-o', '^version = ".*"', '../../crates/bitwarden/Cargo.toml'].execute().text.trim()
def match = ~/version = "(.*)"/
def matcher = match.matcher(content)
matcher.find()

version = "${matcher.group(1)}-SNAPSHOT"
} else {
version "${details.branchName.replaceAll('/', '-')}-SNAPSHOT"
// branchName-SNAPSHOT
version = "${branchName.replaceAll('/', '-')}-SNAPSHOT"
}

afterEvaluate {
Expand All @@ -60,7 +70,7 @@ publishing {
repositories {
maven {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/bitwarden/sdk-maven"
url = "https://maven.pkg.github.com/bitwarden/sdk"
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
Expand Down

0 comments on commit 0185899

Please sign in to comment.