Skip to content

Commit

Permalink
Add build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kairusds committed Oct 11, 2024
1 parent 777b8a1 commit 93d8ebb
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Build Library

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]')"
steps:
- uses: actions/checkout@v4
- uses: gradle/actions/wrapper-validation@v4

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

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Setup Android ndk r15c
run: |
sudo apt install libncurses5
wget https://dl.google.com/android/repository/android-ndk-r15c-linux-x86_64.zip
unzip android-ndk-r15c-linux-x86_64.zip
echo "ndk.dir=$(realpath android-ndk-r15c)" > local.properties
- name: Setup gradle
uses: gradle/actions/setup-gradle@v4

- name: Build library
run: ./gradlew assembleRelease

- name: Set release environment variables
run: |
echo "AAR_SHA256=$(sha256sum imagefilters/build/outputs/aar/imagefilters-release.aar | awk '{ print $1 }')" >> $GITHUB_ENV
- name: Set lib version env variables
run: |
VERSION_NAME=$(grep -oP 'versionName\s*"\K[^"]+' imagefilters/build.gradle)
VERSION_CODE=$(grep -oP 'versionCode\s*\K\d+' imagefilters/build.gradle)
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV
echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_ENV
- name: Upload binaries to a release
id: release
uses: softprops/action-gh-release@v2
with:
files: |
imagefilters/build/outputs/aar/imagefilters-release.aar
tag_name: "v${{ env.VERSION_NAME }}-${{ env.VERSION_CODE }}"

- name: Edit release body
run: |
BODY=$(cat <<EOF
### Changes
$(git log --pretty=format:"- %s (@%an)" $(git describe --tags --abbrev=0 `git rev-list --tags --skip=1 --max-count=1 $TAG_NAME`)..$TAG_NAME -- . ':!.github' ':!.github/**' ':!.gitignore' ':!README.md' ':!LICENSE')
### SHA-256 Checksum of AAR
\`$AAR_SHA256\`
EOF
)
json_payload=$(jq -n --arg body "$BODY" '{body: $body}')
curl -L -X PATCH -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/$REPO/releases/$RELEASE_ID -d "$json_payload"
env:
TAG_NAME: "v${{ env.VERSION_NAME }}-${{ env.VERSION_CODE }}"
AAR_SHA256: ${{ env.AAR_SHA256 }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
RELEASE_ID: ${{ steps.release.outputs.id }}

0 comments on commit 93d8ebb

Please sign in to comment.