add CI
Some checks failed
Build and Release APK / build (push) Failing after 3s

This commit is contained in:
2026-05-14 06:17:36 +05:00
parent eda8797552
commit bff42d7981
5 changed files with 165 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
KEYSTORE_PASSWORD=your_keystore_password_here
KEY_ALIAS=your_key_alias_here
KEY_PASSWORD=your_key_password_here

2
.build/release/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.env
release/

View File

@@ -0,0 +1,11 @@
services:
release:
# image: git.shihaam.dev/dockerfiles/android-builder
image: git.shihaam.dev/dockerfiles/runners/gradle
hostname: isodroid
network_mode: host
env_file: .env
volumes:
- ./release:/release
- ../../:/source
- /root/.cache/cache-runners/gradle:/root/.gradle

View File

@@ -0,0 +1,70 @@
name: Auto Tag on Version Change
on:
push:
branches:
- main
jobs:
check-version:
runs-on: docker-compose
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT_GITEA }}
- name: Check version and prepare release
id: version
run: |
VERSION=$(grep 'versionName = ' app/build.gradle.kts | sed 's/.*versionName = "\(.*\)".*/\1/')
VERSION_CODE=$(grep 'versionCode = ' app/build.gradle.kts | sed 's/.*versionCode = \([0-9]*\).*/\1/')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "version_code=$VERSION_CODE" >> $GITHUB_OUTPUT
if git tag -l | grep -q "^v${VERSION}$"; then
echo "Tag v${VERSION} already exists, skipping"
echo "should_release=false" >> $GITHUB_OUTPUT
else
echo "New version detected: v${VERSION}"
echo "should_release=true" >> $GITHUB_OUTPUT
fi
- name: Extract and commit fastlane changelog
if: steps.version.outputs.should_release == 'true'
run: |
VERSION="${{ steps.version.outputs.version }}"
VERSION_CODE="${{ steps.version.outputs.version_code }}"
FASTLANE_DIR="fastlane/metadata/android/en-US/changelogs"
mkdir -p "$FASTLANE_DIR"
awk -v ver="$VERSION" '
BEGIN { found=0 }
/^## \[/ {
if (found) exit
if ($0 ~ "\\[" ver "\\]") { found=1; next }
}
found { print }
' CHANGELOG.md > "$FASTLANE_DIR/${VERSION_CODE}.txt"
git config user.name "Gitea Actions"
git config user.email "actions@gitea.local"
if git diff --quiet "$FASTLANE_DIR/${VERSION_CODE}.txt" 2>/dev/null; then
echo "No changelog changes to commit"
else
git add "$FASTLANE_DIR/${VERSION_CODE}.txt"
git commit -m "Add fastlane changelog for v${VERSION}"
git push origin main
fi
- name: Create and push tag
if: steps.version.outputs.should_release == 'true'
run: |
VERSION="${{ steps.version.outputs.version }}"
git tag "v${VERSION}"
git push origin "v${VERSION}"
echo "Created and pushed tag v${VERSION}"

View File

@@ -0,0 +1,79 @@
name: Build and Release APK
on:
push:
tags:
- 'v*'
jobs:
build:
runs-on: docker-compose
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Setup keystore and environment
run: |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > app/key.jks
echo "${{ secrets.DOTENV_BASE64 }}" | base64 -d > .build/release/.env
- name: Build APK
working-directory: .build/release
run: docker compose run --rm release
- name: Extract release notes
run: |
VERSION="${{ gitea.ref_name }}"
VERSION="${VERSION#v}"
awk -v ver="$VERSION" '
BEGIN { found=0 }
/^## \[/ {
if (found) exit
if ($0 ~ "\\[" ver "\\]") { found=1; next }
}
found { print }
' CHANGELOG.md > release_notes.md
- name: Create Gitea Release
env:
GITEA_SERVER_URL: ${{ gitea.server_url }}
GITEA_REPOSITORY: ${{ gitea.repository }}
GITEA_TOKEN: ${{ secrets.PAT_GITEA }}
run: |
TAG="${{ gitea.ref_name }}"
TITLE="ISODroid ${{ gitea.ref_name }}"
NOTES_FILE="release_notes.md"
ASSET_PATH=".build/release/release/ISODroid-${{ gitea.ref_name }}.apk"
API_URL="${GITEA_SERVER_URL}/api/v1/repos/${GITEA_REPOSITORY}/releases"
RELEASE_RESPONSE=$(curl -s -X POST "$API_URL" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d "{
\"tag_name\": \"${TAG}\",
\"name\": \"${TITLE}\",
\"body\": $(jq -Rs . < "$NOTES_FILE")
}")
RELEASE_ID=$(echo "$RELEASE_RESPONSE" | jq -r '.id')
if [ "$RELEASE_ID" = "null" ] || [ -z "$RELEASE_ID" ]; then
echo "Failed to create release:"
echo "$RELEASE_RESPONSE"
exit 1
fi
echo "Created release with ID: $RELEASE_ID"
ASSET_NAME=$(basename "$ASSET_PATH")
UPLOAD_URL="${API_URL}/${RELEASE_ID}/assets?name=${ASSET_NAME}"
curl -s -X POST "$UPLOAD_URL" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/octet-stream" \
--data-binary "@${ASSET_PATH}"
echo "Uploaded asset: $ASSET_NAME"