chore(CI): Fix uploads (#242)

* Fix CI uploads

* Decode keystore directly

* Only build release

---------

Co-authored-by: HuanCheng65 <22636177+HuanCheng65@users.noreply.github.com>
This commit is contained in:
Howard Wu 2024-02-02 19:37:02 +08:00 committed by GitHub
parent be3ae43602
commit a899a5fa0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 15 deletions

View File

@ -17,19 +17,11 @@ jobs:
distribution: "zulu" distribution: "zulu"
cache: gradle cache: gradle
- name: Decode Keystore
id: decode_keystore
if: ${{ github.event_name != 'pull_request' || github.ref_type == 'tag' }}
uses: timheuer/base64-to-file@v1.2
with:
fileName: ${{ vars.RELEASE_KEYSTORE }}
fileDir: ${{ github.workspace }}
encodedString: ${{ secrets.KEYSTORE }}
- name: Generate keystore.properties - name: Generate keystore.properties
if: ${{ github.event_name != 'pull_request' || github.ref_type == 'tag' }} if: ${{ github.event_name != 'pull_request' || github.ref_type == 'tag' }}
run: | run: |
if [ -n "${{ secrets.RELEASEKEYPASSWORD }}" ]; then if [ -n "${{ secrets.RELEASEKEYPASSWORD }}" ]; then
echo ${{ secrets.KEYSTORE }} | base64 --decode > ${{ vars.RELEASE_KEYSTORE }}
echo keystore.file="${{ vars.RELEASE_KEYSTORE }}" >> keystore.properties echo keystore.file="${{ vars.RELEASE_KEYSTORE }}" >> keystore.properties
echo keystore.password="${{ secrets.RELEASESTOREPASSWORD }}" >> keystore.properties echo keystore.password="${{ secrets.RELEASESTOREPASSWORD }}" >> keystore.properties
echo keystore.key.alias="${{ vars.RELEASE_KEY_ALIAS }}" >> keystore.properties echo keystore.key.alias="${{ vars.RELEASE_KEY_ALIAS }}" >> keystore.properties
@ -56,7 +48,7 @@ jobs:
env: env:
version_code: ${{ fromJSON(steps.read_output_metadata.outputs.content).elements[0].versionCode }} version_code: ${{ fromJSON(steps.read_output_metadata.outputs.content).elements[0].versionCode }}
version_name: ${{ fromJSON(steps.read_output_metadata.outputs.content).elements[0].versionName }} version_name: ${{ fromJSON(steps.read_output_metadata.outputs.content).elements[0].versionName }}
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v4
with: with:
name: "release-${{ env.version_name }}(${{ env.version_code }})" name: "release-${{ env.version_name }}(${{ env.version_code }})"
path: ./app/build/outputs/apk/release path: ./app/build/outputs/apk/release
@ -72,7 +64,6 @@ jobs:
env: env:
CHANNEL_ID: ${{ secrets.CHANNEL_DEV_ID }} CHANNEL_ID: ${{ secrets.CHANNEL_DEV_ID }}
BOT_TOKEN: ${{ secrets.BOT_DEV_TOKEN }} BOT_TOKEN: ${{ secrets.BOT_DEV_TOKEN }}
MAPPING: ./app/build/outputs/mapping/release/mapping.txt
COMMIT_URL: ${{ github.event.head_commit.url }} COMMIT_URL: ${{ github.event.head_commit.url }}
COMMIT_MESSAGE: |+ COMMIT_MESSAGE: |+
``` ```
@ -85,9 +76,8 @@ jobs:
run: | run: |
if [ -n "$BOT_TOKEN" ] && [ -n "$CHANNEL_ID" ]; then if [ -n "$BOT_TOKEN" ] && [ -n "$CHANNEL_ID" ]; then
export RELEASE=$(find ./app/build/outputs/apk/release -name "*.apk") export RELEASE=$(find ./app/build/outputs/apk/release -name "*.apk")
export DEBUG=$(find ./app/build/outputs/apk/debug -name "*.apk")
ESCAPED=`python3 -c 'import json,os,urllib.parse; msg = json.dumps(os.environ["COMMIT_MESSAGE"]); print(urllib.parse.quote(msg if len(msg) <= 1024 else json.dumps(os.environ["COMMIT_URL"])))'` ESCAPED=`python3 -c 'import json,os,urllib.parse; msg = json.dumps(os.environ["COMMIT_MESSAGE"]); print(urllib.parse.quote(msg if len(msg) <= 1024 else json.dumps(os.environ["COMMIT_URL"])))'`
curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${CHANNEL_ID}&media=%5B%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2Frelease%22%7D%2C%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2Fdebug%22%7D%2C%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2Fmapping%22%2C%22parse_mode%22%3A%22MarkdownV2%22%2C%22caption%22%3A${ESCAPED}%7D%5D&reply_markup=%7B%22inline_keyboard%22%3A%20%5B%5B%7B%22text%22%3A%20%22%E5%9C%A8+Github+%E4%B8%8A%E6%9F%A5%E7%9C%8B%22%2C%20%22url%22%3A%20${ACTION_URL}%7D%5D%5D%7D" -F release="@$RELEASE" -F debug="@$DEBUG" -F mapping="@$MAPPING" curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${CHANNEL_ID}&media=%5B%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2Frelease%22%2C%22parse_mode%22%3A%22MarkdownV2%22%2C%22caption%22%3A${ESCAPED}%7D%5D&reply_markup=%7B%22inline_keyboard%22%3A%20%5B%5B%7B%22text%22%3A%20%22%E5%9C%A8+Github+%E4%B8%8A%E6%9F%A5%E7%9C%8B%22%2C%20%22url%22%3A%20${ACTION_URL}%7D%5D%5D%7D" -F release="@$RELEASE"
fi fi
- name: Upload Mapping to App Center - name: Upload Mapping to App Center
@ -98,4 +88,4 @@ jobs:
uses: saurav-aggarwal/appcenter-cli-action@1.0.1 uses: saurav-aggarwal/appcenter-cli-action@1.0.1
with: with:
token: ${{ secrets.APP_CENTER_TOKEN }} token: ${{ secrets.APP_CENTER_TOKEN }}
command: appcenter crashes upload-mappings -c ${{ env.version_code }} -n ${{ env.version_name }} -m /github/workspace/app/build/outputs/mapping/release/mapping.txt -a huanchengfly/TiebaLite command: appcenter crashes upload-mappings -c ${{ env.version_code }} -n ${{ env.version_name }} -m ./app/build/outputs/mapping/release/mapping.txt -a ${{ secrets.APP_CENTER_APP }}

View File

@ -29,7 +29,7 @@ sweetProperty {
"keystore.file" to "", "keystore.file" to "",
"keystore.password" to "", "keystore.password" to "",
"keystore.key.alias" to "", "keystore.key.alias" to "",
"keystore.key.password" to "" "keystore.key.password" to "",
) )
generateFrom(CURRENT_PROJECT, ROOT_PROJECT) generateFrom(CURRENT_PROJECT, ROOT_PROJECT)
} }