Skip to content

📦 ALLG999 @ 构建027魔改版本 #301

📦 ALLG999 @ 构建027魔改版本

📦 ALLG999 @ 构建027魔改版本 #301

Workflow file for this run

name: 📦构建027魔改版本
run-name: 📦 ${{ github.actor }} @ 构建027魔改版本
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 将时区设为亚洲/上海
run: |
sudo timedatectl set-timezone Asia/Shanghai
echo "Current time: $(date)"
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 设置 JDK
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "zulu"
cache: gradle
- name: 设置 Gradle
uses: gradle/actions/setup-gradle@v4
with:
cache-read-only: false
gradle-version: wrapper
- name: 授予 gradlew 执行权限
run: chmod +x gradlew
- name: 使用 Gradle 构建
run: ./gradlew assembleNormalRelease assembleCompatibleRelease -Pversion=${{ github.ref_name }}
- name: 查找 APK 并设置输出
id: locate_apks
run: |
normal_apk=$(find app/build/outputs/apk/normal/release -name "*.apk" | head -n 1)
compatible_apk=$(find app/build/outputs/apk/compatible/release -name "*.apk" | head -n 1)
echo "normal_apk=$normal_apk" >> $GITHUB_OUTPUT
echo "compatible_apk=$compatible_apk" >> $GITHUB_OUTPUT
- name: 将 APK 复制到暂存阶段以便签名
run: |
mkdir -p app/build/outputs/apk/all
cp "${{ steps.locate_apks.outputs.normal_apk }}" app/build/outputs/apk/all/
cp "${{ steps.locate_apks.outputs.compatible_apk }}" app/build/outputs/apk/all/
- name: APK签名
id: sign_apks
uses: ilharp/sign-android-release@v2
with:
releaseDir: app/build/outputs/apk/all
signingKey: ${{ secrets.ANDROID_SIGNING_KEY }}
keyAlias: ${{ secrets.ANDROID_KEY_ALIAS }}
keyStorePassword: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
keyPassword: ${{ secrets.ANDROID_KEY_PASSWORD }}
buildToolsVersion: 36.0.0
- name: 提取签名 APK 路径
id: extract_apks
run: |
IFS=':' read -r -a files <<< "${{ steps.sign_apks.outputs.signedFiles }}"
for file in "${files[@]}"; do
if [[ "$file" == *Normal* ]]; then
echo "signed_normal=$file" >> $GITHUB_OUTPUT
elif [[ "$file" == *Compatible* ]]; then
echo "signed_compatible=$file" >> $GITHUB_OUTPUT
fi
done
- name: 更新安装包 - Compatible
uses: actions/upload-artifact@v4
with:
name: apk-compatible
path: ${{ steps.extract_apks.outputs.signed_compatible }}
- name: 更新安装包 - Normal
uses: actions/upload-artifact@v4
with:
name: apk-normal
path: ${{ steps.extract_apks.outputs.signed_normal }}
- name: 提取文件名
id: extract_info
run: |
normal_file=$(basename "${{ steps.extract_apks.outputs.signed_normal }}")
compatible_file=$(basename "${{ steps.extract_apks.outputs.signed_compatible }}")
# 提取版本号(以"Normal-"或"Compatible-"之后的部分为起点,以"-signed"之前的内容为终点)
version=$(echo "$normal_file" | sed -E 's/.*-(Normal|Compatible)-(.*)-signed\.apk/\2/')
echo "normal_file=$normal_file" >> $GITHUB_OUTPUT
echo "compatible_file=$compatible_file" >> $GITHUB_OUTPUT
echo "version=$version" >> $GITHUB_OUTPUT
- name: 生成sha256校验值
run: |
sha256sum ${{ steps.extract_apks.outputs.signed_normal }} > CHECKSUMS-Sesame-Normal-${{ steps.extract_info.outputs.version }}.${{ env.SHORT_SHA }}-signed.apk.sha256
sha256sum ${{ steps.extract_apks.outputs.signed_compatible }} > CHECKSUMS-Sesame-Compatible-${{ steps.extract_info.outputs.version }}.${{ env.SHORT_SHA }}-signed.apk.sha256
- name: 获取提交详细信息
id: commit_details
run: |
COMMIT_MESSAGE_BODY=$( \
if [[ "${{ github.event_name }}" == "push" ]]; then \
echo "🔨 $(git rev-list --count ${{ github.event.before }}..${{ github.event.after }}) new commits to ${{ github.repository }}:${{ github.ref_name }} ([compare view](https://github.com/${{ github.repository }}/compare/${{ github.event.before }}...${{ github.event.after }}))"; \
echo ""; \
git log --format=" %h ([view commit](https://github.com/${{ github.repository }}/commit/%H)): %s by %an" ${{ github.event.before }}..${{ github.event.after }}; \
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then \
echo "📦 Pull Request #${{ github.event.number }} for ${{ github.repository }}: ${{ github.head_ref }} -> ${{ github.base_ref }} ([view PR](https://github.com/${{ github.repository }}/pull/${{ github.event.number }}))"; \
echo ""; \
echo "Commits:"; \
git log --format=" %h ([view commit](https://github.com/${{ github.repository }}/commit/%H)): %s by %an" ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}; \
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then \
echo "⚙️ Manual workflow run on ${{ github.ref_name }} by ${{ github.actor }}"; \
echo ""; \
echo "Latest commit:"; \
git log -1 --format=" %h ([view commit](https://github.com/${{ github.repository }}/commit/%H)): %s by %an"; \
else \
echo "ℹ️ Commit information for ${{ github.event_name }} event on ${{ github.ref_name }} by ${{ github.actor }}:"; \
echo ""; \
git log -1 --format=" %h ([view commit](https://github.com/${{ github.repository }}/commit/%H)): %s by %an"; \
fi \
)
echo "COMMIT_MESSAGE_BODY<<EOF" >> $GITHUB_OUTPUT
echo "$COMMIT_MESSAGE_BODY" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: 向TG发送组合消息
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TG_CHAT_ID }}
token: ${{ secrets.TG_BOT_TOKEN }}
message: |
📦 *0.2.7魔改版本 ${{ steps.extract_info.outputs.version }} Build!*
```
下载说明:
Normal 为标准版本,适用于`Android 8.0`及以上的系统
Compatible 为兼容版本,适用于`Android 7.0`及以下的系统,最低支持`Android 5.1`
```
${{ steps.commit_details.outputs.COMMIT_MESSAGE_BODY }}
format: markdown
- name: 向TG发送正常版本APK
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TG_CHAT_ID }}
token: ${{ secrets.TG_BOT_TOKEN }}
document: ${{ steps.extract_apks.outputs.signed_normal }}
- name: 向TG发送兼容版本APK
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TG_CHAT_ID }}
token: ${{ secrets.TG_BOT_TOKEN }}
document: ${{ steps.extract_apks.outputs.signed_compatible }}
- name: 利用版本号创建标签
if: startsWith(github.ref, 'refs/heads/main') && github.event_name == 'push'
run: |
VERSION_TAG="v${{ steps.extract_info.outputs.version }}"
echo "Creating tag: $VERSION_TAG"
git tag "$VERSION_TAG"
git push origin "$VERSION_TAG"
- name: 将资源整合上传到你的仓库发布
uses: softprops/action-gh-release@v2
with:
name: ${{ github.event.release.tag_name || steps.extract_info.outputs.version }} # 发布的名称。默认为标签名称
files: |
${{ steps.extract_apks.outputs.signed_compatible }}
${{ steps.extract_apks.outputs.signed_normal }}
CHECKSUMS-Sesame-Normal-${{ steps.extract_info.outputs.version }}.${{ env.SHORT_SHA }}-signed.apk.sha256
CHECKSUMS-Sesame-Compatible-${{ steps.extract_info.outputs.version }}.${{ env.SHORT_SHA }}-signed.apk.sha256
tag_name: ${{ steps.extract_info.outputs.version}}
draft: false
append_body: true
generate_release_notes: true
body: |
## ✨027魔改版本更新了啥?
${{ steps.commit_details.outputs.COMMIT_MESSAGE_BODY }}
> ## 下载说明
* Normal 为正常版本,适用于`Android 8.0`及以上的系统
* Compatible 为兼容版本,适用于`Android 7.0`及以下的系统,最低支持`Android 5.1`
> ~~墙内不再更新~~ 倒卖必死全家