From fbd405d4d70085d349e81b9c1d70f60495adc21c Mon Sep 17 00:00:00 2001 From: rainy liu Date: Wed, 6 Nov 2024 11:03:01 +0800 Subject: [PATCH] add publish.yml --- .github/workflows/publish.yml | 81 +++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..b3e92b9e --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,81 @@ +name: Publish to pub.dev and release + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.*' # tag pattern on pub.dev: 'v{{version}' + - 'dartcv4-v[0-9]+.[0-9]+.*' + +jobs: + test: + runs-on: windows-2019 + steps: + - uses: actions/checkout@v4 + - uses: robinraju/release-downloader@v1.10 + with: + repository: "rainyl/opencv_dart" + tag: "dnn_test_files" + fileName: "models.zip" + out-file-path: "packages/dartcv/test/" + extract: true + - uses: robinraju/release-downloader@v1.10 + with: + repository: "rainyl/dartcv" + latest: true + fileName: "libdartcv-windows-x64-vs2019.tar.gz" + out-file-path: "packages/dartcv/libdartcv" + extract: true + - uses: subosito/flutter-action@v2 + with: + channel: "stable" + - name: test + run: | + cd "${{github.workspace}}\packages\dartcv" + $env:PATH="${{github.workspace}}\packages\dartcv\libdartcv\lib;$env:PATH" + dart pub global activate coverage + dart pub global run coverage:test_with_coverage --package . --package-name dartcv4 + publish-dartcv4: + if: startsWith(github.ref, 'refs/tags/dartcv4-v') + name: Publish dartcv4 + needs: [test] + permissions: + id-token: write # Required for authentication using OIDC + uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1 + with: + # Specify the github actions deployment environment + environment: pub.dev + working-directory: packages/dartcv + publish-opencv-core: + if: startsWith(github.ref, 'refs/tags/v') + name: Publish opencv_core + needs: [test] + permissions: + id-token: write # Required for authentication using OIDC + uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1 + with: + # Specify the github actions deployment environment + environment: pub.dev + working-directory: packages/opencv_core + publish-opencv-dart: + if: startsWith(github.ref, 'refs/tags/v') + name: Publish opencv_dart + needs: [test] + permissions: + id-token: write # Required for authentication using OIDC + uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1 + with: + # Specify the github actions deployment environment + environment: pub.dev + working-directory: packages/opencv_dart + release: + needs: [test] + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + - name: release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: false + prerelease: false