Merge commit '39681571068d03e40895e566bc3468a565650aef' into release #13
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" | |
on: | |
pull_request: | |
branches: | |
- release | |
push: | |
branches: | |
- release | |
jobs: | |
build: | |
name: Build & Release | |
runs-on: macos-latest | |
steps: | |
# 1. Checkout Repository | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Create .env file from secrets | |
run: | | |
echo "TMDB_ACCESS_TOKEN=${{ secrets.YOUR_API_KEY }}" > .env | |
echo "TMDB_API_BASE_URL=https://api.themoviedb.org" >> .env | |
echo "STREAM_SEARCH_API_BASE_URL=${{ secrets.STREAM_SEARCH_API_BASE_URL }}" >> .env | |
echo "STREAM_MOVIE_API_BASE_URL=${{ secrets.STREAM_MOVIE_API_BASE_URL }}" >> .env | |
# 2. Setup Java | |
- name: Set Up Java | |
uses: actions/setup-java@v3.12.0 | |
with: | |
distribution: 'oracle' | |
java-version: '17' | |
# 3. Setup Flutter | |
- name: Set Up Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: '3.19.3' | |
channel: 'stable' | |
# 4. Cache Flutter Dependencies | |
- name: Cache Flutter Dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.pub-cache | |
key: flutter-${{ runner.os }}-pub-cache-${{ hashFiles('pubspec.yaml') }} | |
restore-keys: | | |
flutter-${{ runner.os }}-pub-cache- | |
# 5. Install Dependencies | |
- name: Install Dependencies | |
run: flutter pub get | |
# 6. Setup Keystore | |
- name: Decode Keystore | |
run: | | |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > android/app/keystore.jks | |
- name: Create key.properties | |
run: | | |
echo "storePassword=${{ secrets.KEYSTORE_PASSWORD }}" > android/key.properties | |
echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/key.properties | |
echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> android/key.properties | |
echo "storeFile=keystore.jks" >> android/key.properties | |
# 7. Cache Flutter Build | |
- name: Cache Flutter Build Artifacts | |
uses: actions/cache@v3 | |
with: | |
path: | | |
build | |
key: flutter-${{ runner.os }}-build-cache-${{ hashFiles('pubspec.yaml') }} | |
restore-keys: | | |
flutter-${{ runner.os }}-build-cache- | |
# 8. Building APK (Release) | |
- name: Build APK (Release) | |
run: flutter build apk --release | |
# 9. Building APK (Debug) | |
- name: Build APK (Debug) | |
run: flutter build apk --debug | |
# 10. Building App Bundle (aab) | |
- name: Build appBundle | |
run: flutter build appbundle | |
# 11. Upload Release Artifacts | |
- name: Upload Release Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Release APK & AAB | |
path: | | |
build/app/outputs/flutter-apk/app-release.apk | |
build/app/outputs/bundle/release/app-release.aab | |
# 12. Upload Debug Artifacts | |
- name: Upload Debug Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Debug APK | |
path: | | |
build/app/outputs/flutter-apk/app-debug.apk | |
# 13. Extract Version | |
- name: Extract version from pubspec.yaml | |
id: extract_version | |
run: | | |
version=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2 | tr -d '\r') | |
echo "VERSION=$version" >> $GITHUB_ENV | |
# 14. Check if Tag Exists | |
- name: Check if Tag Exists | |
id: check_tag | |
run: | | |
if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then | |
echo "TAG_EXISTS=true" >> $GITHUB_ENV | |
else | |
echo "TAG_EXISTS=false" >> $GITHUB_ENV | |
fi | |
# 15. Modify Tag if it Exists | |
- name: Modify Tag | |
if: env.TAG_EXISTS == 'true' | |
id: modify_tag | |
run: | | |
new_version="${{ env.VERSION }}-build-${{ github.run_number }}" | |
echo "VERSION=$new_version" >> $GITHUB_ENV | |
# 16. Create Release | |
- name: Create Release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "build/app/outputs/flutter-apk/app-release.apk,build/app/outputs/bundle/release/app-release.aab" | |
tag: v${{ env.VERSION }}-${{ github.run_number }} | |
token: ${{ secrets.GITHUB_TOKEN }} |