-
Notifications
You must be signed in to change notification settings - Fork 2
135 lines (116 loc) · 5.28 KB
/
Build-Release-AndroidX.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Github Actions AndroidX
# 注意:如果您的默認分支不是main,請更新的值 DEFAULT_BRANCH 以匹配存儲庫的默認分支名稱
# on: [push, pull_request]
# 注意该分支下release的suffix为: "-androidx"
on:
push:
branches: [ master-al-open-androidx ]
tags:
- 'v*'
pull_request:
branches: [ master-al-open-androidx ]
jobs:
AndroidXBuild:
runs-on: ubuntu-latest
steps:
#- uses: einaregilsson/build-number@v3
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
- name: current release suffix
run: echo "releaseSuffix=-androidx" >> $GITHUB_ENV
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Envinfo
run: npx envinfo
- name: Build application
run: |
echo ` git log --first-parent --pretty=%d | grep -m1 tag: `
yarn install && chmod +x gradlew && ./gradlew build && ./gradlew assembleRelease
du -shc `find . -regex '.+\.\(apk\|aab\)$'`
# run: yarn install && cd android && chmod +x gradlew && ./gradlew assembleRelease
- name: Print Get current Tag
run: |
branch_name=` git symbolic-ref -q --short HEAD || git describe --tags --exact-match `
CURRENT_TAG_NAME=` git describe --tag $(git rev-parse --verify refs/remotes/origin/$branch_name"") `
echo "CURRENT_TAG_NAME IS $CURRENT_TAG_NAME"
if [[ $CURRENT_TAG_NAME =~ ${{ env.releaseSuffix }} ]];
then
echo 'include'
else
echo 'exclusive'
CURRENT_TAG_NAME=2.0.0
fi
echo "CURRENT_TAG_NAME IS $CURRENT_TAG_NAME"
CURRENT_TAG_NAME=${CURRENT_TAG_NAME%%${{ env.releaseSuffix }}*}
TAG_VERSION_NAME=$CURRENT_TAG_NAME
TAG_VERSION_NAME=$( echo "${TAG_VERSION_NAME%.*}.$((${TAG_VERSION_NAME##*.}+1))" )
while [ "$(echo ` git rev-parse --verify --quiet $TAG_VERSION_NAME${{ env.releaseSuffix }} `)" ]
do
echo "do not is empty by TAG_VERSION_NAME :$TAG_VERSION_NAME"
TAG_VERSION_NAME=$( echo "${TAG_VERSION_NAME%.*}.$((${TAG_VERSION_NAME##*.}+1))" )
done
echo "done is empty by TAG_VERSION_NAME :$TAG_VERSION_NAME"
echo "branchName=$branch_name" >> $GITHUB_ENV
echo "current_tag_name=$CURRENT_TAG_NAME" >> $GITHUB_ENV
echo "tag_name=$TAG_VERSION_NAME" >> $GITHUB_ENV
# 循环验证当前git是否存在TAG_VERSION_NAME,如果存在则尾号+1 -z 判断是空
# while [ -z "$(echo ` git rev-parse --verify --quiet $TAG_VERSION_NAME `)" ]
# 如果当前git中存在生成的git Tag版本,则尾号+1
# 如果当前git中不存在生成的git Tag版本,则继续执行
# TAG_VERSION_NAME=$( echo "${TAG_VERSION_NAME%.*}.$((${TAG_VERSION_NAME##*.}+1))" )
# echo "Build changelog is ${{ steps.changelog.outputs.changelog }}"
# echo "Build Commit Body is ${{ steps.createDraft.outputs.body }}"
# echo $NEXT_PATCH_VERSION $BUILD_NUMBER
- name: Generate changelog
id: changelog
uses: metcalfc/[email protected]
with:
myToken: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare Release
id: prepare_release
run: |
APK_PATH=`find . -name '*.apk' | grep release`
echo ::set-output name=apk_path::$APK_PATH
APK_NAME=`basename $APK_PATH`
echo ::set-output name=apk_name::$APK_NAME
# 選用
# TAG_NAME=`echo $GITHUB_REF | cut -d / -f3`
# echo ::set-output name=tag_name::$TAG_NAME
# PACKAGE_NAME=`./tools/aapt2 dump packagename $APK_PATH`
# echo ::set-output name=package_name::$PACKAGE_NAME
#Uploads
- name: Upload Artifact
if: steps.prepare_release.outputs.apk_path
uses: actions/upload-artifact@v1
with:
name: app-release.apk
path: app/build/outputs/apk/release/
# path: build/app/outputs/apk/release/
- name: Create GitHub release
id: create_release
# if: steps.version_check.outputs.changed == 'true'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.tag_name }}${{ env.releaseSuffix }}
release_name: ${{ env.tag_name }}${{ env.releaseSuffix }}
commitish: ${{ env.branchName }}
body: |
![release!](https://i.giphy.com/media/lPulaaB9lDMnGZiivs/source.gif)
# Changelog
${{ steps.changelog.outputs.changelog }}
# 预发布 prerelease : true ,草稿 draft: true
prerelease: false
draft: false
- name: Upload APK Asset
if: steps.create_release.outputs.upload_url && steps.prepare_release.outputs.apk_path && steps.prepare_release.outputs.apk_name
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{steps.create_release.outputs.upload_url}}
asset_path: ${{steps.prepare_release.outputs.apk_path}}
asset_name: ${{steps.prepare_release.outputs.apk_name}}
asset_content_type: application/vnd.android.package-archive