Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/copilot-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copilot Code Review Workflow
# Triggers GitHub Copilot automated code review on pull requests targeting the default branch.
#
# Prerequisites (one-time repo setup):
# 1. Go to Settings → Copilot → Policies → Code review
# 2. Enable "Copilot code review" for this repository
# 3. Optionally configure custom review instructions in .github/copilot-instructions.md
#
# This workflow explicitly requests a Copilot review using the gh CLI so that
# reviews are consistently triggered even without the automatic review setting.

name: Copilot Code Review

on:
pull_request:
types:
- opened
- synchronize
- ready_for_review
branches:
- master
- main

permissions:
contents: read
pull-requests: write

jobs:
copilot-review:
name: Request Copilot Review
runs-on: ubuntu-latest
# Skip draft PRs — only review when the PR is ready
if: github.event.pull_request.draft == false

steps:
- name: Request GitHub Copilot review
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api \
repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers \
--method POST \
--field 'reviewers[]=copilot-pull-request-reviewer' || true
# `|| true` prevents failure if Copilot review is not enabled for the repo;
# the PR verification workflow still gates the merge.
105 changes: 105 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Automated Release Workflow
# Trigger from Actions UI: select major/minor/patch, click "Run workflow".
# Bumps version, commits, tags, builds, publishes to GitHub Packages,
# and creates a GitHub Release — fully automated.

name: Create Release

on:
workflow_dispatch:
inputs:
bump:
description: 'Release type'
required: true
type: choice
options:
- patch
- minor
- major

permissions:
contents: write
packages: write

jobs:
release:
name: Bump, Build, Publish & Release
runs-on: ubuntu-latest

steps:
- name: Checkout source
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Compute next version
id: version
run: |
CURRENT=$(grep '^VERSION_NAME=' gradle.properties | cut -d= -f2)
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"

case "${{ inputs.bump }}" in
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
patch) PATCH=$((PATCH + 1)) ;;
esac

NEXT="${MAJOR}.${MINOR}.${PATCH}"
echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
echo "next=$NEXT" >> "$GITHUB_OUTPUT"
echo "tag=v${NEXT}" >> "$GITHUB_OUTPUT"
echo "Bumping $CURRENT → $NEXT (${{ inputs.bump }})"

- name: Update version in gradle.properties
run: sed -i "s/^VERSION_NAME=.*/VERSION_NAME=${{ steps.version.outputs.next }}/" gradle.properties

- name: Update version in library/build.gradle.kts
run: sed -i 's/version = ".*"/version = "${{ steps.version.outputs.next }}"/' library/build.gradle.kts

- name: Commit version bump
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add gradle.properties library/build.gradle.kts
git commit -m "Release ${{ steps.version.outputs.next }}"

- name: Create and push tag
run: |
git tag "${{ steps.version.outputs.tag }}"
git push origin HEAD "${{ steps.version.outputs.tag }}"

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts', '**/gradle-wrapper.properties', '**/libs.versions.toml') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Make gradlew executable
run: chmod +x ./gradlew

- name: Build release
run: ./gradlew :library:assembleRelease

- name: Publish to GitHub Packages
run: ./gradlew :library:publish
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: ${{ steps.version.outputs.tag }}
generate_release_notes: true
files: library/build/outputs/aar/library-release.aar
76 changes: 76 additions & 0 deletions .github/workflows/instrumented-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Instrumented Test Workflow (Optional)
# Runs Android instrumented (UI) tests on an emulator.
# Can be triggered manually or automatically on release branches / release tags.
#
# Note: Emulator-based jobs are slow (~15–20 min). Run on-demand or limit to
# release branches to avoid blocking day-to-day development.

name: Instrumented Tests

on:
# Manual trigger — useful for pre-release validation
workflow_dispatch:

# Automatically run on release branches and tags
push:
branches:
- 'release/**'
tags:
- 'v*'

permissions:
contents: read
checks: write

jobs:
instrumented-tests:
name: Instrumented Tests (API 34)
runs-on: ubuntu-latest

steps:
- name: Checkout source
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts', '**/gradle-wrapper.properties', '**/libs.versions.toml') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Make gradlew executable
run: chmod +x ./gradlew

- name: Enable KVM for hardware acceleration
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm

- name: Run instrumented tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 34
target: google_apis
arch: x86_64
profile: Nexus 6
script: ./gradlew connectedAndroidTest

- name: Upload instrumented test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: instrumented-test-reports
path: |
**/build/reports/androidTests/
**/build/outputs/androidTest-results/
retention-days: 14
63 changes: 63 additions & 0 deletions .github/workflows/pr-verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# PR Verification Workflow
# Runs on every pull request targeting the default branch.
# Builds the project, runs unit tests, and uploads test reports.
#
# Branch protection recommendation:
# - Require this workflow to pass before merging
# - Require at least 1 approving review
# - Require branches to be up to date before merging
# - Restrict force-pushes to the default branch

name: PR Verification

on:
pull_request:
branches:
- master
- main

permissions:
contents: read
checks: write
pull-requests: write

jobs:
build-and-test:
name: Build & Unit Test
runs-on: ubuntu-latest

steps:
- name: Checkout source
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts', '**/gradle-wrapper.properties', '**/libs.versions.toml') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Make gradlew executable
run: chmod +x ./gradlew

- name: Build and run unit tests
run: ./gradlew build test

- name: Upload test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: test-reports
path: |
**/build/reports/tests/
**/build/test-results/
retention-days: 14
68 changes: 68 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Release Publish Workflow
# Triggered by a version tag push (e.g. v2.0.0, v2.1.0-rc1).
# Builds the library and publishes the release AAR to GitHub Packages.
#
# Publishing coordinates (GitHub Packages):
# groupId: com.pddstudio
# artifactId: highlightjs-android
# registry: https://maven.pkg.github.com/pddstudio/highlightjs-android
#
# Consumers add the following to their build.gradle.kts:
# repositories {
# maven {
# url = uri("https://maven.pkg.github.com/pddstudio/highlightjs-android")
# credentials {
# username = "<github-username>"
# password = "<github-pat-with-read:packages>"
# }
# }
# }
# implementation("com.pddstudio:highlightjs-android:<version>")

name: Release

on:
push:
tags:
- 'v*'

permissions:
contents: read
packages: write

jobs:
publish:
name: Publish to GitHub Packages
runs-on: ubuntu-latest

steps:
- name: Checkout source
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts', '**/gradle-wrapper.properties', '**/libs.versions.toml') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Make gradlew executable
run: chmod +x ./gradlew

- name: Build release
run: ./gradlew :library:assembleRelease

- name: Publish to GitHub Packages
run: ./gradlew :library:publish
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading
Loading