Skip to content

Commit

Permalink
Update android.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
akshaynikhare authored Jun 4, 2024
1 parent 14c0a7c commit 928d7a6
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,41 @@ jobs:
echo "version=$version" >> $GITHUB_ENV
echo "VERSION: $version"
- name: Create Release
id: create_release
uses: actions/create-release@v1
- name: Check if Release Exists
id: check_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.version }}
release_name: Release v${{ env.version }}
draft: false
prerelease: false
run: |
response=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/${{ github.repository }}/releases/tags/v${{ env.version }})
release_id=$(echo $response | jq -r '.id')
if [ "$release_id" == "null" ]; then
echo "release_exists=false" >> $GITHUB_ENV
else
echo "release_exists=true" >> $GITHUB_ENV
echo "release_id=$release_id" >> $GITHUB_ENV
fi
- name: Create or Update Release
id: create_or_update_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_EXISTS: ${{ env.release_exists }}
RELEASE_ID: ${{ env.release_id }}
run: |
if [ "$RELEASE_EXISTS" == "false" ]; then
response=$(curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Content-Type: application/json" -d "{\"tag_name\":\"v${{ env.version }}\",\"name\":\"Release v${{ env.version }}\",\"draft\":false,\"prerelease\":false}" https://api.github.com/repos/${{ github.repository }}/releases)
release_id=$(echo $response | jq -r '.id')
echo "release_id=$release_id" >> $GITHUB_ENV
else
echo "Release already exists with ID $RELEASE_ID"
fi
- name: Upload Release Asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_ID: ${{ env.release_id }}
run: |
release_id=$(curl -s \
-H "Authorization: Bearer $GITHUB_TOKEN" \
https://api.github.com/repos/${{ github.repository }}/releases/tags/v${{ env.version }} \
| jq -r '.id')
upload_url="https://uploads.github.com/repos/${{ github.repository }}/releases/$release_id/assets?name=app-v${{ env.version }}.apk"
upload_url="https://uploads.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets?name=app-v${{ env.version }}.apk"
asset_path=./app/build/outputs/apk/release/app-release.apk
curl -X POST \
Expand Down

0 comments on commit 928d7a6

Please sign in to comment.