|
1 | 1 | name: Release Build
|
2 | 2 |
|
3 | 3 | on:
|
4 |
| -# push: |
5 |
| -# branches: |
6 |
| -# - master |
7 |
| -# paths: |
8 |
| -# - 'CHANGELOG.md' |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - 'CHANGELOG.md' |
| 9 | + pull_request: |
9 | 10 | workflow_dispatch:
|
| 11 | +# watch: |
| 12 | +# types: [started] |
| 13 | +# schedule: |
| 14 | +# - cron: '0 4 * * *' |
| 15 | + |
| 16 | +#concurrency: |
| 17 | +# group: ${{ github.ref }}-${{ github.workflow }} |
| 18 | +# cancel-in-progress: true |
10 | 19 |
|
11 | 20 | jobs:
|
12 | 21 | prepare:
|
13 | 22 | runs-on: ubuntu-latest
|
14 |
| - if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' |
| 23 | + env: |
| 24 | + GIT_TOKEN: ${{secrets.ACTIONS_TOKEN}} |
| 25 | + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' |
15 | 26 | outputs:
|
16 | 27 | version: ${{ steps.set-ver.outputs.version }}
|
17 |
| - play: ${{ steps.check.outputs.play }} |
18 |
| - sign: ${{ steps.check.outputs.sign }} |
| 28 | + # play: ${{ steps.check.outputs.play }} |
| 29 | + # sign: ${{ steps.check.outputs.sign }} |
19 | 30 | steps:
|
| 31 | + - name: Setup timezone |
| 32 | + |
| 33 | + with: |
| 34 | + timezoneLinux: 'Asia/Shanghai' |
| 35 | + - uses: actions/checkout@v4 |
| 36 | + with: |
| 37 | + fetch-depth: 0 |
| 38 | + token: ${{env.GIT_TOKEN}} |
20 | 39 | - id: set-ver
|
21 | 40 | run: |
|
22 |
| - echo "version=$(date -d "8 hour" -u +3.%y.%m%d%H)" >> $GITHUB_OUTPUT |
23 |
| - - id: check |
24 |
| - run: | |
25 |
| - if [ ! -z "${{ secrets.RELEASE_KEY_STORE }}" ]; then |
26 |
| - echo "sign=yes" >> $GITHUB_OUTPUT |
27 |
| - fi |
28 |
| - if [ ! -z "${{ secrets.SERVICE_ACCOUNT_JSON }}" ]; then |
29 |
| - echo "play=yes" >> $GITHUB_OUTPUT |
30 |
| - fi |
| 41 | + echo "version=$(date -d "8 hour" -u +3.%y.%m%d%H%M)" >> $GITHUB_OUTPUT |
| 42 | +
|
| 43 | + # - id: check |
| 44 | + # run: | |
| 45 | + # if [ ! -z "${{ secrets.RELEASE_KEY_STORE }}" ]; then |
| 46 | + # echo "sign=yes" >> $GITHUB_OUTPUT |
| 47 | + # fi |
| 48 | + # if [ ! -z "${{ secrets.SERVICE_ACCOUNT_JSON }}" ]; then |
| 49 | + # echo "play=yes" >> $GITHUB_OUTPUT |
| 50 | + # fi |
31 | 51 |
|
32 | 52 | build:
|
33 | 53 | needs: prepare
|
34 |
| - if: ${{ needs.prepare.outputs.sign }} |
| 54 | + # if: ${{ needs.prepare.outputs.sign }} |
35 | 55 | strategy:
|
36 | 56 | matrix:
|
37 |
| - product: [ app, google ] |
| 57 | + product: [Google] |
| 58 | + type: [Firefly, Original] |
38 | 59 | fail-fast: false
|
39 | 60 | runs-on: ubuntu-latest
|
40 | 61 | env:
|
| 62 | + GIT_TOKEN: ${{secrets.ACTIONS_TOKEN}} |
41 | 63 | product: ${{ matrix.product }}
|
| 64 | + type: ${{ matrix.type }} |
42 | 65 | VERSION: ${{ needs.prepare.outputs.version }}
|
43 |
| - play: ${{ needs.prepare.outputs.play }} |
| 66 | + # play: ${{ needs.prepare.outputs.play }} |
44 | 67 | steps:
|
45 | 68 | - uses: actions/checkout@v4
|
46 |
| - |
47 | 69 | - name: Set up JDK 17
|
48 | 70 | uses: actions/setup-java@v4
|
49 | 71 | with:
|
50 | 72 | distribution: 'temurin'
|
51 | 73 | java-version: 17
|
52 |
| - |
53 |
| - - name: Release Apk Sign |
| 74 | + - name: Clear 18PlusList.txt |
54 | 75 | run: |
|
55 |
| - # not use this output |
56 |
| - # echo "KeyStore=yes" >> $GITHUB_OUTPUT |
57 |
| - echo -e "\n" >> gradle.properties |
58 |
| - echo RELEASE_KEY_ALIAS='${{ secrets.RELEASE_KEY_ALIAS }}' >> gradle.properties |
59 |
| - echo RELEASE_KEY_PASSWORD='${{ secrets.RELEASE_KEY_PASSWORD }}' >> gradle.properties |
60 |
| - echo RELEASE_STORE_PASSWORD='${{ secrets.RELEASE_STORE_PASSWORD }}' >> gradle.properties |
61 |
| - echo RELEASE_STORE_FILE='./key.jks' >> gradle.properties |
62 |
| - echo ${{ secrets.RELEASE_KEY_STORE }} | base64 --decode > $GITHUB_WORKSPACE/app/key.jks |
63 |
| -
|
64 |
| - - name: Unify Version Name |
| 76 | + echo "清空18PlusList.txt" |
| 77 | + echo "">$GITHUB_WORKSPACE/app/src/main/assets/18PlusList.txt |
| 78 | + - name: Release Apk Sign |
65 | 79 | run: |
|
66 |
| - echo "统一版本号" |
67 |
| - sed "/def version/c def version = \"${{ env.VERSION }}\"" $GITHUB_WORKSPACE/app/build.gradle -i |
68 |
| -
|
| 80 | + echo "给apk增加签名" |
| 81 | + cp $GITHUB_WORKSPACE/.github/workflows/firefly.jks $GITHUB_WORKSPACE/app/firefly.jks |
| 82 | + sed '$a\RELEASE_STORE_FILE=./firefly.jks' $GITHUB_WORKSPACE/gradle.properties -i |
| 83 | + sed '$a\RELEASE_KEY_ALIAS=YueDu-Firefly' $GITHUB_WORKSPACE/gradle.properties -i |
| 84 | + sed '$a\RELEASE_STORE_PASSWORD=YueDu-Firefly' $GITHUB_WORKSPACE/gradle.properties -i |
| 85 | + sed '$a\RELEASE_KEY_PASSWORD=YueDu-Firefly' $GITHUB_WORKSPACE/gradle.properties -i |
69 | 86 | - name: Set up Gradle
|
70 | 87 | uses: gradle/actions/setup-gradle@v4
|
71 | 88 |
|
72 | 89 | - name: Build With Gradle
|
73 | 90 | run: |
|
74 |
| - echo "开始进行${{ env.product }}构建" |
| 91 | + if [ ${{ env.type }} == 'Original' ]; then |
| 92 | + typeName="Original" |
| 93 | + sed "s/'.release'/'.Original'/" $GITHUB_WORKSPACE/app/build.gradle -i |
| 94 | + sed 's/.release/.Original/' $GITHUB_WORKSPACE/app/google-services.json -i |
| 95 | + else |
| 96 | + typeName="Firefly" |
| 97 | + sed "s/'.release'/'.Firefly'/" $GITHUB_WORKSPACE/app/build.gradle -i |
| 98 | + sed 's/.release/.Firefly/' $GITHUB_WORKSPACE/app/google-services.json -i |
| 99 | + fi |
| 100 | + echo "统一版本号" |
| 101 | + sed "/def version/c def version = \"${{ env.VERSION }}\"" $GITHUB_WORKSPACE/app/build.gradle -i |
| 102 | + echo "开始进行${{ env.product }}.$typeName构建" |
75 | 103 | chmod +x gradlew
|
76 | 104 | ./gradlew assemble${{ env.product }}release --build-cache --parallel --daemon --warning-mode all
|
77 |
| -
|
78 |
| - - name: Organize the Files |
79 |
| - run: | |
| 105 | + echo "修改文件名" |
80 | 106 | mkdir -p ${{ github.workspace }}/apk/
|
81 |
| - cp -rf ${{ github.workspace }}/app/build/outputs/apk/*/*/*.apk ${{ github.workspace }}/apk/ |
82 |
| - |
| 107 | + for file in `ls ${{ github.workspace }}/app/build/outputs/apk/*/*/*.apk`; do |
| 108 | + mv "$file" ${{ github.workspace }}/apk/YueDu.${{ env.product }}.$typeName.${{ env.VERSION }}.apk |
| 109 | + done |
83 | 110 | - name: Upload App To Artifact
|
84 |
| - uses: actions/upload-artifact@v4 |
| 111 | + uses: actions/upload-artifact@v4.3.1 |
85 | 112 | with:
|
86 |
| - name: legado_${{ env.product }} |
| 113 | + name: YueDu.${{ env.product }}.${{ env.type }} |
87 | 114 | path: ${{ github.workspace }}/apk/*.apk
|
88 |
| - |
89 | 115 | - name: Release
|
90 |
| - if: ${{ env.product == 'app' }} |
91 |
| - uses: softprops/action-gh-release@v2 |
| 116 | + # if: ${{ env.product == 'Google' }} |
| 117 | + uses: softprops/action-gh-release@v2.0.8 |
92 | 118 | with:
|
93 |
| - name: legado_app_${{ env.VERSION }} |
| 119 | + name: YueDu.${{ env.VERSION }} |
94 | 120 | tag_name: ${{ env.VERSION }}
|
95 |
| - body_path: ${{ github.workspace }}/CHANGELOG.md |
| 121 | + # body: ${{ env.CHANGE }} |
| 122 | + body_path: ${{ github.workspace }}/app/src/main/assets/updateLog.md |
| 123 | + generate_release_notes: true |
| 124 | + # append_body: true |
| 125 | + token: ${{env.GIT_TOKEN}} |
96 | 126 | draft: false
|
97 | 127 | prerelease: false
|
98 |
| - files: ${{ github.workspace }}/apk/legado_app_*.apk |
99 |
| - env: |
100 |
| - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
101 |
| - |
102 |
| - - name: Prepare For GooglePlay |
103 |
| - if: env.product == 'google' && env.play == 'yes' |
104 |
| - run: | |
105 |
| - mkdir -p ReleaseNotes |
106 |
| - ln -s ${{ github.workspace }}/CHANGELOG.md ReleaseNotes/whatsnew-en-US |
107 |
| - ln -s ${{ github.workspace }}/CHANGELOG.md ReleaseNotes/whatsnew-zh-CN |
| 128 | + files: ${{ github.workspace }}/apk/YueDu.*.apk |
108 | 129 |
|
109 |
| - - name: Release To GooglePlay |
110 |
| - if: env.product == 'google' && env.play == 'yes' |
111 |
| - uses: r0adkll/upload-google-play@v1 |
112 |
| - with: |
113 |
| - serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }} |
114 |
| - packageName: io.legado.play |
115 |
| - releaseFiles: ${{ github.workspace }}/apk/legado_google_*.apk |
116 |
| - track: production |
117 |
| - whatsNewDirectory: ${{ github.workspace }}/ReleaseNotes |
| 130 | + # - name: Prepare For GooglePlay |
| 131 | + # if: env.product == 'Google' && env.play == 'yes' |
| 132 | + # run: | |
| 133 | + # mkdir -p ReleaseNotes |
| 134 | + # ln -s ${{ github.workspace }}/CHANGELOG.md ReleaseNotes/whatsnew-en-US |
| 135 | + # ln -s ${{ github.workspace }}/CHANGELOG.md ReleaseNotes/whatsnew-zh-CN |
| 136 | + # |
| 137 | + # - name: Release To GooglePlay |
| 138 | + # if: env.product == 'google' && env.play == 'yes' |
| 139 | + # uses: r0adkll/upload-google-play@v1 |
| 140 | + # with: |
| 141 | + # serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }} |
| 142 | + # packageName: io.legado.play |
| 143 | + # releaseFiles: ${{ github.workspace }}/apk/YueDu.Google.*.apk |
| 144 | + # track: production |
| 145 | + # whatsNewDirectory: ${{ github.workspace }}/ReleaseNotes |
| 146 | + |
| 147 | + # release_Branch: |
| 148 | + # needs: [prepare, build] |
| 149 | + # runs-on: ubuntu-latest |
| 150 | + # if: ${{ github.actor == 'LM-Firefly' }} |
| 151 | + # steps: |
| 152 | + # - uses: actions/checkout@v4 |
| 153 | + # - uses: actions/download-artifact@v4 |
| 154 | + # with: |
| 155 | + # path: apk/ |
| 156 | + # - working-directory: apk/ |
| 157 | + # run: mv */*.apk . ;rm -rf */ |
| 158 | + # - name: Push Assets To "release" Branch |
| 159 | + # run: | |
| 160 | + # cd $GITHUB_WORKSPACE/apk/ |
| 161 | + # git config --global user.name "github-actions[bot]" |
| 162 | + # git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 163 | + # git init |
| 164 | + # git checkout -b release |
| 165 | + # git remote add origin "https://${{ github.actor }}:${{ secrets.ACTIONS_TOKEN }}@github.com/${{ github.actor }}/${{ github.repository }}/release" |
| 166 | + # git add *.apk |
| 167 | + # git commit -m "${{ env.VERSION }}" |
| 168 | + # git push -f -u origin release |
118 | 169 |
|
119 |
| - - name: Push Assets To "release" Branch |
120 |
| - if: ${{ github.actor == 'gedoor' }} |
121 |
| - run: | |
122 |
| - cd $GITHUB_WORKSPACE/apk/ |
123 |
| - git init |
124 |
| - git checkout -b release |
125 |
| - git config --global user.name "github-actions[bot]" |
126 |
| - git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" |
127 |
| - git remote add origin "https://${{ github.actor }}:${{ secrets.ACTIONS_TOKEN }}@github.com/${{ github.actor }}/release" |
128 |
| - git add *.apk |
129 |
| - git commit -m "${{ env.VERSION }}" |
130 |
| - git push -f -u origin release |
131 |
| - |
132 | 170 | - name: Purge Jsdelivr Cache
|
133 |
| - if: ${{ github.actor == 'gedoor' }} |
| 171 | + if: ${{ github.actor == 'LM-Firefly' }} |
134 | 172 | run: |
|
135 |
| - result=$(curl -s https://purge.jsdelivr.net/gh/${{ github.actor }}/release@release/) |
| 173 | + result=$(curl -s https://purge.jsdelivr.net/gh/${{ github.actor }}/${{ github.repository }}/release@release/) |
136 | 174 | if echo $result |grep -q 'success.*true'; then
|
137 | 175 | echo "jsdelivr缓存更新成功"
|
138 | 176 | else
|
|
0 commit comments