From d14a726d751c03c975243ee1ffd2e3b8be3f1a9b Mon Sep 17 00:00:00 2001 From: otavepto <153766569+otavepto@users.noreply.github.com> Date: Sat, 11 May 2024 16:51:29 +0300 Subject: [PATCH] scripts for gen_emu_config_tool --- .github/workflows/build-migrate_gse-linux.yml | 2 +- .github/workflows/emu-build-variant-linux.yml | 2 +- .github/workflows/emu-deps-linux.yml | 2 +- ...nux.yml => gen_emu_config-build-linux.yml} | 42 ++--------- ...g-win.yml => gen_emu_config-build-win.yml} | 37 +-------- .../workflows/gen_emu_config-pull-request.yml | 22 ++++++ .github/workflows/release.yml | 75 +++++++++++++++++-- 7 files changed, 104 insertions(+), 78 deletions(-) rename .github/workflows/{build-gen_emu_config-linux.yml => gen_emu_config-build-linux.yml} (55%) rename .github/workflows/{build-gen_emu_config-win.yml => gen_emu_config-build-win.yml} (66%) create mode 100644 .github/workflows/gen_emu_config-pull-request.yml diff --git a/.github/workflows/build-migrate_gse-linux.yml b/.github/workflows/build-migrate_gse-linux.yml index 9c2bd246..925ab09c 100644 --- a/.github/workflows/build-migrate_gse-linux.yml +++ b/.github/workflows/build-migrate_gse-linux.yml @@ -36,7 +36,7 @@ jobs: ### fix folder permissions! not sure why this fails # nested subdirs "build/linux/release" cause permission problems - - name: Give all permissions for repo folder + - name: Give all permissions to repo folder shell: bash working-directory: ${{ github.workspace }} run: sudo chmod -R 777 "${{ github.workspace }}" diff --git a/.github/workflows/emu-build-variant-linux.yml b/.github/workflows/emu-build-variant-linux.yml index 6472ce4a..13b5f081 100644 --- a/.github/workflows/emu-build-variant-linux.yml +++ b/.github/workflows/emu-build-variant-linux.yml @@ -105,7 +105,7 @@ jobs: ### fix folder permissions! not sure why this fails # nested subdirs "build/linux/release" cause permission problems - - name: Give all permissions for repo folder + - name: Give all permissions to repo folder shell: bash working-directory: ${{ github.workspace }} run: sudo chmod -R 777 "${{ github.workspace }}" diff --git a/.github/workflows/emu-deps-linux.yml b/.github/workflows/emu-deps-linux.yml index 36ebd131..c44b2997 100644 --- a/.github/workflows/emu-deps-linux.yml +++ b/.github/workflows/emu-deps-linux.yml @@ -50,7 +50,7 @@ jobs: ### fix folder permissions! not sure why this fails # nested subdirs "build/linux/release" cause permission problems - - name: Give all permissions for repo folder + - name: Give all permissions to repo folder if: steps.emu-deps-cache-step.outputs.cache-hit != 'true' shell: bash working-directory: ${{ github.workspace }} diff --git a/.github/workflows/build-gen_emu_config-linux.yml b/.github/workflows/gen_emu_config-build-linux.yml similarity index 55% rename from .github/workflows/build-gen_emu_config-linux.yml rename to .github/workflows/gen_emu_config-build-linux.yml index 37a1147d..594d2e05 100644 --- a/.github/workflows/build-gen_emu_config-linux.yml +++ b/.github/workflows/gen_emu_config-build-linux.yml @@ -1,20 +1,8 @@ -name: Generate emu config script (Linux) +name: Build gen_emu_config script (Linux) on: - push: - branches: [ - "ci-build-gen-linux*", - "ci-build-all" - ] - tags: - - release* - - pull_request: - branches: [ "dev" ] - paths: - - '!**/*.md' - - 'tools/generate_emu_config/**' - + workflow_call: + # needed since it allows this to become a reusable workflow workflow_dispatch: # allows manual trigger @@ -24,7 +12,7 @@ permissions: env: ARTIFACT_NAME: "generate_emu_config-linux-${{ github.sha }}" SCRIPT_BASE_DIR: "tools/generate_emu_config" - PACKAGE_BASE_DIR: "tools/generate_emu_config/bin/package/linux" + PACKAGE_BASE_DIR: "tools/generate_emu_config/bin/linux" jobs: build: @@ -36,13 +24,13 @@ jobs: ### fix folder permissions! not sure why this fails # nested subdirs "build/linux/release" cause permission problems - - name: Give all permissions for repo folder + - name: Give all permissions to repo folder shell: bash working-directory: ${{ github.workspace }} run: sudo chmod -R 777 "${{ github.workspace }}" -# deps - - name: Install dependencies +# env + - name: Install env shell: bash working-directory: "${{ env.SCRIPT_BASE_DIR }}" run: sudo chmod 77 recreate_venv_linux.sh && sudo ./recreate_venv_linux.sh @@ -51,13 +39,7 @@ jobs: - name: Rebuild shell: bash working-directory: "${{ env.SCRIPT_BASE_DIR }}" - run: sudo chmod 77 rebuild_linux.sh && sudo ./rebuild_linux.sh - -# package - - name: Package build - shell: bash - working-directory: "${{ env.SCRIPT_BASE_DIR }}" - run: sudo chmod 77 package_linux.sh && sudo ./package_linux.sh + run: sudo chmod 77 rebuild_linux.sh && ./rebuild_linux.sh # upload artifact - name: Upload build package @@ -68,11 +50,3 @@ jobs: if-no-files-found: 'error' compression-level: 9 retention-days: 1 - -# release tag - - name: Release - if: startsWith(github.ref, 'refs/tags/') - uses: softprops/action-gh-release@v1 - with: - files: "${{ env.PACKAGE_BASE_DIR }}/**/*" - \ No newline at end of file diff --git a/.github/workflows/build-gen_emu_config-win.yml b/.github/workflows/gen_emu_config-build-win.yml similarity index 66% rename from .github/workflows/build-gen_emu_config-win.yml rename to .github/workflows/gen_emu_config-build-win.yml index a8288d2d..06152a5e 100644 --- a/.github/workflows/build-gen_emu_config-win.yml +++ b/.github/workflows/gen_emu_config-build-win.yml @@ -1,20 +1,8 @@ -name: Generate emu config script (Windows) +name: Build gen_emu_config script (Windows) on: - push: - branches: [ - "ci-build-gen-win*", - "ci-build-all" - ] - tags: - - release* - - pull_request: - branches: [ "dev" ] - paths: - - '!**/*.md' - - 'tools/generate_emu_config/**' - + workflow_call: + # needed since it allows this to become a reusable workflow workflow_dispatch: # allows manual trigger @@ -24,10 +12,7 @@ permissions: env: ARTIFACT_NAME: "generate_emu_config-win-${{ github.sha }}" SCRIPT_BASE_DIR: "tools/generate_emu_config" - PACKAGE_BASE_DIR: "tools/generate_emu_config/bin/package/win" - - THIRD_PARTY_BASE_DIR: 'third-party' - + PACKAGE_BASE_DIR: "tools/generate_emu_config/bin/win" jobs: build: @@ -67,12 +52,6 @@ jobs: working-directory: "${{ env.SCRIPT_BASE_DIR }}" run: rebuild_win.bat -# package - - name: Package build - shell: cmd - working-directory: "${{ env.SCRIPT_BASE_DIR }}" - run: package_win.bat - # upload artifact - name: Upload build package uses: actions/upload-artifact@v4 @@ -82,11 +61,3 @@ jobs: if-no-files-found: 'error' compression-level: 9 retention-days: 1 - -# release tag - - name: Release - if: startsWith(github.ref, 'refs/tags/') - uses: softprops/action-gh-release@v1 - with: - files: "${{ env.PACKAGE_BASE_DIR }}/**/*" - \ No newline at end of file diff --git a/.github/workflows/gen_emu_config-pull-request.yml b/.github/workflows/gen_emu_config-pull-request.yml new file mode 100644 index 00000000..531eb977 --- /dev/null +++ b/.github/workflows/gen_emu_config-pull-request.yml @@ -0,0 +1,22 @@ +name: Emu pull request + +on: + pull_request: + branches: [ "dev" ] + paths: + - '!**/*.md' + - 'tools/generate_emu_config/**' + +permissions: + contents: write + +jobs: + script-win: + name: Gen emu config win + if: ${{ !cancelled() }} + uses: ./.github/workflows/gen_emu_config-build-win.yml + + script-linux: + name: Gen emu config linux + if: ${{ !cancelled() }} + uses: ./.github/workflows/gen_emu_config-build-linux.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7144e240..63808317 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,6 @@ permissions: contents: write env: - PACKAGE_BASE_DIR: "build/package/win" THIRD_PARTY_BASE_DIR: 'third-party' jobs: @@ -21,7 +20,11 @@ jobs: if: ${{ !cancelled() }} uses: ./.github/workflows/emu-build-all-win.yml - + gen_emu_script-win: + name: Gen emu config win + if: ${{ !cancelled() }} + uses: ./.github/workflows/gen_emu_config-build-win.yml + emu-win-prep: needs: [ emu-win-all ] runs-on: windows-2022 @@ -37,21 +40,21 @@ jobs: # we need branch because it has package scripts - name: Checkout branch - if: steps.emu-deps-cache-step.outputs.cache-hit != 'true' uses: actions/checkout@v4 - name: Clone third-party deps (deps/win) - if: steps.emu-deps-cache-step.outputs.cache-hit != 'true' uses: actions/checkout@v4 with: ref: 'third-party/deps/win' path: "${{env.THIRD_PARTY_BASE_DIR}}/deps/win" +## donwload artifacts - name: Download emu build artifacts (Win) uses: actions/download-artifact@v4 with: # name: "emu-win-release" path: build/prep + pattern: emu-* merge-multiple: true - name: Extract all build artifacts (Win) @@ -70,8 +73,8 @@ jobs: - name: Upload build package (release) uses: actions/upload-artifact@v4 with: - name: "build-win-release-${{ github.sha }}" - path: "${{ env.PACKAGE_BASE_DIR }}/release/" + name: "build-win-release" + path: "build/package/win/release/" if-no-files-found: 'error' compression-level: 9 retention-days: 1 @@ -86,12 +89,68 @@ jobs: - name: Upload build package (debug) uses: actions/upload-artifact@v4 with: - name: "build-win-debug-${{ github.sha }}" - path: "${{ env.PACKAGE_BASE_DIR }}/debug/" + name: "build-win-debug" + path: "build/package/win/debug/" if-no-files-found: 'error' compression-level: 9 retention-days: 1 + gen_emu_script-win-prep: + needs: [ gen_emu_script-win ] + runs-on: windows-2022 + steps: + # on Windows Git will auto change line ending to CRLF, not preferable + - name: Ensure LF line ending + shell: cmd + working-directory: ${{ github.workspace }} + run: | + git config --local core.autocrlf false + git config --system core.autocrlf false + git config --global core.autocrlf false + + # we need branch because it has package scripts + - name: Checkout branch + uses: actions/checkout@v4 + + - name: Clone third-party deps (deps/win) + uses: actions/checkout@v4 + with: + ref: 'third-party/deps/win' + path: "${{env.THIRD_PARTY_BASE_DIR}}/deps/win" + +## donwload artifacts + - name: Download gen_emu_script build artifacts (Win) + uses: actions/download-artifact@v4 + with: + # name: "emu-win-release" + path: build/prep + pattern: generate_emu_config-* + merge-multiple: true + + - name: Extract all build artifacts (Win) + shell: cmd + working-directory: ${{ github.workspace }} + run: | + "${{env.THIRD_PARTY_BASE_DIR}}\deps\win\7za\7za.exe" x "build\prep\*.zip" -aos -o"tools\generate_emu_config\bin\win" + +### package + - name: Package generate_emu_config + shell: cmd + working-directory: "tools/generate_emu_config" + run: package_win.bat + +### upload artifact/package to github Actions + - name: Upload generate_emu_config package (release) + uses: actions/upload-artifact@v4 + with: + name: "generate_emu_config-win" + path: "generate_emu_config/bin/package/" + if-no-files-found: 'error' + compression-level: 9 + retention-days: 1 + + + # ### release (debug + release modes) # - name: Release # uses: softprops/action-gh-release@v1