Skip to content

refactor #1039 Add license. #217

refactor #1039 Add license.

refactor #1039 Add license. #217

Workflow file for this run

name: Release
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
draft:
runs-on: ubuntu-latest
outputs:
release_tag: ${{ steps.check_release.outputs.tag_title }}
steps:
- uses: actions/checkout@v6
- name: Check if release exists
id: check_release
env:
TZ: 'Asia/Tokyo'
GH_TOKEN: ${{ github.token }}
run: |
VERSION_FILE=buildSrc/src/main/java/property/Version.kt
MAJOR=$(cat $VERSION_FILE | grep MAJOR | head -1 | awk '{print $6}')
MIDDLE=$(cat $VERSION_FILE | grep MIDDLE | head -1 | awk '{print $6}')
MINOR=$(cat $VERSION_FILE | grep MINOR | head -1 | awk '{print $6}')
CURRENT_VERSION=$MAJOR.$MIDDLE.$MINOR
echo $CURRENT_VERSION
tag_title="${CURRENT_VERSION}_draft"
echo "tag_title=${tag_title}" >> $GITHUB_OUTPUT
releases=$(curl -s -H "Authorization: token ${GH_TOKEN}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${{ github.repository }}/releases?per_page=50")
RELEASE_EXISTS=$(echo $releases | jq --arg search_name $tag_title '[.[] | select(.draft == true and .name == $search_name)] | length > 0')
echo $RELEASE_EXISTS
if [[ $RELEASE_EXISTS == true ]]; then
echo "release_exists=true" >> $GITHUB_OUTPUT
echo "Release ${tag_title} already exists, skipping creation."
else
echo "release_exists=false" >> $GITHUB_OUTPUT
echo "Release ${tag_title} does not exist. I will create it on next step."
fi
shell: bash
- name: Create Release
id: create_release
if: steps.check_release.outputs.release_exists == 'false'
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create ${{ steps.check_release.outputs.tag_title }} --title ${{ steps.check_release.outputs.tag_title }} --draft
shell: bash
build:
needs: draft
strategy:
matrix:
os: [ubuntu-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Install
timeout-minutes: 3
uses: actions/setup-java@v5
with:
distribution: 'corretto' # See 'Supported distributions' for available options
java-version: '21'
- name: Download Android SDK
uses: android-actions/setup-android@v3
with:
api-level: 35
build-tools: 35.0.0
- name: Prepare credentials
id: prepare-credentials
timeout-minutes: 1
run: |
echo "${{ secrets.RELEASE_KEYSTORE }}" | base64 -d > release_keystore.jks
echo "store_file=$(realpath release_keystore.jks)" >> "${GITHUB_OUTPUT}"
- name: Grant permission of Gradle wrapper
timeout-minutes: 1
run: chmod +x gradlew
- name: Build Release APK
timeout-minutes: 16
run: |
./gradlew assembleRelease
env:
_JAVA_OPTIONS: '-Duser.language=ja -Duser.country=JP'
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
STORE_FILE_PATH: ${{ steps.prepare-credentials.outputs.store_file }}
- name: Clean up credentials
timeout-minutes: 1
if: ${{ always() }}
run: |
rm release_keystore.jks
- name: Upload artifacts
timeout-minutes: 2
if: ${{ success() }}
uses: actions/upload-artifact@v7
with:
name: Release artifacts
path: |
app/build/outputs/
- name: Upload APK to artifact
timeout-minutes: 2
if: ${{ success() }}
uses: actions/upload-artifact@v7
with:
name: Release APK
path: |
app/build/outputs/apk/release/*.apk
- name: Upload artifact to release
timeout-minutes: 5
if: ${{ success() }}
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ needs.draft.outputs.release_tag }}
run: |
tag_title=$RELEASE_TAG
gh release upload ${tag_title} app/build/outputs/apk/release/*.apk --clobber
shell: bash
test:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: install
timeout-minutes: 3
uses: actions/setup-java@v5
with:
distribution: 'corretto' # See 'Supported distributions' for available options
java-version: '21'
cache: gradle
- name: Grant permission of Gradle wrapper
timeout-minutes: 1
run: chmod +x gradlew
- name: Coverage
timeout-minutes: 18
env:
TZ: 'Asia/Tokyo'
_JAVA_OPTIONS: '-Duser.language=ja -Duser.country=JP -Duser.timezone=Asia/Tokyo'
run: "./gradlew koverHtmlReport"
- name: Upload configuration cache
timeout-minutes: 3
if: ${{ always() }}
uses: actions/upload-artifact@v7
with:
name: Configuration cache
path: |
build/reports/configuration-cache/
build/reports/problems/problems-report.html
- name: Upload Unit Test Results
timeout-minutes: 3
if: ${{ always() }}
uses: actions/upload-artifact@v7
with:
name: Unit Test Results
path: |
*/build/reports/tests
- name: Upload Coverage Results
timeout-minutes: 3
if: ${{ success() }}
uses: actions/upload-artifact@v7
with:
name: Kover Results
path: |
build/reports/kover
- name: Print summary
timeout-minutes: 1
if: ${{ success() }}
run: ./gradlew printCoverageSummary
- name: Store summary
timeout-minutes: 1
if: ${{ success() }}
run: |
echo "## Test coverage" >> $GITHUB_STEP_SUMMARY
./gradlew printCoverageSummary >> $GITHUB_STEP_SUMMARY
cat $GITHUB_STEP_SUMMARY
shell: bash