diff --git a/.github/workflows/build-ndk.yml b/.github/workflows/build-ndk.yml index d5acc0b..8bd8de3 100644 --- a/.github/workflows/build-ndk.yml +++ b/.github/workflows/build-ndk.yml @@ -4,25 +4,25 @@ on: workflow_dispatch: inputs: version: - description: 'Version' + description: "Version" required: false push: tags: - "v*" branches: - - 'master' - - 'main' - - 'dev/*' - - 'feat/*' - - 'fix/*' + - "master" + - "main" + - "dev/*" + - "feat/*" + - "fix/*" pull_request: branches: - - 'master' - - 'main' - - 'dev/*' - - 'feat/*' - - 'fix/*' + - "master" + - "main" + - "dev/*" + - "feat/*" + - "fix/*" jobs: qpm_info: @@ -36,123 +36,123 @@ jobs: ndk: ${{ steps.read_qpm_info.outputs.ndk }} steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Install jq - run: | - sudo apt-get update - sudo apt-get install -y jq - - - name: Read info from qpm.json - id: read_qpm_info - run: | - if [ -f "qpm.shared.json" ]; then - NAME="$(jq -r '.config.info.name' qpm.shared.json)" - ID="$(jq -r '.config.info.id' qpm.shared.json)" - OVERRIDE_SO_NAME="$(jq -r '.config.info.additionalData.overrideSoName' qpm.shared.json)" - QMOD_OUTPUT_PATH="$(jq -r '.config.workspace.qmodOutput' qpm.shared.json)" - NDK="$(jq -r '.config.workspace.ndk' qpm.shared.json)" - else - NAME="$(jq -r '.info.name' qpm.json)" - ID="$(jq -r '.info.id' qpm.json)" - OVERRIDE_SO_NAME="$(jq -r '.info.additionalData.overrideSoName' qpm.json)" - QMOD_OUTPUT_PATH="$(jq -r '.workspace.qmodOutput' qpm.json)" - NDK="$(jq -r '.workspace.ndk' qpm.json)" - fi - - echo "name=${NAME}" | tee -a "$GITHUB_OUTPUT" - echo "id=${ID}" | tee -a "$GITHUB_OUTPUT" - echo "override_so_name=${OVERRIDE_SO_NAME}" | tee -a "$GITHUB_OUTPUT" - echo "qmod_output_path=${QMOD_OUTPUT_PATH}" | tee -a "$GITHUB_OUTPUT" - echo "ndk=${NDK}" | tee -a "$GITHUB_OUTPUT" + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install jq + run: | + sudo apt-get update + sudo apt-get install -y jq + + - name: Read info from qpm.json + id: read_qpm_info + run: | + if [ -f "qpm.shared.json" ]; then + NAME="$(jq -r '.config.info.name' qpm.shared.json)" + ID="$(jq -r '.config.info.id' qpm.shared.json)" + OVERRIDE_SO_NAME="$(jq -r '.config.info.additionalData.overrideSoName' qpm.shared.json)" + QMOD_OUTPUT_PATH="$(jq -r '.config.workspace.qmodOutput' qpm.shared.json)" + NDK="$(jq -r '.config.workspace.ndk' qpm.shared.json)" + else + NAME="$(jq -r '.info.name' qpm.json)" + ID="$(jq -r '.info.id' qpm.json)" + OVERRIDE_SO_NAME="$(jq -r '.info.additionalData.overrideSoName' qpm.json)" + QMOD_OUTPUT_PATH="$(jq -r '.workspace.qmodOutput' qpm.json)" + NDK="$(jq -r '.workspace.ndk' qpm.json)" + fi + + echo "name=${NAME}" | tee -a "$GITHUB_OUTPUT" + echo "id=${ID}" | tee -a "$GITHUB_OUTPUT" + echo "override_so_name=${OVERRIDE_SO_NAME}" | tee -a "$GITHUB_OUTPUT" + echo "qmod_output_path=${QMOD_OUTPUT_PATH}" | tee -a "$GITHUB_OUTPUT" + echo "ndk=${NDK}" | tee -a "$GITHUB_OUTPUT" build: runs-on: ubuntu-latest needs: qpm_info steps: - - uses: actions/checkout@v4 - name: Checkout - with: - submodules: true - lfs: true - - - uses: seanmiddleditch/gha-setup-ninja@v3 - - - name: Get home path - run: | - echo "HOME=$HOME" | tee -a "$GITHUB_ENV" - - - name: Extract version - if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.version != '' - id: version - run: | - if [ "${{ github.event.inputs.version }}" != "" ]; then - FULL_VERSION="${{ github.event.inputs.version }}" - VERSION="${FULL_VERSION%%[-+]*}" - else - TAG="${GITHUB_REF#refs/tags/}" - FULL_VERSION="${GITHUB_REF#refs/tags/v}" - VERSION="${FULL_VERSION%%[-+]*}" - fi - - echo "TAG=$TAG" | tee -a "$GITHUB_OUTPUT" - echo "VERSION=$VERSION" | tee -a "$GITHUB_OUTPUT" - echo "FULL_VERSION=$FULL_VERSION" | tee -a "$GITHUB_OUTPUT" - - - name: Update version in qpm.json, qpm.shared.json, and mod.template.json - if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.version != '' - run: | - # Update qpm.json - if [ -f qpm.json ]; then - MODIFIED_JSON="$(jq --arg version "$VERSION" '.info.version = $version' qpm.json)" - echo "$MODIFIED_JSON" > qpm.json - fi - - # Update qpm.shared.json if it exists - if [ -f qpm.shared.json ]; then - MODIFIED_JSON="$(jq --arg version "$VERSION" '.config.info.version = $version' qpm.shared.json)" - echo "$MODIFIED_JSON" > qpm.shared.json - fi - - # Update mod.template.json if it exists - if [ -f mod.template.json ]; then - MODIFIED_JSON="$(jq --arg version "$FULL_VERSION" '.version = $version' mod.template.json)" - echo "$MODIFIED_JSON" > mod.template.json - fi - env: - VERSION: ${{ steps.version.outputs.VERSION }} - FULL_VERSION: ${{ steps.version.outputs.FULL_VERSION }} - - - name: Setup qpm - uses: fernthedev/qpm-action@v1 - with: - workflow_token: ${{ secrets.GITHUB_TOKEN }} - restore: true - resolve_ndk: true - cache: true - - - name: Build & Create Qmod - run: | - qpm s qmod - env: - GITHUB_WORKFLOW_RUN: "true" - - - name: Rename build artifacts - run: | - mv "./build/debug/${{ needs.qpm_info.outputs.override_so_name }}" "./debug_${{ needs.qpm_info.outputs.override_so_name }}" - mv "./build/${{ needs.qpm_info.outputs.override_so_name }}" "./${{ needs.qpm_info.outputs.override_so_name }}" - - - name: Upload build artifacts - uses: actions/upload-artifact@v4 - with: - name: build-artifacts - if-no-files-found: error - path: | - ./${{ needs.qpm_info.outputs.override_so_name }} - ./debug_${{ needs.qpm_info.outputs.override_so_name }} - ${{ needs.qpm_info.outputs.qmod_output_path }} + - uses: actions/checkout@v4 + name: Checkout + with: + submodules: true + lfs: true + + - uses: seanmiddleditch/gha-setup-ninja@v3 + + - name: Get home path + run: | + echo "HOME=$HOME" | tee -a "$GITHUB_ENV" + + - name: Extract version + if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.version != '' + id: version + run: | + if [ "${{ github.event.inputs.version }}" != "" ]; then + FULL_VERSION="${{ github.event.inputs.version }}" + VERSION="${FULL_VERSION%%[-+]*}" + else + TAG="${GITHUB_REF#refs/tags/}" + FULL_VERSION="${GITHUB_REF#refs/tags/v}" + VERSION="${FULL_VERSION%%[-+]*}" + fi + + echo "TAG=$TAG" | tee -a "$GITHUB_OUTPUT" + echo "VERSION=$VERSION" | tee -a "$GITHUB_OUTPUT" + echo "FULL_VERSION=$FULL_VERSION" | tee -a "$GITHUB_OUTPUT" + + - name: Update version in qpm.json, qpm.shared.json, and mod.template.json + if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.version != '' + run: | + # Update qpm.json + if [ -f qpm.json ]; then + MODIFIED_JSON="$(jq --arg version "$VERSION" '.info.version = $version' qpm.json)" + echo "$MODIFIED_JSON" > qpm.json + fi + + # Update qpm.shared.json if it exists + if [ -f qpm.shared.json ]; then + MODIFIED_JSON="$(jq --arg version "$VERSION" '.config.info.version = $version' qpm.shared.json)" + echo "$MODIFIED_JSON" > qpm.shared.json + fi + + # Update mod.template.json if it exists + if [ -f mod.template.json ]; then + MODIFIED_JSON="$(jq --arg version "$FULL_VERSION" '.version = $version' mod.template.json)" + echo "$MODIFIED_JSON" > mod.template.json + fi + env: + VERSION: ${{ steps.version.outputs.VERSION }} + FULL_VERSION: ${{ steps.version.outputs.FULL_VERSION }} + + - name: Setup qpm + uses: fernthedev/qpm-action@v1 + with: + workflow_token: ${{ secrets.GITHUB_TOKEN }} + restore: true + resolve_ndk: true + cache: true + + - name: Build & Create Qmod + run: | + qpm s qmod + env: + GITHUB_WORKFLOW_RUN: "true" + + - name: Rename build artifacts + run: | + mv "./build/debug/${{ needs.qpm_info.outputs.override_so_name }}" "./debug_${{ needs.qpm_info.outputs.override_so_name }}" + mv "./build/${{ needs.qpm_info.outputs.override_so_name }}" "./${{ needs.qpm_info.outputs.override_so_name }}" + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: build-artifacts + if-no-files-found: error + path: | + ./${{ needs.qpm_info.outputs.override_so_name }} + ./debug_${{ needs.qpm_info.outputs.override_so_name }} + ${{ needs.qpm_info.outputs.qmod_output_path }} release: runs-on: ubuntu-latest @@ -162,52 +162,51 @@ jobs: contents: write steps: - - name: Download build artifacts - uses: actions/download-artifact@v4 - with: - name: build-artifacts - path: output/ - - - name: Upload .qmod - id: upload_file_qmod - uses: softprops/action-gh-release@v2 - with: - tag_name: ${{ github.event.inputs.version }} - draft: false - generate_release_notes: true - files: | - ./output/*.qmod - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload .so artifacts - id: upload_file_so - uses: softprops/action-gh-release@v2 - with: - tag_name: ${{ github.event.inputs.version }} - files: | - ./output/*.so - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Check if BSQMODS_TOKEN is set - id: check-token - run: | - if [ -z "${{ secrets.BSQMODS_TOKEN }}" ]; then - echo "TOKEN_SET=false" | tee -a "$GITHUB_OUTPUT" - else - echo "TOKEN_SET=true" | tee -a "$GITHUB_OUTPUT" - fi - - - name: Make PR to mod repository - if: steps.check-token.outputs.TOKEN_SET == 'true' - id: qmod-release - uses: QuestPackageManager/qmod-repo-publish-action@main - with: - token: ${{ secrets.BSQMODS_TOKEN }} - qmod_url: - ${{ - fromJSON(steps.upload_file_qmod.outputs.assets)[0].browser_download_url - }} - qmod_repo_owner: 'QuestPackageManager' - qmod_repo_name: 'bsqmods' + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: build-artifacts + path: output/ + + - name: Upload .qmod + id: upload_file_qmod + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ github.event.inputs.version }} + draft: false + generate_release_notes: true + files: | + ./output/*.qmod + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload .so artifacts + id: upload_file_so + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ github.event.inputs.version }} + files: | + ./output/*.so + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Check if BSQMODS_TOKEN is set + id: check-token + run: | + if [ -z "${{ secrets.BSQMODS_TOKEN }}" ]; then + echo "TOKEN_SET=false" | tee -a "$GITHUB_OUTPUT" + else + echo "TOKEN_SET=true" | tee -a "$GITHUB_OUTPUT" + fi + + - name: Make PR to mod repository + if: steps.check-token.outputs.TOKEN_SET == 'true' + id: qmod-release + uses: DanTheMan827/qmod-repo-publish-action@main + with: + token: ${{ secrets.BSQMODS_TOKEN }} + qmod_url: ${{ + fromJSON(steps.upload_file_qmod.outputs.assets)[0].browser_download_url + }} + qmod_repo_owner: "QuestPackageManager" + qmod_repo_name: "bsqmods"