-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from Achintha444/main
build: add PR builder for the project
- Loading branch information
Showing
4 changed files
with
246 additions
and
7 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
# ------------------------------------------------------------------------------------- | ||
# | ||
# Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). | ||
# | ||
# WSO2 LLC. licenses this file to you under the Apache License, | ||
# Version 2.0 (the "License"); you may not use this file except | ||
# in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
# -------------------------------------------------------------------------------------- | ||
|
||
# This workflow will run the build for PRs to check for any build related issues. | ||
|
||
name: 👷 PR Builder | ||
|
||
on: | ||
pull_request: | ||
types: [ opened, synchronize, labeled ] | ||
branches: [ main ] | ||
paths-ignore: | ||
- "**/LICENSE" | ||
|
||
concurrency: | ||
group: pr-builder-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
GH_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN }} | ||
ANDROID_SCRIPT_DIR: .github/workflows/scripts/android | ||
DOCS_SCRIPT_DIR: .github/workflows/scripts/docs | ||
DOC_DIR: docs | ||
|
||
jobs: | ||
check_for_relevant_changes: | ||
name: 🔄 Check for Relevant Changes | ||
runs-on: ubuntu-latest | ||
outputs: | ||
android_changed: ${{ steps.check_android_changes.outputs.android_changed }} | ||
documentation_changed: ${{ steps.check_documentation_changes.outputs.documentation_changed }} | ||
steps: | ||
- name: ⬇️ Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ env.GH_TOKEN }} | ||
fetch-depth: 0 | ||
|
||
- name: 🌴 Fetch PR branch | ||
run: | | ||
if [ ${{ github.event.pull_request.head.repo.fork }} == true ]; then | ||
git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-${{ github.event.pull_request.number }} | ||
else | ||
git fetch origin ${{ github.head_ref }} | ||
fi | ||
- name: 🗃️ Get changed files | ||
id: changed-files | ||
run: | | ||
if [ ${{ github.event.pull_request.head.repo.fork }} == true ]; then | ||
echo "Comparing changes for PR from fork" | ||
git diff --name-only origin/${{ github.base_ref }}..pr-${{ github.event.pull_request.number }} > changed_files.txt | ||
fi | ||
echo "Changed files:" | ||
cat changed_files.txt | ||
- name: 🤖 Check for Android Changes | ||
id: check_android_changes | ||
run: | | ||
echo "Checking for Android changes" | ||
android_changed=false | ||
if grep -q "android/" changed_files.txt; then | ||
android_changed=true | ||
echo "Android changes detected" | ||
fi | ||
echo "android_changed=${android_changed}" >> $GITHUB_OUTPUT | ||
- name: 📑 Check for Documentation Changes | ||
id: check_documentation_changes | ||
run: | | ||
echo "Checking for Documentation changes" | ||
documentation_changed=false | ||
if grep -q "docs/" changed_files.txt; then | ||
documentation_changed=true | ||
echo "Documentation changes detected" | ||
fi | ||
echo "documentation_changed=${documentation_changed}" >> $GITHUB_OUTPUT | ||
asgardeo-android-sdk-builder: | ||
name: 🤖 🚧 Asgardeo Android SDK Builder | ||
needs: check_for_relevant_changes | ||
if: needs.check_for_relevant_changes.outputs.android_changed == 'true' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: ⬇️ Checkout | ||
id: checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ env.GH_TOKEN }} | ||
fetch-depth: 0 | ||
|
||
- name: ☕️ Set up Adopt JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: "17" | ||
distribution: "adopt" | ||
|
||
- name: 🚧 Build Asgardeo Android SDK | ||
working-directory: ${{ env.ANDROID_SCRIPT_DIR }} | ||
run: bash ./android_sdk_build.sh | ||
|
||
documentation-builder: | ||
name: 📑 🚧 Documentation Builder | ||
needs: check_for_relevant_changes | ||
if: needs.check_for_relevant_changes.outputs.documentation_changed == 'true' | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [lts/*] | ||
steps: | ||
- name: ⬇️ Checkout | ||
id: checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ env.GH_TOKEN }} | ||
fetch-depth: 0 | ||
|
||
- name: 🟢 Setup node | ||
id: setup-node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: 🧩 Install Dependencies | ||
id: install-dependencies | ||
working-directory: ${{ env.DOC_DIR }} | ||
run: npm ci | ||
|
||
- name: 🏗️ Build with VitePress | ||
id: build | ||
working-directory: ${{ env.DOC_DIR }} | ||
run: | | ||
npm run docs:build | ||
- name: ☕️ Set up Adopt JDK 17 (For Android SDK API Docs Generation) | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: "17" | ||
distribution: "adopt" | ||
|
||
- name: 🤖 Generate Android SDK API Docs | ||
working-directory: ${{ env.DOCS_SCRIPT_DIR }}/android | ||
run: bash ./dokka_build.sh |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# ------------------------------------------------------------------------------------- | ||
# | ||
# Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). | ||
# | ||
# WSO2 LLC. licenses this file to you under the Apache License, | ||
# Version 2.0 (the "License"); you may not use this file except | ||
# in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
# -------------------------------------------------------------------------------------- | ||
|
||
#!/bin/bash | ||
|
||
# Go to android sdk directory | ||
go_to_android_sdk_dir() { | ||
cd ../../../../android | ||
} | ||
|
||
# Function to regenerate Gradle wrapper | ||
regenerate_gradle_wrapper() { | ||
echo | ||
./gradlew wrapper | ||
} | ||
|
||
# Function to check Gradle wrapper | ||
check_gradle_wrapper() { | ||
echo | ||
if [ ! -f "./gradlew" ]; then | ||
echo "Gradle wrapper (./gradlew) not found. Please regenerate using './gradlew wrapper'" | ||
exit 1 | ||
fi | ||
|
||
echo "Gradle Wrapper - OK" | ||
|
||
if [ ! -f "./gradlew.bat" ]; then | ||
echo "Gradle wrapper (./gradlew.bat) not found. Please regenerate using './gradlew wrapper'" | ||
exit 1 | ||
fi | ||
|
||
echo "Gradle Wrapper (Windows) - OK" | ||
|
||
./gradlew --version | ||
if [ $? -ne 0 ]; then | ||
echo "Error: Gradle wrapper execution failed. Please check Gradle installation and configuration." | ||
exit 1 | ||
fi | ||
echo "Gradle Wrapper - OK" | ||
} | ||
|
||
# Function to build with Gradle | ||
gradle_build() { | ||
echo | ||
./gradlew clean build | ||
} | ||
|
||
# run gradle tasks to build Android SDKs | ||
build_android_sdks() { | ||
# Go to android sdk directory | ||
go_to_android_sdk_dir | ||
|
||
# Functions to release Android SDKs | ||
regenerate_gradle_wrapper | ||
check_gradle_wrapper | ||
gradle_build | ||
} | ||
|
||
# Call the functions in sequence | ||
build_android_sdks |