From 090ad93265a9e7b3fd369df56b4fdfb6dabfcd4f Mon Sep 17 00:00:00 2001 From: valord577 <30427460+valord577@users.noreply.github.com> Date: Fri, 23 Aug 2024 15:23:14 +0800 Subject: [PATCH] gh action ng (#6) --- .github/matrix.json | 32 +++++ .github/oss_v4.py | 2 +- .../workflows/{_buildx.yml => _matrix.yml} | 109 ++++++++++-------- .github/workflows/ffmpeg.yml | 11 +- .github/workflows/mbedtls.yml | 10 +- .github/workflows/sdl2.yml | 10 +- build.ps1 | 4 +- build.sh | 8 +- deps/ffmpeg | 2 +- deps/sdl2 | 2 +- env-apple.sh | 2 +- .../ffmpeg/01_use_custom_config.patch | 0 .../ffmpeg/02_fix_pkgconf_prefix.patch | 0 .../ffmpeg/03_fix_ios_api_available.patch | 0 .../ffmpeg/04_fix_some_warnings.patch | 0 .../ffmpeg/05_fix_linker_xcode15.patch | 0 .../ffmpeg/06_fix_some_warnings.patch | 0 .../sdl2/01_del_unusable_files.patch | 0 .../sdl2/02_fix_pkgconf_prefix.patch | 0 scripts/ffmpeg.sh | 6 +- scripts/llvm.sh | 4 +- scripts/mbedtls.sh | 4 +- scripts/sdl2.sh | 2 +- 23 files changed, 123 insertions(+), 85 deletions(-) create mode 100644 .github/matrix.json rename .github/workflows/{_buildx.yml => _matrix.yml} (50%) rename {patchs => patches}/ffmpeg/01_use_custom_config.patch (100%) rename {patchs => patches}/ffmpeg/02_fix_pkgconf_prefix.patch (100%) rename {patchs => patches}/ffmpeg/03_fix_ios_api_available.patch (100%) rename {patchs => patches}/ffmpeg/04_fix_some_warnings.patch (100%) rename {patchs => patches}/ffmpeg/05_fix_linker_xcode15.patch (100%) rename {patchs => patches}/ffmpeg/06_fix_some_warnings.patch (100%) rename {patchs => patches}/sdl2/01_del_unusable_files.patch (100%) rename {patchs => patches}/sdl2/02_fix_pkgconf_prefix.patch (100%) diff --git a/.github/matrix.json b/.github/matrix.json new file mode 100644 index 0000000..fdfea94 --- /dev/null +++ b/.github/matrix.json @@ -0,0 +1,32 @@ +[ + { + "os": "macos-14", + "platform": "iphoneos", + "arch": "arm64", + "pkg_type": "static" + }, + { + "os": "macos-14", + "platform": "iphonesimulator", + "arch": "arm64", + "pkg_type": "static" + }, + { + "os": "macos-14", + "platform": "iphonesimulator", + "arch": "x86_64", + "pkg_type": "static" + }, + { + "os": "macos-14", + "platform": "macosx", + "arch": "arm64", + "pkg_type": "static" + }, + { + "os": "macos-14", + "platform": "macosx", + "arch": "x86_64", + "pkg_type": "static" + } +] diff --git a/.github/oss_v4.py b/.github/oss_v4.py index 6255060..a8c2d7b 100755 --- a/.github/oss_v4.py +++ b/.github/oss_v4.py @@ -9,7 +9,7 @@ from typing import Any, Callable, NoReturn from urllib.parse import quote as escape -sign_expires_in_seconds = "10" +sign_expires_in_seconds = "60" environ_key_http_debug = "HTTP_DEBUG_MESSAGE" oss_storage_basedir = os.getenv("GH_OSSUTIL_PKGS") diff --git a/.github/workflows/_buildx.yml b/.github/workflows/_matrix.yml similarity index 50% rename from .github/workflows/_buildx.yml rename to .github/workflows/_matrix.yml index 126132c..15efe9d 100644 --- a/.github/workflows/_buildx.yml +++ b/.github/workflows/_matrix.yml @@ -1,4 +1,4 @@ -name: _buildx +name: _matrix on: workflow_call: inputs: @@ -16,6 +16,7 @@ on: type: boolean env: + GH_TOKEN: ${{ github.token }} GH_OSSUTIL_AK: ${{ secrets.GH_OSSUTIL_AK }} GH_OSSUTIL_SK: ${{ secrets.GH_OSSUTIL_SK }} GH_OSSUTIL_BUCKET: ${{ secrets.GH_OSSUTIL_BUCKET }} @@ -24,34 +25,57 @@ env: GH_OSSUTIL_CNAME: ${{ secrets.GH_OSSUTIL_CNAME }} jobs: + _preset: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: ${{ github.workspace }} + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + pkgver: ${{ steps.set-pkgver.outputs.pkgver }} + steps: + - name: clone with gh + run: | + gh repo clone ${{ github.repositoryUrl }} . -- --no-checkout --single-branch --depth=1 + git fetch --no-tags --prune --no-recurse-submodules --depth=1 origin +${{ github.sha }}; git checkout FETCH_HEAD + - name: set matrix + id: set-matrix + run: | + if [[ ${{ (! inputs.disable_shared) }} ]]; then { jq_expr='(.pkg_type=="shared")'; } fi + if [[ ${{ (! inputs.disable_static) }} ]]; then + if [ -z "${jq_expr}" ]; then { jq_expr='(.pkg_type=="static")'; } else { jq_expr="$jq_expr or (.pkg_type==\"static\")"; } fi + fi + printf "\e[1m\e[33m%s\e[0m\n" "jq_expr: $jq_expr" + + matrix=$(cat .github/matrix.json | jq -c -M "map(. | select($jq_expr) )") + printf "\e[1m\e[33m%s\e[0m\n" "matrix: $matrix" + echo "matrix={\"include\":$(echo $matrix)}" >> "$GITHUB_OUTPUT" + - name: set pkgver + id: set-pkgver + run: | + pkgver=$(git ls-tree -d --abbrev=7 --format='%(objectname)' HEAD -- deps/${{ github.workflow }}) + printf "\e[1m\e[33m%s\e[0m\n" "pkgver: $pkgver" + echo "pkgver=$pkgver" >> "$GITHUB_OUTPUT" + _buildx: + needs: _preset strategy: - matrix: - pkg_type: [shared, static] - platform: [iphoneos, iphonesimulator, macosx] - arch: [arm64, x86_64] - exclude: - - platform: 'iphoneos' - arch: 'x86_64' - runs-on: macos-14 - outputs: - version: ${{ steps.version.outputs._PKG_VERSION }} + matrix: ${{ fromJson(needs._preset.outputs.matrix) }} + runs-on: ${{ matrix.os }} env: - _REPO_THIS: "_repo_this" - _SETP_CAN_RUN: ${{ (! inputs.disable_shared && matrix.pkg_type == 'shared') || (! inputs.disable_static && matrix.pkg_type == 'static') }} INST_DIR: "${{ github.workspace }}/${{ github.workflow }}" CCACHE_DIR: ${{ github.workspace }}/.ccache CCACHE_GHA_KEY: ${{ matrix.pkg_type }}-${{ matrix.platform }}-${{ matrix.arch }}-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }} CCACHE_GHA_KEY_RESTORE: ${{ matrix.pkg_type }}-${{ matrix.platform }}-${{ matrix.arch }} steps: - - name: checkout this repo - uses: actions/checkout@v4 - with: - path: ${{ env._REPO_THIS }} + - name: clone with gh + run: | + gh repo clone ${{ github.repositoryUrl }} . -- --no-checkout --single-branch --depth=1 + git fetch --no-tags --prune --no-recurse-submodules --depth=1 origin +${{ github.sha }}; git checkout FETCH_HEAD - name: install required software(s) run: | - brew list -l - brew install ccache nasm + brew list -l; brew install ccache nasm - name: gh action ccache restore uses: actions/cache/restore@v4 with: @@ -60,66 +84,49 @@ jobs: restore-keys: | ${{ env.CCACHE_GHA_KEY_RESTORE }} - name: buildx library - ${{ github.workflow }} - if: ${{ env._SETP_CAN_RUN == 'true' }} run: | - source ${{ env._REPO_THIS }}/build_${{ matrix.platform }}_${{ matrix.arch }}.sh + source build_${{ matrix.platform }}_${{ matrix.arch }}.sh compile ${{ github.workflow }} ${{ matrix.pkg_type }} ${{ matrix.platform }} ${{ matrix.arch }} - name: gh action ccache save - if: ${{ env._SETP_CAN_RUN == 'true' }} uses: actions/cache/save@v4 with: path: ${{ env.CCACHE_DIR }} key: ${{ env.CCACHE_GHA_KEY }} - - name: set required env `_PKG_VERSION` - id: version - if: ${{ env._SETP_CAN_RUN == 'true' }} - run: | - pushd -- "${{ env._REPO_THIS }}/deps/${{ github.workflow }}" - _PKG_VERSION=$(git rev-parse --short=7 HEAD) - popd - - echo "_PKG_VERSION=${_PKG_VERSION}" >> "$GITHUB_ENV" - echo "_PKG_VERSION=${_PKG_VERSION}" >> "$GITHUB_OUTPUT" - name: set required env `_PKG_ZIP_NAME` - if: ${{ env._SETP_CAN_RUN == 'true' }} run: | - echo "_PKG_ZIP_NAME=${{ github.workflow }}_${{ matrix.platform }}_${{ matrix.arch }}_${{ env._PKG_VERSION }}_${{ matrix.pkg_type }}" >> "$GITHUB_ENV" + echo "_PKG_ZIP_NAME=${{ github.workflow }}_${{ matrix.platform }}_${{ matrix.arch }}_${{ needs._preset.outputs.pkgver }}_${{ matrix.pkg_type }}" >> "$GITHUB_ENV" - name: compress library - ${{ github.workflow }} - if: ${{ env._SETP_CAN_RUN == 'true' }} run: | zip -ry "${{ env._PKG_ZIP_NAME }}.zip" ${{ github.workflow }} - name: upload library - ${{ github.workflow }} - if: ${{ env._SETP_CAN_RUN == 'true' }} uses: actions/upload-artifact@v4 with: name: ${{ env._PKG_ZIP_NAME }} path: ${{ env._PKG_ZIP_NAME }}.zip + _upload: - needs: _buildx + needs: + - _preset + - _buildx runs-on: ubuntu-latest env: _PUSH_CAN_EXE: ${{ github.event_name == 'push' && (! inputs.disable_upload) }} steps: + - name: clone with gh + run: | + gh repo clone ${{ github.repositoryUrl }} . -- --no-checkout --single-branch --depth=1 + git fetch --no-tags --prune --no-recurse-submodules --depth=1 origin +${{ github.sha }}; git checkout FETCH_HEAD - name: download ${{ github.workflow }} libraries uses: actions/download-artifact@v4 with: path: ${{ github.workspace }}/${{ github.workflow }} - - name: show debug info - run: | - env - echo -e "\n" - echo -e "${PWD}" - echo -e "\n" - ls -Alh -- . - echo -e "\n" - ls -AlhR ${{ github.workflow }} - name: commit to pre-compiled packages if: ${{ env._PUSH_CAN_EXE == 'true' }} run: | - mkdir -p '${{ github.workflow }}/${{ needs._buildx.outputs.version }}' - mv -f ${{ github.workspace }}/${{ github.workflow }}/*/*.zip '${{ github.workflow }}/${{ needs._buildx.outputs.version }}' + mkdir -p '${{ github.workflow }}/${{ needs._preset.outputs.pkgver }}' + mv -f ${{ github.workspace }}/${{ github.workflow }}/*/*.zip '${{ github.workflow }}/${{ needs._preset.outputs.pkgver }}' - for ZIP in `ls -- ${{ github.workflow }}/${{ needs._buildx.outputs.version }}`; do - ./.github/oss_v4.py push "${{ github.workflow }}/${{ needs._buildx.outputs.version }}/${ZIP}" \ - "${{ github.workflow }}/${{ needs._buildx.outputs.version }}/${ZIP}" + for ZIP in `ls -- ${{ github.workflow }}/${{ needs._preset.outputs.pkgver }}`; do + ./.github/oss_v4.py push "${{ github.workflow }}/${{ needs._preset.outputs.pkgver }}/${ZIP}" \ + "${{ github.workflow }}/${{ needs._preset.outputs.pkgver }}/${ZIP}" done diff --git a/.github/workflows/ffmpeg.yml b/.github/workflows/ffmpeg.yml index 0c319de..c1ede39 100644 --- a/.github/workflows/ffmpeg.yml +++ b/.github/workflows/ffmpeg.yml @@ -4,10 +4,10 @@ on: branches: - main paths: - - '.github/workflows/_buildx.yml' + - '.github/workflows/_matrix.yml' - '.github/workflows/ffmpeg.yml' - 'deps/ffmpeg' - - 'patchs/ffmpeg/**' + - 'patches/ffmpeg/**' - 'scripts/ffmpeg.sh' - 'build.sh' - 'env-apple.sh' @@ -16,10 +16,10 @@ on: branches: - main paths: - - '.github/workflows/_buildx.yml' + - '.github/workflows/_matrix.yml' - '.github/workflows/ffmpeg.yml' - 'deps/ffmpeg' - - 'patchs/ffmpeg/**' + - 'patches/ffmpeg/**' - 'scripts/ffmpeg.sh' - 'build.sh' - 'env-apple.sh' @@ -28,7 +28,6 @@ on: jobs: build: secrets: inherit - uses: ./.github/workflows/_buildx.yml + uses: ./.github/workflows/_matrix.yml with: - disable_shared: false disable_upload: true diff --git a/.github/workflows/mbedtls.yml b/.github/workflows/mbedtls.yml index b36200f..4f9fc85 100644 --- a/.github/workflows/mbedtls.yml +++ b/.github/workflows/mbedtls.yml @@ -4,10 +4,10 @@ on: branches: - main paths: - - '.github/workflows/_buildx.yml' + - '.github/workflows/_matrix.yml' - '.github/workflows/mbedtls.yml' - 'deps/mbedtls' - - 'patchs/mbedtls/**' + - 'patches/mbedtls/**' - 'scripts/mbedtls.sh' - 'build.sh' - 'env-apple.sh' @@ -15,10 +15,10 @@ on: branches: - main paths: - - '.github/workflows/_buildx.yml' + - '.github/workflows/_matrix.yml' - '.github/workflows/mbedtls.yml' - 'deps/mbedtls' - - 'patchs/mbedtls/**' + - 'patches/mbedtls/**' - 'scripts/mbedtls.sh' - 'build.sh' - 'env-apple.sh' @@ -26,4 +26,4 @@ on: jobs: build: secrets: inherit - uses: ./.github/workflows/_buildx.yml + uses: ./.github/workflows/_matrix.yml diff --git a/.github/workflows/sdl2.yml b/.github/workflows/sdl2.yml index 806bcb0..441e97c 100644 --- a/.github/workflows/sdl2.yml +++ b/.github/workflows/sdl2.yml @@ -4,10 +4,10 @@ on: branches: - main paths: - - '.github/workflows/_buildx.yml' + - '.github/workflows/_matrix.yml' - '.github/workflows/sdl2.yml' - 'deps/sdl2' - - 'patchs/sdl2/**' + - 'patches/sdl2/**' - 'scripts/sdl2.sh' - 'build.sh' - 'env-apple.sh' @@ -15,10 +15,10 @@ on: branches: - main paths: - - '.github/workflows/_buildx.yml' + - '.github/workflows/_matrix.yml' - '.github/workflows/sdl2.yml' - 'deps/sdl2' - - 'patchs/sdl2/**' + - 'patches/sdl2/**' - 'scripts/sdl2.sh' - 'build.sh' - 'env-apple.sh' @@ -26,4 +26,4 @@ on: jobs: build: secrets: inherit - uses: ./.github/workflows/_buildx.yml + uses: ./.github/workflows/_matrix.yml diff --git a/build.ps1 b/build.ps1 index e77e44f..e787aa3 100644 --- a/build.ps1 +++ b/build.ps1 @@ -68,11 +68,11 @@ $compile = { Pop-Location } - if (Test-Path -PathType Container -Path "${PROJ_ROOT}/patchs/${PKG_NAME}") { + if (Test-Path -PathType Container -Path "${PROJ_ROOT}/patches/${PKG_NAME}") { Push-Location "${env:SUBPROJ_SRC}" git reset --hard HEAD - foreach ($patch in (Get-ChildItem -Path "${PROJ_ROOT}/patchs/${PKG_NAME}" -File)) { + foreach ($patch in (Get-ChildItem -Path "${PROJ_ROOT}/patches/${PKG_NAME}" -File)) { git apply ${patch}.FullName } Pop-Location diff --git a/build.sh b/build.sh index 2c30608..26d4dba 100755 --- a/build.sh +++ b/build.sh @@ -23,7 +23,7 @@ case ${TARGET_PLATFORM} in "macosx" | "iphoneos" | "iphonesimulator") source "${PROJ_ROOT}/env-apple.sh" ${TARGET_PLATFORM} ${TARGET_ARCH} ;; - ?) + *) ;; esac @@ -52,12 +52,12 @@ function compile() { popd fi - if [ -e "${PROJ_ROOT}/patchs/${PKG_NAME}" ]; then + if [ -e "${PROJ_ROOT}/patches/${PKG_NAME}" ]; then pushd -- "${SUBPROJ_SRC}" git reset --hard HEAD - for patch in $(ls -- "${PROJ_ROOT}/patchs/${PKG_NAME}"); do - git apply "${PROJ_ROOT}/patchs/${PKG_NAME}/${patch}" + for patch in $(ls -- "${PROJ_ROOT}/patches/${PKG_NAME}"); do + git apply "${PROJ_ROOT}/patches/${PKG_NAME}/${patch}" done popd fi diff --git a/deps/ffmpeg b/deps/ffmpeg index 66c05dc..cfe0a36 160000 --- a/deps/ffmpeg +++ b/deps/ffmpeg @@ -1 +1 @@ -Subproject commit 66c05dc03163998fb9a90ebd53e2c39a4f95b7ea +Subproject commit cfe0a36352f5439668fc9b5b9e5b985d2958b906 diff --git a/deps/sdl2 b/deps/sdl2 index fb14975..ba2f78a 160000 --- a/deps/sdl2 +++ b/deps/sdl2 @@ -1 +1 @@ -Subproject commit fb1497566c5a05e2babdcf45ef0ab5c7cca2c4ae +Subproject commit ba2f78a0069118a6c583f1fbf1420144ffa35bad diff --git a/env-apple.sh b/env-apple.sh index 3b73433..6a520e3 100755 --- a/env-apple.sh +++ b/env-apple.sh @@ -48,7 +48,7 @@ case ${TARGET_PLATFORM} in "iphonesimulator") TARGET_FLAG="ios-simulator" ;; - ?) + *) ;; esac diff --git a/patchs/ffmpeg/01_use_custom_config.patch b/patches/ffmpeg/01_use_custom_config.patch similarity index 100% rename from patchs/ffmpeg/01_use_custom_config.patch rename to patches/ffmpeg/01_use_custom_config.patch diff --git a/patchs/ffmpeg/02_fix_pkgconf_prefix.patch b/patches/ffmpeg/02_fix_pkgconf_prefix.patch similarity index 100% rename from patchs/ffmpeg/02_fix_pkgconf_prefix.patch rename to patches/ffmpeg/02_fix_pkgconf_prefix.patch diff --git a/patchs/ffmpeg/03_fix_ios_api_available.patch b/patches/ffmpeg/03_fix_ios_api_available.patch similarity index 100% rename from patchs/ffmpeg/03_fix_ios_api_available.patch rename to patches/ffmpeg/03_fix_ios_api_available.patch diff --git a/patchs/ffmpeg/04_fix_some_warnings.patch b/patches/ffmpeg/04_fix_some_warnings.patch similarity index 100% rename from patchs/ffmpeg/04_fix_some_warnings.patch rename to patches/ffmpeg/04_fix_some_warnings.patch diff --git a/patchs/ffmpeg/05_fix_linker_xcode15.patch b/patches/ffmpeg/05_fix_linker_xcode15.patch similarity index 100% rename from patchs/ffmpeg/05_fix_linker_xcode15.patch rename to patches/ffmpeg/05_fix_linker_xcode15.patch diff --git a/patchs/ffmpeg/06_fix_some_warnings.patch b/patches/ffmpeg/06_fix_some_warnings.patch similarity index 100% rename from patchs/ffmpeg/06_fix_some_warnings.patch rename to patches/ffmpeg/06_fix_some_warnings.patch diff --git a/patchs/sdl2/01_del_unusable_files.patch b/patches/sdl2/01_del_unusable_files.patch similarity index 100% rename from patchs/sdl2/01_del_unusable_files.patch rename to patches/sdl2/01_del_unusable_files.patch diff --git a/patchs/sdl2/02_fix_pkgconf_prefix.patch b/patches/sdl2/02_fix_pkgconf_prefix.patch similarity index 100% rename from patchs/sdl2/02_fix_pkgconf_prefix.patch rename to patches/sdl2/02_fix_pkgconf_prefix.patch diff --git a/scripts/ffmpeg.sh b/scripts/ffmpeg.sh index 2ad1cd0..187baf8 100755 --- a/scripts/ffmpeg.sh +++ b/scripts/ffmpeg.sh @@ -19,7 +19,7 @@ case ${PKG_TYPE} in "shared") PKG_TYPE_FLAG="--disable-static --enable-shared" ;; - ?) + *) printf "\e[1m\e[31m%s\e[0m\n" "Invalid PKG TYPE: '${PKG_TYPE}'." exit 1 ;; @@ -76,7 +76,7 @@ case ${PKG_PLATFORM} in --disable-libxcb --disable-xlib " ;; - ?) + *) ;; esac case ${PKG_PLATFORM} in @@ -85,7 +85,7 @@ case ${PKG_PLATFORM} in "iphoneos" | "iphonesimulator") CONFIGURE_COMMAND="${CONFIGURE_COMMAND} --disable-programs" ;; - ?) + *) ;; esac diff --git a/scripts/llvm.sh b/scripts/llvm.sh index fa1812d..9d4c6e7 100755 --- a/scripts/llvm.sh +++ b/scripts/llvm.sh @@ -24,7 +24,7 @@ case ${PKG_TYPE} in "shared") PKG_TYPE_FLAG="-D LLVM_BUILD_LLVM_DYLIB:BOOL=1" ;; - ?) + *) printf "\e[1m\e[31m%s\e[0m\n" "Invalid PKG TYPE: '${PKG_TYPE}'." exit 1 ;; @@ -55,7 +55,7 @@ case ${PKG_ARCH} in "arm64") LLVM_TARGET="AArch64" ;; - ?) + *) printf "\e[1m\e[31m%s\e[0m\n" "Invalid PKG_ARCH: '${PKG_ARCH}'." exit 1 ;; diff --git a/scripts/mbedtls.sh b/scripts/mbedtls.sh index 4cf8ca2..698fc41 100755 --- a/scripts/mbedtls.sh +++ b/scripts/mbedtls.sh @@ -7,7 +7,7 @@ set -e pushd -- "${SUBPROJ_SRC}" git submodule set-url -- framework ../mbedtls-framework -git submodule update --init -f -- framework +git submodule update --init --depth=1 --single-branch -f -- framework popd # ---------------------------- # preset features @@ -41,7 +41,7 @@ case ${PKG_TYPE} in PKG_TYPE_FLAG="-D USE_STATIC_MBEDTLS_LIBRARY:BOOL=1 -D USE_SHARED_MBEDTLS_LIBRARY:BOOL=0" PKG_LIBRARY_DEPS="-lmbedtls -lmbedx509 -lmbedcrypto -lp256m -leverest" ;; - ?) + *) printf "\e[1m\e[31m%s\e[0m\n" "Invalid PKG TYPE: '${PKG_TYPE}'." exit 1 ;; diff --git a/scripts/sdl2.sh b/scripts/sdl2.sh index 6dd7346..ea5aeca 100755 --- a/scripts/sdl2.sh +++ b/scripts/sdl2.sh @@ -8,7 +8,7 @@ case ${PKG_TYPE} in "static") PKG_TYPE_FLAG="-D BUILD_SHARED_LIBS:BOOL=0" ;; - ?) + *) printf "\e[1m\e[31m%s\e[0m\n" "Invalid PKG TYPE: '${PKG_TYPE}'." exit 1 ;;