From a7ecfbd7d7faeaf27310750638f60d8415013c3d Mon Sep 17 00:00:00 2001 From: niuhuan Date: Tue, 2 Apr 2024 13:32:23 +0800 Subject: [PATCH] :construction_worker: map build condition --- .github/workflows/Package.yml | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/.github/workflows/Package.yml b/.github/workflows/Package.yml index fdd139b..33baab6 100644 --- a/.github/workflows/Package.yml +++ b/.github/workflows/Package.yml @@ -27,28 +27,36 @@ jobs: config: - target: ios host: macos-latest - build: ${{ env.PACKAGE_IOS }} - target: android host: ubuntu-latest - build: ${{ env.PACKAGE_ANDROID }} runs-on: ${{ matrix.config.host }} steps: - - if: ${{ matrix.config.build == 'true' }} + - name: need_build + id: need_build + run: | + if [ ${{ matrix.config.target }} == 'android' ] && [ ${{ env.PACKAGE_ANDROID }} == 'true' ]; then + echo "::set-output name=need_build::true" + elif [ ${{ matrix.config.target }} == 'ios' ] && [ ${{ env.PACKAGE_IOS }} == 'true' ]; then + echo "::set-output name=need_build::true" + else + echo "::set-output name=need_build::false" + fi + - if: steps.need_build.outputs.need_build == 'true' name: Set-Version (All) run: | cd ci cp version.code.txt ../lib/assets/version.txt - - if: ${{ matrix.config.build == 'true' }} + - if: steps.need_build.outputs.need_build == 'true' name: Setup flutter uses: subosito/flutter-action@v2 with: flutter-version: ${{ env.FLUTTER_VERSION }} architecture: x64 - - if: ${{ matrix.config.build == 'true' }} + - if: steps.need_build.outputs.need_build == 'true' uses: actions/setup-go@v2 with: go-version: ${{ env.GO_VERSION }} - - if: ${{ matrix.config.build == 'true' }} + - if: steps.need_build.outputs.need_build == 'true' name: Cache go modules uses: actions/cache@v3 with: @@ -58,25 +66,25 @@ jobs: key: ubuntu-latest-go-${{ hashFiles('**/go.sum') }} restore-keys: | ubuntu-latest-go- - - if: ${{ matrix.config.build == 'true' }} + - if: steps.need_build.outputs.need_build == 'true' name: checkout uses: actions/checkout@v3 - - if: ${{ matrix.config.build == 'true' }} + - if: steps.need_build.outputs.need_build == 'true' name: checkout core uses: actions/checkout@v3 with: repository: 'niuhuan/pikapika-go-core' token: ${{ secrets.GH_TOKEN }} path: 'go' - - if: ${{ matrix.config.build == 'true' }} + - if: steps.need_build.outputs.need_build == 'true' name: Install go mobile (mobile) run: | go install golang.org/x/mobile/cmd/gomobile@latest - - if: ${{ matrix.config.build == 'true' }} && matrix.config.target == 'ios' + - if: steps.need_build.outputs.need_build == 'true' && matrix.config.target == 'ios' name: Build (ios) run: | sh scripts/build-ipa.sh - - if: ${{ matrix.config.build == 'true' }} && matrix.config.target == 'android' + - if: steps.need_build.outputs.need_build == 'true' && matrix.config.target == 'android' name: Build (android-arm64) env: KEY_FILE_BASE64: ${{ secrets.KEY_FILE_BASE64 }} @@ -84,14 +92,14 @@ jobs: run: | sh scripts/build-apk-arm64.sh sh scripts/sign-apk-github-actions.sh - - if: ${{ matrix.config.build == 'true' }} && matrix.config.target == 'ios' + - if: steps.need_build.outputs.need_build == 'true' && matrix.config.target == 'ios' name: 'Upload Artifact (ios)' uses: actions/upload-artifact@v4 with: name: 'nosign.ipa' path: 'build/nosign.ipa' retention-days: 3 - - if: ${{ matrix.config.build == 'true' }} && matrix.config.target == 'android' + - if: steps.need_build.outputs.need_build == 'true' && matrix.config.target == 'android' name: 'Upload Artifact (ios)' uses: actions/upload-artifact@v4 with: