👷 map build condition

This commit is contained in:
niuhuan 2024-04-02 13:32:23 +08:00
parent 31ea00b5af
commit a7ecfbd7d7
1 changed files with 21 additions and 13 deletions

View File

@ -27,28 +27,36 @@ jobs:
config: config:
- target: ios - target: ios
host: macos-latest host: macos-latest
build: ${{ env.PACKAGE_IOS }}
- target: android - target: android
host: ubuntu-latest host: ubuntu-latest
build: ${{ env.PACKAGE_ANDROID }}
runs-on: ${{ matrix.config.host }} runs-on: ${{ matrix.config.host }}
steps: 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) name: Set-Version (All)
run: | run: |
cd ci cd ci
cp version.code.txt ../lib/assets/version.txt cp version.code.txt ../lib/assets/version.txt
- if: ${{ matrix.config.build == 'true' }} - if: steps.need_build.outputs.need_build == 'true'
name: Setup flutter name: Setup flutter
uses: subosito/flutter-action@v2 uses: subosito/flutter-action@v2
with: with:
flutter-version: ${{ env.FLUTTER_VERSION }} flutter-version: ${{ env.FLUTTER_VERSION }}
architecture: x64 architecture: x64
- if: ${{ matrix.config.build == 'true' }} - if: steps.need_build.outputs.need_build == 'true'
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: ${{ env.GO_VERSION }} go-version: ${{ env.GO_VERSION }}
- if: ${{ matrix.config.build == 'true' }} - if: steps.need_build.outputs.need_build == 'true'
name: Cache go modules name: Cache go modules
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
@ -58,25 +66,25 @@ jobs:
key: ubuntu-latest-go-${{ hashFiles('**/go.sum') }} key: ubuntu-latest-go-${{ hashFiles('**/go.sum') }}
restore-keys: | restore-keys: |
ubuntu-latest-go- ubuntu-latest-go-
- if: ${{ matrix.config.build == 'true' }} - if: steps.need_build.outputs.need_build == 'true'
name: checkout name: checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- if: ${{ matrix.config.build == 'true' }} - if: steps.need_build.outputs.need_build == 'true'
name: checkout core name: checkout core
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:
repository: 'niuhuan/pikapika-go-core' repository: 'niuhuan/pikapika-go-core'
token: ${{ secrets.GH_TOKEN }} token: ${{ secrets.GH_TOKEN }}
path: 'go' path: 'go'
- if: ${{ matrix.config.build == 'true' }} - if: steps.need_build.outputs.need_build == 'true'
name: Install go mobile (mobile) name: Install go mobile (mobile)
run: | run: |
go install golang.org/x/mobile/cmd/gomobile@latest 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) name: Build (ios)
run: | run: |
sh scripts/build-ipa.sh 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) name: Build (android-arm64)
env: env:
KEY_FILE_BASE64: ${{ secrets.KEY_FILE_BASE64 }} KEY_FILE_BASE64: ${{ secrets.KEY_FILE_BASE64 }}
@ -84,14 +92,14 @@ jobs:
run: | run: |
sh scripts/build-apk-arm64.sh sh scripts/build-apk-arm64.sh
sh scripts/sign-apk-github-actions.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)' name: 'Upload Artifact (ios)'
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: 'nosign.ipa' name: 'nosign.ipa'
path: 'build/nosign.ipa' path: 'build/nosign.ipa'
retention-days: 3 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)' name: 'Upload Artifact (ios)'
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with: