diff --git a/.github/workflows/buildndk.yml b/.github/workflows/buildndk.yml index abb96b3881c..9ab2e20f09b 100644 --- a/.github/workflows/buildndk.yml +++ b/.github/workflows/buildndk.yml @@ -1,106 +1,85 @@ name: NDK build env: - ndkname: android-ndk-r23 - module_id: codegen - qmodName: Codegen - cache-name: codegen_cache + module_id: codegen + qmodName: Codegen + cache-name: codegen_cache on: workflow_dispatch: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] jobs: build: runs-on: ubuntu-latest - + steps: - - uses: actions/checkout@v2 - name: Checkout - with: - submodules: true - lfs: true - - - uses: seanmiddleditch/gha-setup-ninja@v3 - - - name: Create ndkpath.txt - run: | - echo "$ANDROID_NDK_LATEST_HOME" > ${GITHUB_WORKSPACE}/ndkpath.txt - cat ${GITHUB_WORKSPACE}/ndkpath.txt - - - name: Get QPM - if: steps.cache-qpm.outputs.cache-hit != 'true' - uses: dawidd6/action-download-artifact@v2 - with: - github_token: ${{secrets.GITHUB_TOKEN}} - workflow: cargo-build.yml - name: linux-qpm-rust - path: QPM - repo: RedBrumbler/QuestPackageManager-Rust - - - name: QPM Collapse - run: | - chmod +x ./QPM/qpm-rust - ./QPM/qpm-rust collapse - - - name: QPM Dependencies Cache - id: cache-qpm-deps - uses: actions/cache@v2 - env: - cache-name: cache-qpm-deps - with: - path: /home/runner/.local/share/QPM-Rust/cache - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('qpm.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - - name: QPM Restore - run: | - chmod +x ./QPM/qpm-rust - ./QPM/qpm-rust restore - - - name: List Post Restore - run: | - echo includes: - ls -la ${GITHUB_WORKSPACE}/extern/includes - echo libs: - ls -la ${GITHUB_WORKSPACE}/extern/libs - echo cache: - ls -la $HOME/.local/share/QPM-Rust/cache - - - name: Build - run: | - cd ${GITHUB_WORKSPACE} - ./QPM/qpm-rust qmod build --isLibrary=true - pwsh -Command ./build.ps1 - - - name: Create Qmod - run: | - pwsh -Command ./createqmod.ps1 ${{env.qmodName}} - - - name: Get Library Name - id: libname - run: | - cd ./build/ - pattern="lib${module_id}*.so" - files=( $pattern ) - echo ::set-output name=NAME::"${files[0]}" - - - name: Upload non-debug artifact - uses: actions/upload-artifact@v2 - with: - name: ${{ steps.libname.outputs.NAME }} - path: ./build/${{ steps.libname.outputs.NAME }} - if-no-files-found: error - - - name: Upload qmod artifact - uses: actions/upload-artifact@v2 - with: - name: ${{env.qmodName}}.qmod - path: ./${{ env.qmodName }}.qmod - if-no-files-found: error + - uses: actions/checkout@v2 + name: Checkout + with: + submodules: true + lfs: true + + - uses: seanmiddleditch/gha-setup-ninja@v3 + + - name: Create ndkpath.txt + run: | + echo "$ANDROID_NDK_LATEST_HOME" > ${GITHUB_WORKSPACE}/ndkpath.txt + cat ${GITHUB_WORKSPACE}/ndkpath.txt + + - name: QPM Rust Action + uses: Fernthedev/qpm-rust-action@main + with: + #required + workflow_token: ${{secrets.GITHUB_TOKEN}} + + restore: true # will run restore on download + cache: true #will cache dependencies + + # Name of qmod in release asset. Assumes exists, same as prior + qpm_qmod: ${{env.qmodName}}.qmod + + - name: QPM Collapse + run: qpm-rust collapse + + - name: Build + run: | + cd ${GITHUB_WORKSPACE} + qpm-rust s build + + - name: Create Qmod + run: | + qpm-rust qmod build + pwsh -Command ./createqmod.ps1 ${{env.qmodName}} + + - name: Get Library Name + id: libname + run: | + cd ./build/ + pattern="lib${module_id}*.so" + files=( $pattern ) + echo ::set-output name=NAME::"${files[0]}" + + - name: Upload non-debug artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ steps.libname.outputs.NAME }} + path: ./build/${{ steps.libname.outputs.NAME }} + if-no-files-found: error + + - name: Upload debug artifact + uses: actions/upload-artifact@v2 + with: + name: debug_${{ steps.libname.outputs.NAME }} + path: ./build/debug_${{ steps.libname.outputs.NAME }} + if-no-files-found: error + + - name: Upload qmod artifact + uses: actions/upload-artifact@v2 + with: + name: ${{env.qmodName}}.qmod + path: ./${{ env.qmodName }}.qmod + if-no-files-found: error diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6853d91902c..1222bbb14d0 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,199 +1,89 @@ name: Publish QPM Package env: - ndkname: android-ndk-r23 - module_id: codegen - qmodName: Codegen - cache-name: codegen_cache + module_id: codegen + qmodName: Codegen + cache-name: codegen_cache on: push: tags: - - 'v*' + - "v*" jobs: publish: runs-on: ubuntu-latest - + steps: - - uses: actions/checkout@v2 - name: Checkout - with: - submodules: true - lfs: true - - - uses: seanmiddleditch/gha-setup-ninja@v3 - - - name: Create ndkpath.txt - run: | - echo "$ANDROID_NDK_LATEST_HOME" > ${GITHUB_WORKSPACE}/ndkpath.txt - cat ${GITHUB_WORKSPACE}/ndkpath.txt - - - name: Get QPM - if: steps.cache-qpm.outputs.cache-hit != 'true' - uses: dawidd6/action-download-artifact@v2 - with: - github_token: ${{secrets.GITHUB_TOKEN}} - workflow: cargo-build.yml - name: linux-qpm-rust - path: QPM - repo: RedBrumbler/QuestPackageManager-Rust - - - name: QPM Collapse - run: | - chmod +x ./QPM/qpm-rust - ./QPM/qpm-rust collapse - - # added the cache on the off chance the qpm.json stays the same across versions - - name: QPM Dependencies Cache - id: cache-qpm-deps - uses: actions/cache@v2 - env: - cache-name: cache-qpm-deps - with: - path: /home/runner/.local/share/QPM-Rust/cache - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('qpm.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - - name: QPM Restore - run: | - chmod +x ./QPM/qpm-rust - ./QPM/qpm-rust restore - - - name: List Post Restore - run: | - echo includes: - ls -la ${GITHUB_WORKSPACE}/extern/includes - echo libs: - ls -la ${GITHUB_WORKSPACE}/extern/libs - echo cache: - ls -la $HOME/.local/share/QPM-Rust/cache - - - name: Get Tag Version - id: get_tag_version - run: | - echo ${GITHUB_REF#refs/tags/} - echo ::set-output name=TAG::${GITHUB_REF#refs/tags/} - echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v} - - - name: QPM Edit Version - run: | - ./QPM/qpm-rust package edit --version "${{ steps.get_tag_version.outputs.VERSION }}" - - - name: Build - run: | - cd ${GITHUB_WORKSPACE} - ./QPM/qpm-rust qmod build --isLibrary=true - pwsh -Command ./build.ps1 - - name: Create Qmod - run: | - pwsh -Command ./createqmod.ps1 ${{env.qmodName}} - - # Commit the change to the package, .vscode/c_cpp_properties.json, and Android.mk - - name: Configure commit - run: | - git config user.name "Github Actions" - git config user.email "<>" - - - name: Commit Edit Version - run: | - git add qpm.json - git commit -m "Update Version and post restore" - - # Then, we want to use the commit we have just made, and force push our tag to that commit - - name: Get Commit ID - id: get_commit_id - run: | - echo `git rev-parse HEAD` - echo ::set-output name=ID::`git rev-parse HEAD` - - - name: Force create tag - run: | - git tag --force ${{ steps.get_tag_version.outputs.TAG }} ${{ steps.get_commid_id.outputs.ID }} - - # Then, push, upload our artifacts, modify the config file to have soLink and debugSoLink - - name: Create and push version specific branch - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - git branch version-${{ steps.get_tag_version.outputs.TAG }} - git push -u origin version-${{ steps.get_tag_version.outputs.TAG }} --force --tags - - # Get release that was created for this tag - - name: Get Release - uses: octokit/request-action@v2.x - id: get_release - with: - route: GET /repos/:repository/releases/tags/${{ steps.get_tag_version.outputs.TAG }} - repository: ${{ github.repository }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/checkout@v2 + name: Checkout + with: + submodules: true + lfs: true + + - uses: seanmiddleditch/gha-setup-ninja@v3 + + - name: Create ndkpath.txt + run: | + echo "$ANDROID_NDK_LATEST_HOME" > ${GITHUB_WORKSPACE}/ndkpath.txt + cat ${GITHUB_WORKSPACE}/ndkpath.txt + + - name: Get Tag Version + id: get_tag_version + run: | + echo ${GITHUB_REF#refs/tags/} + echo ::set-output name=TAG::${GITHUB_REF#refs/tags/} + echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v} + + - name: QPM Rust Action + uses: Fernthedev/qpm-rust-action@main + with: + #required + workflow_token: ${{secrets.GITHUB_TOKEN}} + + restore: true # will run restore on download + cache: true #will cache dependencies - - name: Get Release Upload URL - id: get_upload_url - run: | - url=$(echo "$response" | jq -r '.upload_url') - echo $url - echo "::set-output name=upload_url::$url" - env: - response: ${{ steps.get_release.outputs.data }} - - - name: Get Library Name - id: libname - run: | - cd ./build/ - pattern="lib${module_id}*.so" - files=( $pattern ) - echo ::set-output name=NAME::"${files[0]}" - - - name: Upload Release Asset - id: upload_release_asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.get_upload_url.outputs.upload_url }} - asset_path: ./build/${{ steps.libname.outputs.NAME }} - asset_name: ${{ steps.libname.outputs.NAME }} - asset_content_type: application/octet-stream - - - name: Upload Qmod Asset - id: upload_qmod_asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.get_upload_url.outputs.upload_url }} - asset_path: ./${{env.qmodName}}.qmod - asset_name: ${{env.qmodName}}.qmod - asset_content_type: application/octet-stream - - - name: Change QPM Package Info - run: | - ./QPM/qpm-rust package edit-extra --branchName "version-${{ steps.get_tag_version.outputs.TAG }}" - ./QPM/qpm-rust package edit-extra --soLink "${{ steps.upload_release_asset.outputs.browser_download_url }}" - ./QPM/qpm-rust package edit-extra --modLink "${{ steps.upload_qmod_asset.outputs.browser_download_url }}" - - - name: Commit Changed package info - run: | - git add qpm.json - git commit -m "Updated qpm.json" - - # Then, we want to use the commit we have just made, and force push our tag to that commit - - name: Get Commit ID - id: get_created_commit_id - run: | - echo `git rev-parse HEAD` - echo ::set-output name=ID::`git rev-parse HEAD` - - - name: Push New Commit and Tag - run: | - git push origin HEAD:version-${{ steps.get_tag_version.outputs.TAG }} --force - git tag --force ${{ steps.get_tag_version.outputs.TAG }} ${{ steps.get_created_commit_id.outputs.ID }} - git push --tags --force - - - name: QPM Publish - run: ./QPM/qpm-rust publish "${{secrets.PUBLISH_KEY}}" + publish: true + publish_token: ${{secrets.PUBLISH_KEY}} + + version: ${{ steps.get_tag_version.outputs.VERSION }} + tag: ${{ steps.get_tag_version.outputs.TAG }} + + # set to true if applicable, ASSUMES the file is already a release asset + qpm_release_bin: true + qpm_debug_bin: true + + # Name of qmod in release asset. Assumes exists, same as prior + qpm_qmod: ${{env.qmodName}}.qmod + + - name: Build + run: | + cd ${GITHUB_WORKSPACE} + qpm-rust s build + qpm-rust qmod build + + - name: Get Library Name + id: libname + run: | + cd ./build/ + pattern="lib${module_id}*.so" + files=( $pattern ) + echo ::set-output name=NAME::"${files[0]}" + + - name: Create Qmod + run: | + pwsh -Command ./createqmod.ps1 ${{env.qmodName}} + + - name: Upload to Release + id: upload_file_release + uses: softprops/action-gh-release@v0.1.15 + with: + name: ${{ github.event.inputs.release_msg }} + tag_name: ${{ github.event.inputs.version }} + files: | + ./build/${{ steps.libname.outputs.NAME }} + ./build/debug_${{ steps.libname.outputs.NAME }} + ./${{ env.qmodName }}.qmod + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index ba97bea65d7..917b9ab72fe 100644 --- a/.gitignore +++ b/.gitignore @@ -6,10 +6,9 @@ qpm.lock.json ndkpath.txt obj/ libs/ -qpm.shared.json +.cache/ *.zip -qpm.shared.json mod.json extern.cmake qpm_defines.cmake diff --git a/qpm.json b/qpm.json index 8be6a25914b..44f83936a0d 100644 --- a/qpm.json +++ b/qpm.json @@ -19,5 +19,11 @@ } } ], - "additionalData": {} -} + "workspace": { + "scripts": { + "build": [ + "pwsh ./build.ps1" + ] + } + } +} \ No newline at end of file diff --git a/qpm.shared.json b/qpm.shared.json new file mode 100644 index 00000000000..f835f55f54b --- /dev/null +++ b/qpm.shared.json @@ -0,0 +1,66 @@ +{ + "config": { + "sharedDir": "include", + "dependenciesDir": "extern", + "info": { + "name": "codegen", + "id": "codegen", + "version": "0.0.1", + "url": "https://github.com/sc2ad/BeatSaber-Quest-Codegen", + "additionalData": { + "overrideSoName": "libcodegen.so" + } + }, + "dependencies": [ + { + "id": "beatsaber-hook", + "versionRange": "^4.0.0", + "additionalData": {} + } + ], + "workspace": { + "scripts": { + "build": [ + "pwsh ./build.ps1" + ] + } + } + }, + "restoredDependencies": [ + { + "dependency": { + "id": "libil2cpp", + "versionRange": "=0.2.3", + "additionalData": { + "headersOnly": true + } + }, + "version": "0.2.3" + }, + { + "dependency": { + "id": "beatsaber-hook", + "versionRange": "=4.0.0", + "additionalData": { + "soLink": "https://github.com/sc2ad/beatsaber-hook/releases/download/v4.0.0/libbeatsaber-hook_4_0_0.so", + "debugSoLink": "https://github.com/sc2ad/beatsaber-hook/releases/download/v4.0.0/debug_libbeatsaber-hook_4_0_0.so", + "branchName": "version/v4_0_0" + } + }, + "version": "4.0.0" + }, + { + "dependency": { + "id": "scotland2", + "versionRange": "=0.1.2", + "additionalData": { + "soLink": "https://github.com/sc2ad/scotland2/releases/download/v0.1.2/libsl2.so", + "debugSoLink": "https://github.com/sc2ad/scotland2/releases/download/v0.1.2/debug_libsl2.so", + "overrideSoName": "libsl2.so", + "branchName": "version/v0_1_2" + } + }, + "version": "0.1.2" + } + ] +} \ No newline at end of file