Compare commits
4 Commits
621618a3da
...
659c79e5dd
| Author | SHA1 | Date | |
|---|---|---|---|
|
659c79e5dd
|
|||
|
0512662466
|
|||
|
842bb0553e
|
|||
|
96e5cc1213
|
3
.build/release/.env.example
Normal file
3
.build/release/.env.example
Normal 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
2
.build/release/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.env
|
||||
release/
|
||||
11
.build/release/compose.yml
Normal file
11
.build/release/compose.yml
Normal 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
|
||||
- ./cache:/root/.gradle
|
||||
40
.build/release/create-release.sh
Normal file
40
.build/release/create-release.sh
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
TAG="$1"
|
||||
TITLE="$2"
|
||||
NOTES_FILE="$3"
|
||||
ASSET_PATH="$4"
|
||||
|
||||
API_URL="${GITEA_SERVER_URL}/api/v1/repos/${GITEA_REPOSITORY}/releases"
|
||||
|
||||
# Create release
|
||||
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"
|
||||
|
||||
# Upload asset
|
||||
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"
|
||||
17
.build/release/extract-changelog.sh
Normal file
17
.build/release/extract-changelog.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
VERSION="${1#v}"
|
||||
VERSION_CODE=$(grep 'versionCode = ' app/build.gradle.kts | sed 's/.*versionCode = \([0-9]*\).*/\1/')
|
||||
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 | tee release_notes.md > "$FASTLANE_DIR/${VERSION_CODE}.txt"
|
||||
30
.gitea/workflows/auto-tag.yml
Normal file
30
.gitea/workflows/auto-tag.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
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: Create tag if version changed
|
||||
run: |
|
||||
VERSION=$(grep 'versionName = ' app/build.gradle.kts | sed 's/.*versionName = "\(.*\)".*/\1/')
|
||||
echo "Current version: $VERSION"
|
||||
|
||||
if git tag -l | grep -q "^v${VERSION}$"; then
|
||||
echo "Tag v${VERSION} already exists, skipping"
|
||||
else
|
||||
git tag "v${VERSION}"
|
||||
git push origin "v${VERSION}"
|
||||
echo "Created and pushed tag v${VERSION}"
|
||||
fi
|
||||
38
.gitea/workflows/build-apk.yml
Normal file
38
.gitea/workflows/build-apk.yml
Normal file
@@ -0,0 +1,38 @@
|
||||
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 changelog
|
||||
run: bash .build/release/extract-changelog.sh ${{ gitea.ref_name }}
|
||||
|
||||
- name: Create Gitea Release
|
||||
env:
|
||||
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
||||
GITEA_REPOSITORY: ${{ gitea.repository }}
|
||||
GITEA_TOKEN: ${{ secrets.PAT_GITEA }}
|
||||
run: |
|
||||
bash .build/release/create-release.sh \
|
||||
"${{ gitea.ref_name }}" \
|
||||
"ISODroid ${{ gitea.ref_name }}" \
|
||||
"release_notes.md" \
|
||||
".build/release/release/ISODroid-${{ gitea.ref_name }}.apk"
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -16,3 +16,5 @@ local.properties
|
||||
|
||||
app/release/
|
||||
app/debug/
|
||||
app/key.jks
|
||||
.build/release/release/*.apk
|
||||
|
||||
@@ -136,8 +136,18 @@ android {
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
create("release") {
|
||||
storeFile = file("key.jks")
|
||||
storePassword = System.getenv("KEYSTORE_PASSWORD")
|
||||
keyAlias = System.getenv("KEY_ALIAS")
|
||||
keyPassword = System.getenv("KEY_PASSWORD")
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
signingConfig = signingConfigs.getByName("release")
|
||||
isMinifyEnabled = false
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
|
||||
Reference in New Issue
Block a user