Skip to content

Commit f8fe5cb

Browse files
Create github action for publishing (#134)
* Initial github actions * Correct workflow for publish * Add version check * Remove circleci
1 parent 44bd67c commit f8fe5cb

File tree

3 files changed

+128
-1
lines changed

3 files changed

+128
-1
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Publish Java Release
2+
3+
on:
4+
workflow_dispatch: # Allows manual triggering
5+
# No inputs needed here if java-version is fixed and others are secrets
6+
# If you still want to override java-version occasionally, you could add:
7+
# inputs:
8+
# java-version-override:
9+
# description: 'Optional: Specify Java version for SDKMAN (e.g., 17.0.11-tem). Defaults to Java 17.'
10+
# required: false
11+
# default: '17.0.11-tem'
12+
13+
jobs:
14+
publish:
15+
runs-on: ubuntu-latest
16+
environment: release # Optional: configure an environment if you use environment-specific secrets or protection rules
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Verify version against branch name
22+
shell: bash
23+
run: |
24+
BRANCH_NAME="${{ github.ref_name }}"
25+
echo "Current branch: $BRANCH_NAME"
26+
27+
if [[ "$BRANCH_NAME" == "master" ]]; then
28+
echo "Skipping version check for master branch."
29+
exit 0
30+
fi
31+
32+
if [[ ! -f .version ]]; then
33+
echo "Error: .version file not found!"
34+
exit 1
35+
fi
36+
37+
# Read the version file and trim whitespace
38+
VERSION_FROM_FILE=$(cat .version | xargs)
39+
40+
if [[ -z "$VERSION_FROM_FILE" ]]; then
41+
echo "Error: .version file is empty or contains only whitespace!"
42+
exit 1
43+
fi
44+
45+
echo "Version from .version file: '$VERSION_FROM_FILE'"
46+
echo "Branch name: '$BRANCH_NAME'"
47+
48+
if [[ "$VERSION_FROM_FILE" != "$BRANCH_NAME" ]]; then
49+
echo "Error: mismatched version file against branch. Version file: '$VERSION_FROM_FILE', Branch: '$BRANCH_NAME'"
50+
exit 1
51+
else
52+
echo "Version file content matches branch name. Proceeding..."
53+
fi
54+
55+
- name: Setup Java 17
56+
id: setup_java
57+
shell: bash
58+
run: |
59+
echo "Starting Java setup..."
60+
curl -s "https://get.sdkman.io" | bash
61+
# Ensure SDKMAN environment variables are available for the current shell and subsequent steps
62+
# Using $HOME is generally more portable than /home/runner
63+
source "$HOME/.sdkman/bin/sdkman-init.sh"
64+
65+
# List available Java versions (optional, for debugging)
66+
sdk list java
67+
68+
# Install and set Java 17 (e.g., Temurin 17.0.11)
69+
# You can replace '17.0.11-tem' with the specific Java 17 distribution and version you prefer from 'sdk list java'
70+
JAVA_VERSION_TO_INSTALL="17.0.11-tem"
71+
# If you added java-version-override input:
72+
# JAVA_VERSION_TO_INSTALL="${{ github.event.inputs.java-version-override || '17.0.11-tem' }}"
73+
74+
sdk install java "$JAVA_VERSION_TO_INSTALL"
75+
sdk default java "$JAVA_VERSION_TO_INSTALL"
76+
77+
INSTALLED_JAVA_HOME=$(sdk home java "$JAVA_VERSION_TO_INSTALL")
78+
echo "JAVA_HOME_PATH=$INSTALLED_JAVA_HOME" >> $GITHUB_ENV
79+
echo "Successfully set up Java $JAVA_VERSION_TO_INSTALL"
80+
echo "JAVA_HOME is now $INSTALLED_JAVA_HOME"
81+
java -version
82+
83+
- name: Validate Gradle Wrapper
84+
uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # pin@1.1.0
85+
env:
86+
JAVA_HOME: ${{ env.JAVA_HOME_PATH }}
87+
88+
- name: Publish Android/Java Packages to Maven
89+
shell: bash
90+
run: ./gradlew publish -PisSnapshot=false --stacktrace
91+
env:
92+
JAVA_HOME: ${{ env.JAVA_HOME_PATH }}
93+
MAVEN_USERNAME: ${{ secrets.OSSR_USERNAME }}
94+
MAVEN_PASSWORD: ${{ secrets.OSSR_TOKEN }}
95+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
96+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}

.github/workflows/test.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build and Test
2+
3+
on:
4+
merge_group:
5+
workflow_dispatch:
6+
pull_request:
7+
branches:
8+
- main
9+
push:
10+
branches:
11+
- main
12+
13+
permissions:
14+
contents: read
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
19+
20+
jobs:
21+
unit:
22+
name: Run Unit Tests
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- uses: ./.github/actions/setup
29+
30+
- run: ./gradlew clean test jacocoTestReport lint --continue --console=plain --max-workers=1 --no-daemon
31+
32+
- uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # pin@4.5.0

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Guardian SDK for Android
22

3-
[![CircleCI](https://img.shields.io/circleci/project/github/auth0/Guardian.Android.svg)](https://circleci.com/gh/auth0/Guardian.Android)
43
[![Coverage Status](https://img.shields.io/codecov/c/github/auth0/Guardian.Android/master.svg)](https://codecov.io/github/auth0/Guardian.Android)
54
[![License](http://img.shields.io/:license-mit-blue.svg)](http://doge.mit-license.org)
65
[![Maven Central](https://img.shields.io/maven-central/v/com.auth0.android/guardian.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.auth0.android%22%20AND%20a%3A%22guardian%22)

0 commit comments

Comments
 (0)