diff --git a/.github/workflows/gh_pages.yaml b/.github/workflows/gh_pages.yaml index 4352b12..cee1131 100644 --- a/.github/workflows/gh_pages.yaml +++ b/.github/workflows/gh_pages.yaml @@ -30,7 +30,7 @@ jobs: - name: Create symbolic link run: ln -s ./build/web ./docs - name: Build project - run: flutter build -v web --release + run: flutter build -v web --base-href "/flutter_notes/" - name: Deploy to GitHub Pages uses: peaceiris/actions-gh-pages@v3 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 59f9f42..5c1262c 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -32,11 +32,18 @@ jobs: matrix: target: [Android, Web] # [Android, iOS, Linux, macOS, Windows, Web] include: + # - os: ubuntu-20.04 + # target: Android + # build_target: apk + # build_path: build/app/outputs/apk/release + # asset_extension: .apk + # asset_content_type: application/vnd.android.package-archive + # channel: stable - os: ubuntu-20.04 target: Android - build_target: apk - build_path: build/app/outputs/apk/release - asset_extension: .apk + build_target: appbundle + build_path: build/app/outputs/bundle/release + asset_extension: .aab asset_content_type: application/vnd.android.package-archive channel: stable # - os: ubuntu-20.04 @@ -70,7 +77,18 @@ jobs: # Disable fail-fast as we want results from all even if one fails. fail-fast: false needs: draft-release - steps: + steps: + # Set environment variables. + - name: Get release tag version + run: echo "RELEASE_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Create build asset name + env: + REPOSITORY_NAME: ${{ github.event.repository.name }} + MATRIX_TARGET: ${{ matrix.target }} + run: | + export RELEASE_TARGET=$(echo "${MATRIX_TARGET,,}") + echo "BUILD_ASSET_NAME=${{ env.REPOSITORY_NAME }}_${RELEASE_TARGET}_${{ env.RELEASE_TAG }}${{ matrix.asset_extension }}" >> $GITHUB_ENV + # Set up Flutter. - name: Clone Flutter repository with ${{ matrix.channel }} channel uses: subosito/flutter-action@v1.5.3 @@ -79,20 +97,20 @@ jobs: # Set up required dependencies. - name: Install Linux dependencies - if: matrix.build_target == 'linux' + if: matrix.target == 'linux' run: | sudo apt-get update sudo apt-get install -y libgtk-3-dev libx11-dev pkg-config cmake ninja-build libblkid-dev - name: Install Android dependencies - if: matrix.build_target == 'android' + if: matrix.target == 'android' uses: actions/setup-java@v1 with: - java-version: "12.x" + java-version: '12.x' - name: Enable web support - if: matrix.build_target == 'web' + if: matrix.target == 'web' run: flutter config --enable-web - - name: Enable ${{ matrix.target }} desktop support - if: matrix.build_target == 'linux' || matrix.build_target == 'windows' || matrix.build_target == 'macos' + - name: Enable desktop support + if: matrix.target == 'linux' || matrix.target == 'windows' || matrix.target == 'macos' run: flutter config --enable-${{ matrix.build_target }}-desktop - name: Run Flutter doctor run: flutter doctor -v @@ -100,49 +118,76 @@ jobs: # Clone the repository and get required packages. - name: Clone the repository uses: actions/checkout@v2 + + # Cache required files. + - name: Cache Gradle packages + if: matrix.target == 'android' + uses: actions/cache@v2 + env: + CACHE_NAME: gradle + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-${{ env.CACHE_NAME }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-${{ env.CACHE_NAME }}- + + - name: Cache pubspec dependencies + uses: actions/cache@v2 + env: + CACHE_NAME: pubspec + with: + path: | + ${{ env.PUB_CACHE }} + ${{ env.FLUTTER_ROOT }}/bin + **/.dart_tool + **/.packages + **/.flutter-plugins + **/.flutter-plugin-dependencies + key: ${{ runner.os }}-${{ env.CACHE_NAME }}-${{ hashFiles('**/pubspec.lock') }} + restore-keys: | + ${{ runner.os }}-${{ env.CACHE_NAME }}- + - name: Get packages for the Flutter project run: flutter pub get # Build the application. - name: Build project - run: flutter build -v ${{ matrix.build_target }} --release + run: flutter build -v ${{ matrix.build_target }} # Prepare release build package. - name: Copy VC redistributables to release directory for Windows - if: matrix.build_target == 'windows' + if: matrix.target == 'windows' run: | Copy-Item (vswhere -latest -find 'VC\Redist\MSVC\*\x64\*\msvcp140.dll') . Copy-Item (vswhere -latest -find 'VC\Redist\MSVC\*\x64\*\vcruntime140.dll') . Copy-Item (vswhere -latest -find 'VC\Redist\MSVC\*\x64\*\vcruntime140_1.dll') . - # Compress build. - name: Compress build for Windows - if: matrix.build_target == 'windows' - run: compress-archive -Path * -DestinationPath ./flutter_notes_${{ matrix.build_target }}${{ matrix.asset_extension }} + if: matrix.target == 'windows' + run: compress-archive -Path * -DestinationPath ./${{ env.BUILD_ASSET_NAME }} working-directory: ${{ matrix.build_path }} - name: Compress build for Linux - if: matrix.build_target == 'linux' || matrix.build_target == 'web' - run: tar czf ./flutter_notes_${{ matrix.build_target }}${{ matrix.asset_extension }} * + if: matrix.target == 'linux' || matrix.target == 'web' + run: tar czf ./${{ env.BUILD_ASSET_NAME }} * working-directory: ${{ matrix.build_path }} - name: Compress build for macOS - if: matrix.build_target == 'macos' - run: ditto -c -k --sequesterRsrc --keepParent Flutter\ Notes.app ./flutter_notes_${{ matrix.build_target }}${{ matrix.asset_extension }} + if: matrix.target == 'macos' + run: ditto -c -k --sequesterRsrc --keepParent '*.app' ./${{ env.BUILD_ASSET_NAME }} working-directory: ${{ matrix.build_path }} - name: Rename build for Android - if: matrix.build_target == 'apk' - run: mv app-release${{ matrix.asset_extension }} ./flutter_notes_${{ matrix.build_target }}${{ matrix.asset_extension }} + if: matrix.target == 'android' + run: mv app-release${{ matrix.asset_extension }} ./${{ env.BUILD_ASSET_NAME }} working-directory: ${{ matrix.build_path }} # Upload the build. - - name: Get release tag version - run: echo "RELEASE_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - name: Upload release asset id: upload_release_asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: softprops/action-gh-release@v1 with: - upload_url: ${{ needs.draft-release.outputs.upload_url }} - asset_path: ./${{ matrix.build_path }}/flutter_notes_${{ matrix.build_target }}${{ matrix.asset_extension }} - asset_name: flutter_notes_${{ matrix.build_target }}_${{ env.RELEASE_TAG }}${{ matrix.asset_extension }} - asset_content_type: ${{ matrix.asset_content_type }} + name: Flutter Test v${{ env.RELEASE_TAG }} + draft: true + prerelease: false + files: | + ./${{ matrix.build_path }}/${{ env.BUILD_ASSET_NAME }}