Skip to content

Commit

Permalink
Added gitlab-publish action
Browse files Browse the repository at this point in the history
  • Loading branch information
furkanaskin authored and Furkan committed Dec 14, 2022
1 parent 21d7300 commit 24b193c
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 26 deletions.
88 changes: 68 additions & 20 deletions .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,74 @@
name: Android CI

name: Release
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
release:
types: [created]

jobs:
build:

publish:
name: Release OzanSuperApp's Library
runs-on: ubuntu-latest
permissions: write-all

steps:
- uses: actions/checkout@v3
- name: set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- uses: actions/checkout@v1

- name: Set up JDK 12
uses: actions/setup-java@v1
with:
java-version: 12

- name: Cache Gradle and wrapper
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Grant Permission for Gradlew to Execute
run: chmod +x gradlew

- name: Build AAR ⚙️🛠
run: bash ./gradlew :viewpagerdotsindicator:assemble

- name: Publish to GitLab Package Registry 🚀
run: bash ./gradlew :viewpagerdotsindicator:publish
env:
GPR_USER: ${{ github.actor }}
GPR_KEY: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLAB_REPO_URL: ${{ secrets.GITLAB_REPO_URL }}
GITLAB_DEPLOY_KEY: ${{ secrets.GITLAB_DEPLOY_KEY }}
GITLAB_DEPLOY_TOKEN: ${{ secrets.GITLAB_DEPLOY_TOKEN }}

- name: Create Release ✅
id: create_release
uses: actions/create-release@v1
env:
GPR_USER: ${{ github.actor }}
GPR_KEY: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLAB_REPO_URL: ${{ secrets.GITLAB_REPO_URL }}
GITLAB_DEPLOY_KEY: ${{ secrets.GITLAB_DEPLOY_KEY }}
GITLAB_DEPLOY_TOKEN: ${{ secrets.GITLAB_DEPLOY_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: true
prerelease: false

- name: Upload OzanSuperApp's Library AAR 🗳
uses: actions/upload-release-asset@v1
env:
GPR_USER: ${{ github.actor }}
GPR_KEY: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLAB_REPO_URL: ${{ secrets.GITLAB_REPO_URL }}
GITLAB_DEPLOY_KEY: ${{ secrets.GITLAB_DEPLOY_KEY }}
GITLAB_DEPLOY_TOKEN: ${{ secrets.GITLAB_DEPLOY_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: seatview/build/outputs/aar/seatview-release.aar
asset_name: seatview.aar
asset_content_type: application/aar
64 changes: 58 additions & 6 deletions seatview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ buildscript {
}
}
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'

android {
compileSdkVersion 31
Expand All @@ -27,11 +28,62 @@ android {
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.annotation:annotation:1.4.0'
def core_version = "1.8.0"
ext {
mGroupId = "com.ozanlimited"
mArtifactId = "seatview"
mVersionCode = 1
mVersionName = "1.0.0"

// Java language implementation
implementation "androidx.core:core:$core_version"
mLibraryName = "Seat-View"
mLibraryDescription = ""
}

task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
from android.sourceSets.main.java.srcDirs
}

afterEvaluate {
publishing {
publications {
maven(MavenPublication) {
groupId mGroupId
artifactId mArtifactId
version mVersionName

from components.release

artifact androidSourcesJar

pom {
name = mLibraryName
description = mLibraryDescription
}
}
}

repositories {
maven {
url System.getenv("GITLAB_REPO_URL")
credentials(HttpHeaderCredentials) {
name = System.getenv("GITLAB_DEPLOY_KEY")
value = System.getenv("GITLAB_DEPLOY_TOKEN")
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
}

publish.dependsOn assemble

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.annotation:annotation:1.4.0'
def core_version = "1.8.0"

// Java language implementation
implementation "androidx.core:core:$core_version"
}
}

0 comments on commit 24b193c

Please sign in to comment.