Skip to content

Publish

Publish #31

Workflow file for this run

name: Publish
on:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
publish-bundle:
strategy:
matrix:
os: [ubuntu-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
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}"
echo "tag_title=${tag_title}" >> $GITHUB_OUTPUT
RELEASE_EXISTS=$(curl -s -H "Authorization: token ${GH_TOKEN}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${{ github.repository }}/releases/tags/${tag_title}" | jq -r '.message')
if [[ "$RELEASE_EXISTS" == "Not Found" ]]; then
echo "release_exists=false" >> $GITHUB_OUTPUT
echo "Release ${tag_title} does not exist. I will create it on next step."
else
echo "release_exists=true" >> $GITHUB_OUTPUT
echo "Release ${tag_title} already exists, skipping creation."
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 }} --prerelease
shell: bash
- 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 "${KEYSTORE_ENCODED}" | base64 -d > upload_keystore.jks
echo "upload_store_file=$(realpath upload_keystore.jks)" >> "${GITHUB_OUTPUT}"
echo "${KEY_JSON_ENCODED}" | base64 -d > sa.json
echo "sa_json_file=$(realpath sa.json)" >> "${GITHUB_OUTPUT}"
env:
KEYSTORE_ENCODED: ${{ secrets.UPLOAD_KEYSTORE }}
KEY_JSON_ENCODED: ${{ secrets.KEY_JSON }}
- name: Grant permission of Gradle wrapper
timeout-minutes: 1
run: chmod +x gradlew
- name: Publish Release AAB
timeout-minutes: 12
run: |
./gradlew publishReleaseBundle
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.upload_store_file }}
SA_FILE_PATH: ${{ steps.prepare-credentials.outputs.sa_json_file }}
- name: Clean up credentials
timeout-minutes: 1
if: ${{ always() }}
run: |
rm upload_keystore.jks
rm sa.json
- name: Upload artifacts
timeout-minutes: 2
if: ${{ success() }}
uses: actions/upload-artifact@v7
with:
name: Release bundle artifacts
path: |
app/build/outputs/
- name: Upload AAB to artifact
timeout-minutes: 2
if: ${{ success() }}
uses: actions/upload-artifact@v7
with:
name: Release AAB
path: |
app/build/outputs/bundle/release/*.aab
- name: Upload artifact to release
timeout-minutes: 3
if: ${{ success() }}
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ steps.check_release.outputs.tag_title }}
run: |
tag_title=$RELEASE_TAG
gh release upload ${tag_title} app/build/outputs/bundle/release/*.aab --clobber
shell: bash