This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
name: Build Android Release
|
name: Android APK Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -6,7 +6,7 @@ on:
|
|||||||
- main
|
- main
|
||||||
- master
|
- master
|
||||||
tags:
|
tags:
|
||||||
- "*"
|
- "android-app-v*"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
@@ -16,7 +16,7 @@ permissions:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
android:
|
android:
|
||||||
name: Build Android
|
name: Build Android APK
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@@ -163,31 +163,31 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp "$apk_path" "$pkg_dir/gongyun-app-release.apk"
|
cp "$apk_path" "$pkg_dir/gongyun-android-app-release.apk"
|
||||||
ls -alh "$pkg_dir/gongyun-app-release.apk"
|
ls -alh "$pkg_dir/gongyun-android-app-release.apk"
|
||||||
|
|
||||||
- name: Rename Android APK
|
- name: Prepare Android APK artifact
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
apk="dist/android/gongyun-app-release.apk"
|
apk="dist/android/gongyun-android-app-release.apk"
|
||||||
if [ ! -f "$apk" ]; then
|
if [ ! -f "$apk" ]; then
|
||||||
echo "Release APK was not found at $apk."
|
echo "Release APK was not found at $apk."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp "$apk" gongyun-app-release.apk
|
cp "$apk" gongyun-android-app-release.apk
|
||||||
ls -alh gongyun-app-release.apk
|
ls -alh gongyun-android-app-release.apk
|
||||||
|
|
||||||
- name: Upload Android APK artifact
|
- name: Upload Android APK artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: gongyun-app-release.apk
|
name: gongyun-android-app-release.apk
|
||||||
path: gongyun-app-release.apk
|
path: gongyun-android-app-release.apk
|
||||||
|
|
||||||
- name: Publish Gitea release
|
- name: Publish Gitea release
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/android-app-v')
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
@@ -196,6 +196,7 @@ jobs:
|
|||||||
GITEA_REPO: app
|
GITEA_REPO: app
|
||||||
TAG_NAME: ${{ github.ref_name }}
|
TAG_NAME: ${{ github.ref_name }}
|
||||||
TARGET_COMMITISH: ${{ github.sha }}
|
TARGET_COMMITISH: ${{ github.sha }}
|
||||||
|
ANDROID_APK_FILE: gongyun-android-app-release.apk
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
@@ -206,6 +207,8 @@ jobs:
|
|||||||
|
|
||||||
releases_url="$GITEA_API_URL/repos/$GITEA_OWNER/$GITEA_REPO/releases"
|
releases_url="$GITEA_API_URL/repos/$GITEA_OWNER/$GITEA_REPO/releases"
|
||||||
release_by_tag_url="$releases_url/tags/$TAG_NAME"
|
release_by_tag_url="$releases_url/tags/$TAG_NAME"
|
||||||
|
export RELEASE_TITLE="Android App APK ${TAG_NAME}"
|
||||||
|
export RELEASE_BODY="Android app installation package (APK) for ${TAG_NAME}."
|
||||||
|
|
||||||
status="$(curl -sS -o release.json -w "%{http_code}" \
|
status="$(curl -sS -o release.json -w "%{http_code}" \
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
@@ -220,8 +223,8 @@ jobs:
|
|||||||
print(json.dumps({
|
print(json.dumps({
|
||||||
"tag_name": tag,
|
"tag_name": tag,
|
||||||
"target_commitish": os.environ.get("TARGET_COMMITISH", ""),
|
"target_commitish": os.environ.get("TARGET_COMMITISH", ""),
|
||||||
"name": tag,
|
"name": f"Android App APK {tag}",
|
||||||
"body": f"Automated release for {tag}.",
|
"body": f"Android app installation package (APK) for {tag}.",
|
||||||
"draft": False,
|
"draft": False,
|
||||||
"prerelease": False,
|
"prerelease": False,
|
||||||
}))
|
}))
|
||||||
@@ -250,6 +253,32 @@ jobs:
|
|||||||
PY
|
PY
|
||||||
)"
|
)"
|
||||||
|
|
||||||
|
release_update_payload="$(python3 - <<'PY'
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
print(json.dumps({
|
||||||
|
"name": os.environ["RELEASE_TITLE"],
|
||||||
|
"body": os.environ["RELEASE_BODY"],
|
||||||
|
"draft": False,
|
||||||
|
"prerelease": False,
|
||||||
|
}))
|
||||||
|
PY
|
||||||
|
)"
|
||||||
|
|
||||||
|
update_status="$(curl -sS -o release.json -w "%{http_code}" \
|
||||||
|
-X PATCH \
|
||||||
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "$release_update_payload" \
|
||||||
|
"$releases_url/$release_id")"
|
||||||
|
|
||||||
|
if [ "$update_status" != "200" ]; then
|
||||||
|
echo "Failed to update Android release metadata. HTTP status: $update_status"
|
||||||
|
cat release.json
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
assets_url="$releases_url/$release_id/assets"
|
assets_url="$releases_url/$release_id/assets"
|
||||||
|
|
||||||
curl -sS -f \
|
curl -sS -f \
|
||||||
@@ -259,8 +288,14 @@ jobs:
|
|||||||
|
|
||||||
python3 - <<'PY' > asset-ids-to-delete.txt
|
python3 - <<'PY' > asset-ids-to-delete.txt
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
names = {"gongyun-app-release.apk"}
|
tag = os.environ["TAG_NAME"]
|
||||||
|
names = {
|
||||||
|
os.environ["ANDROID_APK_FILE"],
|
||||||
|
f"gongyun-{tag}.apk",
|
||||||
|
"gongyun-app-release.apk",
|
||||||
|
}
|
||||||
with open("assets.json", encoding="utf-8") as f:
|
with open("assets.json", encoding="utf-8") as f:
|
||||||
for asset in json.load(f):
|
for asset in json.load(f):
|
||||||
if asset.get("name") in names:
|
if asset.get("name") in names:
|
||||||
@@ -276,18 +311,19 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
done < asset-ids-to-delete.txt
|
done < asset-ids-to-delete.txt
|
||||||
|
|
||||||
|
release_asset_name="gongyun-${TAG_NAME}.apk"
|
||||||
curl -sS -f \
|
curl -sS -f \
|
||||||
-X POST \
|
-X POST \
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
-F "attachment=@gongyun-app-release.apk" \
|
-F "attachment=@$ANDROID_APK_FILE" \
|
||||||
"$assets_url?name=gongyun-app-release.apk"
|
"$assets_url?name=$release_asset_name"
|
||||||
|
|
||||||
- name: Post-build disk cleanup
|
- name: Post-build disk cleanup
|
||||||
if: always()
|
if: always()
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
rm -rf build dist .dart_tool android/.gradle android/app-release.jks android/key.properties || true
|
rm -rf build dist .dart_tool android/.gradle android/app-release.jks android/key.properties gongyun-android-app-release.apk gongyun-app-release.apk || true
|
||||||
if command -v docker >/dev/null 2>&1; then
|
if command -v docker >/dev/null 2>&1; then
|
||||||
docker system prune -af --volumes || true
|
docker system prune -af --volumes || true
|
||||||
docker builder prune -af || true
|
docker builder prune -af || true
|
||||||
+1
-1
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
# In Windows, build-name is used as the major, minor, and patch parts
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 1.3.0+1
|
version: 1.3.1+2
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.11.4
|
sdk: ^3.11.4
|
||||||
|
|||||||
Reference in New Issue
Block a user