Skip to content

Commit

Permalink
ci: also release on play store
Browse files Browse the repository at this point in the history
[release: 1.0.1]
  • Loading branch information
Zxilly committed Oct 7, 2022
1 parent 4bdf007 commit a511a48
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
26 changes: 23 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: Build and release

on:
push:
Expand All @@ -19,6 +19,8 @@ jobs:
utcOffset: "+08:00"

- uses: actions/checkout@v3
with:
fetch-depth: 0 # fetch tags

- name: Grant permission for scripts
run: chmod +x ./scripts/*.sh
Expand Down Expand Up @@ -58,7 +60,7 @@ jobs:
if: steps.release.outputs.release == 'true'
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ github.event.release.tag_name }}"
automatic_release_tag: "${{ steps.release.outputs.version }}"
prerelease: false
files: |
app/build/outputs/apk/github/release/*
Expand All @@ -81,4 +83,22 @@ jobs:
env:
VERSION_CODE: ${{ steps.apk-info.outputs.version-code }}
VERSION_NAME: ${{ steps.apk-info.outputs.version-name }}
APPCENTER_TOKEN: ${{ secrets.APP_CENTER_TOKEN }}
APPCENTER_TOKEN: ${{ secrets.APP_CENTER_TOKEN }}

- name: Create whatsNew
if: steps.release.outputs.release == 'true'
run: |
./scripts/whats_new.sh
env:
VERSION: ${{ steps.release.outputs.version }}

- name: Upload Android Release to Play Store
uses: r0adkll/upload-google-play@v1.0.18
if: steps.release.outputs.release == 'true'
with:
releaseFiles: app/build/outputs/bundle/playRelease/app-play-release.aab
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
packageName: top.learningman.push
track: beta
mappingFile: app/build/outputs/mapping/playRelease/mapping.txt
whatsNewDirectory: whatsNew
15 changes: 13 additions & 2 deletions scripts/release_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,21 @@
# get last git commit message
git_commit_message=$(git log -1 --pretty=%B)

#if commit message contains "[release]" then set output
if [[ $git_commit_message == *"[release]"* ]]; then
if [[ $git_commit_message == *"[release:"* ]]; then
echo "::set-output name=release::true"
echo "Should release"
# get version from [release: x.x.x]
version=$(echo "$git_commit_message" | grep -o "\[release:.*\]" | sed "s/\[release:\s*//g" | sed "s/\s*\]//g")
if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::set-output name=version::$version"
echo "Version is $version"
else
echo "Version format is not correct"
echo "Version format should be x.x.x"
echo "But got $version"
exit 1
fi

else
echo "::set-output name=release::false"
echo "Should not release"
Expand Down
4 changes: 4 additions & 0 deletions scripts/whats_new.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
mkdir whatsNew
echo "请参阅 https://github.com/ZNotify/android/releases/tag/$VERSION" > whatsNew/whatsnew-zh-CN.txt
echo "Please refer to https://github.com/ZNotify/android/releases/tag/$VERSION" > whatsNew/whatsnew-en.txt

0 comments on commit a511a48

Please sign in to comment.