fix(ci): missing create_release
action
#4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Release | |
on: | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
permissions: | |
contents: write | |
packages: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
distribution: "zulu" | |
java-version: "17" | |
- name: Cache Gradle packages | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: ${{ runner.os }}-gradle- | |
- name: Decode and Set Up google-services.json | |
run: | | |
echo "${{ secrets.GOOGLE_SERVICE_BASE64_ENCODED }}" | base64 -d > app/google-services.json | |
- name: Decode and Set Up Keystore | |
run: | | |
echo "${{ secrets.KEYSTORE_BASE64_ENCODED }}" | base64 -d > keystore.jks | |
- name: Setup keystore.properties | |
run: | | |
echo "store.file=../keystore.jks" >> keystore.properties | |
echo "store.password=${{ secrets.KEYSTORE_PASSWORD }}" >> keystore.properties | |
echo "key.alias=tutortoise" >> keystore.properties | |
echo "key.password=${{ secrets.KEY_PASSWORD }}" >> keystore.properties | |
- name: Setup local.properties | |
run: | | |
echo "base.url=${{ secrets.BASE_URL }}" >> local.properties | |
echo "google.oauth.client.id=${{ secrets.GOOGLE_OAUTH_CLIENT_ID }}" >> local.properties | |
- name: Build Release APK | |
run: ./gradlew assembleRelease | |
env: | |
CI: true | |
- name: Determine Version Name | |
id: determine_version | |
run: | | |
if [ -n "${{ github.event.head_commit.message }}" ]; then | |
VERSION_NAME=$(echo "${{ github.event.head_commit.message }}" | grep -oP '(?<=\[version: ).*?(?=\])') | |
fi | |
if [ -z "$VERSION_NAME" ]; then | |
VERSION_NAME="v0.0.$(date +'%y%m%d')" | |
fi | |
echo "::set-output name=version_name::$VERSION_NAME" | |
- name: Delete Existing Release | |
if: always() | |
run: | | |
gh release delete ${{ steps.determine_version.outputs.version_name }} -y || true | |
gh release delete-tag ${{ steps.determine_version.outputs.version_name }} || true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.determine_version.outputs.version_name }} | |
release_name: ${{ steps.determine_version.outputs.version_name }}.${{ github.run_id }} | |
draft: false | |
prerelease: false | |
- name: Upload APK as Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: app-release | |
path: app/build/outputs/apk/release/app-release.apk | |
- name: Upload APK to Release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: app/build/outputs/apk/release/app-release.apk | |
asset_name: app-release.apk | |
asset_content_type: application/vnd.android.package-archive |