Build and Release #25
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Release | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 检出代码 | |
uses: actions/checkout@v3 | |
- name: 获取最新标签 | |
id: get_tag | |
run: | | |
# 获取最新发布的 tag | |
RELEASE_TAG=$(git describe --tags $(git rev-list --tags --max-count=1)) | |
echo "最新发布的 tag: $RELEASE_TAG" | |
echo "RELEASE_TAG=${RELEASE_TAG}" >> $GITHUB_ENV | |
- name: 获取当前时间 | |
id: get_time | |
run: | | |
# 获取当前时间并转换为 GMT+8 格式 | |
DATE_TIME=$(TZ='Asia/Singapore' date '+%Y%m%d_%H%M') | |
echo "当前时间: $DATE_TIME" | |
echo "DATE_TIME=${DATE_TIME}" >> $GITHUB_ENV | |
- name: 构建 APK 文件名 | |
id: build_apk_name | |
run: | | |
# 构建 APK 文件名 | |
APK_NAME="XQE_Release_${{ env.RELEASE_TAG }}_${{ env.DATE_TIME }}.apk" | |
echo "APK 文件名: $APK_NAME" | |
echo "APK_NAME=${APK_NAME}" >> $GITHUB_ENV | |
- name: 获取更新日志 | |
if: env.should_build == 'true' | |
run: | | |
CHANGELOG=$(git log ${{ env.RELEASE_TAG }}..${{ env.TAGS }} --pretty=format:"%s" | sed 's/^/ - /') | |
echo "更新日志:" | |
echo "${CHANGELOG}" | |
echo "CHANGELOG=${CHANGELOG}" >> $GITHUB_ENV | |
- name: 输出更新日志 | |
if: env.should_build == 'true' | |
run: | | |
echo "更新日志: ${{ env.CHANGELOG }}" | |
- name: 安装 JDK 和 Gradle | |
if: env.should_build == 'true' | |
run: | | |
sudo apt update | |
sudo apt install -y openjdk-11-jdk | |
wget | |
unzip gradle-7.6-bin.zip | |
sudo mv gradle-7.6 /opt/gradle | |
sudo ln -s /opt/gradle/bin/gradle /usr/local/bin/gradle | |
- name: 验证 Gradle 和 JDK 安装 | |
if: env.should_build == 'true' | |
run: | | |
java -version | |
gradle -v | |
- name: 打包 myLazyNoSo 分支 (Gradle) | |
if: env.should_build == 'true' | |
run: | | |
echo "开始打包 myLazyNoSo 分支..." | |
./gradlew clean assembleCompatibleRelease | |
- name: 发布到 GitHub | |
if: env.should_build == 'true' | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ env.RELEASE_TAG }} | |
name: "XQE_lazy_${{ env.TAGS }}" | |
body: ${{ env.CHANGELOG }} # 更新日志 | |
files: build/outputs/apk/compatible/release/*.apk | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: 重命名 APK 文件 | |
if: env.should_build == 'true' | |
run: | | |
mv build/outputs/apk/compatible/release/*.apk build/outputs/apk/compatible/release/${{ env.APK_NAME }} | |
echo "APK 文件已重命名为: ${{ env.APK_NAME }}" |