Adapt Session Service to reference implementation #91
This file contains 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: CI | ||
on: | ||
workflow_dispatch: {} | ||
push: | ||
branches: | ||
- main | ||
- master | ||
- beta | ||
- 'sdk-release/**' | ||
- 'feature/**' | ||
- development | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+*' | ||
pull_request: | ||
branches: | ||
- main | ||
- master | ||
- beta | ||
- 'sdk-release/**' | ||
- 'feature/**' | ||
- development | ||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Setup Java | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: "17" # always use 17 LTS for building | ||
distribution: zulu | ||
architecture: x64 | ||
- name: Cache Maven dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ hashFiles('**/src/**') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven | ||
- name: Configure GPG Key | ||
run: | | ||
echo "$GPG_PRIVATE_KEY" | base64 --decode | gpg --batch --import | ||
env: | ||
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | ||
- name: Install dependencies | ||
run: mvn clean install -DskipTests | ||
- name: Save Maven build artifacts | ||
if: success() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: maven-artifacts | ||
path: target/ | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
needs: build # Ensure build job runs before this one | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
java-version: ["8", "11", "17", "18", "19", "20"] | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Download build artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: maven-artifacts | ||
- name: Setup Test Java Runtime | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: ${{ matrix.java-version }} | ||
distribution: zulu | ||
architecture: x64 | ||
- name: Cache Maven dependencies for tests | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ matrix.java-version }}-${{ hashFiles('**/pom.xml') }}-${{ hashFiles('**/src/**') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
- name: Run test suite | ||
env: | ||
CORBADO_API_SECRET: ${{ secrets.CORBADO_API_SECRET }} | ||
CORBADO_PROJECT_ID: ${{ secrets.CORBADO_PROJECT_ID }} | ||
CORBADO_BACKEND_API: ${{ vars.CORBADO_BACKEND_API }} | ||
CORBADO_FRONTEND_API: ${{ vars.CORBADO_FRONTEND_API }} | ||
run: mvn --batch-mode --update-snapshots verify -DskipInstall | ||
deploy: | ||
name: Deploy to Maven Central | ||
runs-on: ubuntu-latest | ||
needs: [build,test] | ||
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' # Only run on version tags or if triggered manually | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Download build artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: maven-artifacts | ||
- name: Setup Java | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: "17" | ||
distribution: zulu | ||
architecture: x64 | ||
server-id: central | ||
- name: Cache Maven dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ hashFiles('**/src/**') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
- name: Setup GPG for Signing | ||
run: | | ||
echo "${{ secrets.GPG_PRIVATE_KEY }}" | base64 --decode | gpg --batch --import | ||
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf | ||
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf | ||
gpg-connect-agent reloadagent /bye | ||
- name: Setup maven | ||
uses: s4u/[email protected] | ||
with: | ||
githubServer: false | ||
servers: '[{"id": "central", "username": "${{ vars.OSSRH_USERNAME }}", "password": "${{ secrets.OSSRH_PASSWORD }}"}]' | ||
- name: Deploy to Maven Central | ||
env: | ||
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | ||
run: mvn deploy -DskipTests -P release | ||