From 40b571491e5e579981aa66958c7267e446e4a778 Mon Sep 17 00:00:00 2001 From: Brian Wo <45139213+brainwo@users.noreply.github.com> Date: Sat, 27 Apr 2024 05:30:58 +0800 Subject: [PATCH] ci: add Github Action workflows (#30) - Specified Flutter environment version in pubspec.yaml - Add version constraint to `custom_lint` and `riverpod_lint` - Add check.yml workflow - Add build.yml workflow --- .github/workflows/build.yml | 58 +++++++++++++++++++++++++++++++++++++ .github/workflows/check.yml | 33 +++++++++++++++++++++ pubspec.lock | 2 +- pubspec.yaml | 7 +++-- 4 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/check.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..b8ec750 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,58 @@ +name: Build release tag +on: + push: + tags: + - "v*" + workflow_dispatch: + +jobs: + build: + name: Create ${{ matrix.os }} build + runs-on: ${{ matrix.os }} + strategy: + matrix: + target: [Linux] + include: + - os: ubuntu-latest + target: Linux + build_target: linux + build_path: build/linux/x64/release/bundle + asset_name: linux_amd64 + asset_extension: .tar.gz + asset_content_type: application/gzip + fail-fast: false + steps: + - name: Install Flutter + uses: subosito/flutter-action@v2 + with: + channel: stable + flutter-version-flie: pubspec.yaml + - name: Install Linux dependencies + if: matrix.target == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y clang cmake ninja-build libgtk-3-dev libstdc++-12-dev + - uses: actions/checkout@v2 + - run: | + flutter config --enable-linux-desktop + flutter config --no-analytics + dart --disable-analytics + flutter config --no-enable-android + flutter config --no-enable-web + - run: flutter doctor -v + - run: flutter pub get + - run: dart fix --apply --code=unnecessary_final + - run: flutter build -v ${{ matrix.build_target }} --release + - name: Compress build for Linux + if: matrix.target == 'Linux' + run: tar czf $GITHUB_WORKSPACE/yatta_${{ matrix.build_target }}${{ matrix.asset_extension }} * + working-directory: ${{ matrix.build_path }} + - name: Upload the artifact to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + release_name: Release ${{ github.ref_name }} + file: yatta_${{ matrix.build_target }}${{ matrix.asset_extension }} + tag: ${{ github.ref }} + asset_name: yatta_${{ github.ref_name }}_${{ matrix.asset_name }}${{ matrix.asset_extension }} + overwrite: true diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..4be3b71 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,33 @@ +name: Code check + +on: + push: + branches: + - main + pull_request: + types: + - opened + - reopened + - synchronize + +jobs: + format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: subosito/flutter-action@v2 + with: + channel: stable + flutter-version-flie: pubspec.yaml + - name: Update dependencies + run: flutter pub get + - name: Disable analytics + run: | + flutter config --no-analytics + dart --disable-analytics + - name: Remove custom lint # https://github.com/invertase/dart_custom_lint/issues/228 + run: sed -i '/custom_lint/d' analysis_options.yaml + - name: Format + run: dart format --set-exit-if-changed lib + - name: Analyze + run: flutter analyze lib diff --git a/pubspec.lock b/pubspec.lock index ca79ca9..564e0cd 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -890,4 +890,4 @@ packages: version: "1.0.3" sdks: dart: ">=3.3.3 <4.0.0" - flutter: ">=3.19.0" + flutter: ">=3.19.6" diff --git a/pubspec.yaml b/pubspec.yaml index afa629a..f3e0018 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,10 +3,11 @@ description: A multipurpose YouTube frontend for hackers publish_to: "none" -version: 0.0.0 +version: 0.0.2 environment: sdk: ">=3.0.0 <4.0.0" + flutter: 3.19.6 dependencies: autoscroll: @@ -21,11 +22,11 @@ dependencies: path: package/youtube_api/ dev_dependencies: - custom_lint: + custom_lint: ^0.6.4 extra_pedantic: ^4.0.0 flutter_test: sdk: flutter - riverpod_lint: + riverpod_lint: ^2.3.10 test: ^1.21.0 flutter: