Yuito-app-android/.github/workflows/build.yml

107 lines
2.9 KiB
YAML
Raw Normal View History

2020-11-20 06:41:23 +01:00
name: Build
on:
push:
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 1.8
- run: |
chmod +x ./gradlew
./gradlew :app:testBlueDebugUnitTest
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 1.8
- run: |
chmod +x ./gradlew
./gradlew :app:assembleBlueRelease
- uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: app/build/outputs/apk/blue/release
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
- uses: actions/upload-artifact@v2
with:
name: built-app
path: ${{ env.SIGNED_RELEASE_FILE }}
draft:
runs-on: ubuntu-latest
needs: [test, build]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases \
| tr '\r\n' ' ' \
| jq '.[] | select(.draft == true) | .id' \
| xargs -I '{}' \
curl -X DELETE -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases/{}
- run: |
DIR_TIMESTAMP=$(git log -1 --pretty="format:%ct" ./changelogs/)
for d in ./changelogs/*/; do
if [ $(git log -1 --pretty="format:%ct" "$d") = $DIR_TIMESTAMP ]; then
echo "CHANGELOG_DIR=$d" >> $GITHUB_ENV
echo "CHANGELOG_VERSION=$(basename -as / "$d")" >> $GITHUB_ENV
fi
done
- uses: actions/create-release@v1
id: draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.CHANGELOG_VERSION }}
release_name: Yuito ${{ env.CHANGELOG_VERSION }}
body_path: ${{ env.CHANGELOG_DIR }}whatsnew-ja-JP
draft: true
- uses: actions/download-artifact@v1
with:
name: built-app
- run: |
cd ./built-app
echo "ARTIFACT_FILE=$(find . -type f -name "*.apk" | head -1 | gawk -F/ '{print $NF}')" >> $GITHUB_ENV
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.draft.outputs.upload_url }}
asset_path: ./built-app/${{ env.ARTIFACT_FILE }}
asset_name: Yuito-${{ env.CHANGELOG_VERSION }}.apk
asset_content_type: application/vnd.android.package-archive