|
1 | | -name: NDK build |
| 1 | +name: QPM build |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: 'Version' |
| 8 | + required: false |
| 9 | + |
5 | 10 | push: |
6 | 11 | tags: |
7 | 12 | - "v*" |
8 | 13 | branches: |
| 14 | + - 'master' |
9 | 15 | - 'main' |
10 | 16 | - 'dev/*' |
11 | 17 | - 'feat/*' |
12 | 18 | - 'fix/*' |
13 | | - paths-ignore: |
14 | | - - '**.yml' |
15 | | - - '!.github/workflows/build-ndk.yml' |
16 | | - - '**.json' |
17 | | - - '!qpm.json' |
18 | | - - '!qpm.shared.json' |
19 | | - - '!mod.template.json' |
20 | | - - '**.txt' |
21 | | - - '!CMakeLists.txt' |
22 | | - - '**.ps1' |
23 | | - - '!build.ps1' |
24 | | - - '!createqmod.ps1' |
25 | | - - '**.md' |
26 | | - - '.gitignore' |
27 | 19 | pull_request: |
28 | | - branches: main |
29 | | - |
30 | | -env: |
31 | | - module_id: FasterScroll |
32 | | - qmod_name: Faster Scroll |
| 20 | + branches: |
| 21 | + - 'master' |
| 22 | + - 'main' |
| 23 | + - 'dev/*' |
| 24 | + - 'feat/*' |
| 25 | + - 'fix/*' |
33 | 26 |
|
34 | 27 | jobs: |
| 28 | + qpm_info: |
| 29 | + runs-on: ubuntu-latest |
| 30 | + |
| 31 | + outputs: |
| 32 | + name: ${{ steps.read_qpm_info.outputs.name }} |
| 33 | + id: ${{ steps.read_qpm_info.outputs.id }} |
| 34 | + override_so_name: ${{ steps.read_qpm_info.outputs.override_so_name }} |
| 35 | + qmod_output_path: ${{ steps.read_qpm_info.outputs.qmod_output_path }} |
| 36 | + ndk: ${{ steps.read_qpm_info.outputs.ndk }} |
| 37 | + |
| 38 | + steps: |
| 39 | + - name: Checkout repository |
| 40 | + uses: actions/checkout@v4 |
| 41 | + |
| 42 | + - name: Install jq |
| 43 | + run: | |
| 44 | + sudo apt-get update |
| 45 | + sudo apt-get install -y jq |
| 46 | +
|
| 47 | + - name: Read info from qpm.json |
| 48 | + id: read_qpm_info |
| 49 | + run: | |
| 50 | + if [ -f "qpm.shared.json" ]; then |
| 51 | + NAME="$(jq -r '.config.info.name' qpm.shared.json)" |
| 52 | + ID="$(jq -r '.config.info.id' qpm.shared.json)" |
| 53 | + OVERRIDE_SO_NAME="$(jq -r '.config.info.additionalData.overrideSoName' qpm.shared.json)" |
| 54 | + QMOD_OUTPUT_PATH="$(jq -r '.config.workspace.qmodOutput' qpm.shared.json)" |
| 55 | + NDK="$(jq -r '.config.workspace.ndk' qpm.shared.json)" |
| 56 | + else |
| 57 | + NAME="$(jq -r '.info.name' qpm.json)" |
| 58 | + ID="$(jq -r '.info.id' qpm.json)" |
| 59 | + OVERRIDE_SO_NAME="$(jq -r '.info.additionalData.overrideSoName' qpm.json)" |
| 60 | + QMOD_OUTPUT_PATH="$(jq -r '.workspace.qmodOutput' qpm.json)" |
| 61 | + NDK="$(jq -r '.workspace.ndk' qpm.json)" |
| 62 | + fi |
| 63 | +
|
| 64 | + echo "name=${NAME}" | tee -a "$GITHUB_OUTPUT" |
| 65 | + echo "id=${ID}" | tee -a "$GITHUB_OUTPUT" |
| 66 | + echo "override_so_name=${OVERRIDE_SO_NAME}" | tee -a "$GITHUB_OUTPUT" |
| 67 | + echo "qmod_output_path=${QMOD_OUTPUT_PATH}" | tee -a "$GITHUB_OUTPUT" |
| 68 | + echo "ndk=${NDK}" | tee -a "$GITHUB_OUTPUT" |
| 69 | +
|
35 | 70 | build: |
36 | 71 | runs-on: ubuntu-latest |
| 72 | + needs: qpm_info |
37 | 73 |
|
38 | 74 | steps: |
39 | | - - uses: actions/checkout@v2 |
| 75 | + - uses: actions/checkout@v4 |
40 | 76 | name: Checkout |
41 | 77 | with: |
42 | 78 | submodules: true |
43 | 79 | lfs: true |
44 | 80 |
|
45 | 81 | - uses: seanmiddleditch/gha-setup-ninja@v3 |
46 | 82 |
|
47 | | - # Use canary NDK to avoid lesser known compile bugs |
48 | | - - name: Setup canary NDK |
49 | | - id: setup-ndk |
50 | | - uses: ./.github/actions/canary-ndk |
51 | | - |
52 | | - - name: Create ndkpath.txt |
| 83 | + - name: Get home path |
53 | 84 | run: | |
54 | | - echo ${{ steps.setup-ndk.outputs.ndk-path }} > ${GITHUB_WORKSPACE}/ndkpath.txt |
55 | | - cat ${GITHUB_WORKSPACE}/ndkpath.txt |
| 85 | + echo "HOME=$HOME" | tee -a "$GITHUB_ENV" |
56 | 86 |
|
57 | | - # get version from pushed tag |
58 | 87 | - name: Extract version |
59 | | - if: startsWith(github.ref, 'refs/tags/v') |
| 88 | + if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.version != '' |
60 | 89 | id: version |
61 | 90 | run: | |
62 | | - echo "TAG=${GITHUB_REF#refs/tags/}" >> ${GITHUB_OUTPUT} |
63 | | - echo "VERSION=${GITHUB_REF#refs/tags/v}" >> ${GITHUB_OUTPUT} |
| 91 | + if [ "${{ github.event.inputs.version }}" != "" ]; then |
| 92 | + FULL_VERSION="${{ github.event.inputs.version }}" |
| 93 | + VERSION="${FULL_VERSION%%[-+]*}" |
| 94 | + else |
| 95 | + TAG="${GITHUB_REF#refs/tags/}" |
| 96 | + FULL_VERSION="${GITHUB_REF#refs/tags/v}" |
| 97 | + VERSION="${FULL_VERSION%%[-+]*}" |
| 98 | + fi |
| 99 | +
|
| 100 | + echo "TAG=$TAG" | tee -a "$GITHUB_OUTPUT" |
| 101 | + echo "VERSION=$VERSION" | tee -a "$GITHUB_OUTPUT" |
| 102 | + echo "FULL_VERSION=$FULL_VERSION" | tee -a "$GITHUB_OUTPUT" |
| 103 | +
|
| 104 | + - name: Update version in qpm.json, qpm.shared.json, and mod.template.json |
| 105 | + if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.version != '' |
| 106 | + run: | |
| 107 | + # Update qpm.json |
| 108 | + if [ -f qpm.json ]; then |
| 109 | + MODIFIED_JSON="$(jq --arg version "$VERSION" '.info.version = $version' qpm.json)" |
| 110 | + echo "$MODIFIED_JSON" > qpm.json |
| 111 | + fi |
| 112 | +
|
| 113 | + # Update qpm.shared.json if it exists |
| 114 | + if [ -f qpm.shared.json ]; then |
| 115 | + MODIFIED_JSON="$(jq --arg version "$VERSION" '.config.info.version = $version' qpm.shared.json)" |
| 116 | + echo "$MODIFIED_JSON" > qpm.shared.json |
| 117 | + fi |
| 118 | +
|
| 119 | + # Update mod.template.json if it exists |
| 120 | + if [ -f mod.template.json ]; then |
| 121 | + MODIFIED_JSON="$(jq --arg version "$FULL_VERSION" '.version = $version' mod.template.json)" |
| 122 | + echo "$MODIFIED_JSON" > mod.template.json |
| 123 | + fi |
| 124 | + env: |
| 125 | + VERSION: ${{ steps.version.outputs.VERSION }} |
| 126 | + FULL_VERSION: ${{ steps.version.outputs.FULL_VERSION }} |
64 | 127 |
|
65 | | - # if we don't have a tag, don't do anything special |
66 | 128 | - name: Setup qpm |
67 | | - if: ${{ !startsWith(github.ref, 'refs/tags/v') }} |
68 | | - uses: Fernthedev/qpm-action@main |
| 129 | + uses: fernthedev/qpm-action@v1 |
69 | 130 | with: |
70 | 131 | workflow_token: ${{ secrets.GITHUB_TOKEN }} |
71 | 132 | restore: true |
| 133 | + resolve_ndk: true |
72 | 134 | cache: true |
73 | | - publish: false |
74 | 135 |
|
75 | 136 | - name: Build & Create Qmod |
76 | 137 | run: | |
77 | | - cd ${GITHUB_WORKSPACE} |
78 | 138 | qpm s qmod |
79 | 139 |
|
80 | | - - name: Get Library Name |
81 | | - id: libname |
| 140 | + - name: Rename build artifacts |
82 | 141 | run: | |
83 | | - cd ./build/ |
84 | | - pattern="lib${module_id}*.so" |
85 | | - files=( $pattern ) |
86 | | - echo "NAME=${files[0]}" >> ${GITHUB_OUTPUT} |
87 | | -
|
88 | | - - name: Rename debug artifact |
89 | | - run: mv "./build/debug/${{ steps.libname.outputs.NAME }}" "./build/debug_${{ steps.libname.outputs.NAME }}" |
| 142 | + mv "./build/debug/${{ needs.qpm_info.outputs.override_so_name }}" "./debug_${{ needs.qpm_info.outputs.override_so_name }}" |
| 143 | + mv "./build/${{ needs.qpm_info.outputs.override_so_name }}" "./${{ needs.qpm_info.outputs.override_so_name }}" |
90 | 144 |
|
91 | | - - name: Upload non-debug artifact |
92 | | - uses: actions/upload-artifact@v2 |
| 145 | + - name: Upload build artifacts |
| 146 | + uses: actions/upload-artifact@v4 |
93 | 147 | with: |
94 | | - name: ${{ steps.libname.outputs.NAME }} |
95 | | - path: ./build/${{ steps.libname.outputs.NAME }} |
| 148 | + name: build-artifacts |
96 | 149 | if-no-files-found: error |
| 150 | + path: | |
| 151 | + ./${{ needs.qpm_info.outputs.override_so_name }} |
| 152 | + ./debug_${{ needs.qpm_info.outputs.override_so_name }} |
| 153 | + ${{ needs.qpm_info.outputs.qmod_output_path }} |
| 154 | +
|
| 155 | + release: |
| 156 | + runs-on: ubuntu-latest |
| 157 | + needs: build |
| 158 | + if: startsWith(github.ref, 'refs/tags/v') |
| 159 | + permissions: |
| 160 | + contents: write |
97 | 161 |
|
98 | | - - name: Upload debug artifact |
99 | | - uses: actions/upload-artifact@v2 |
| 162 | + steps: |
| 163 | + - name: Download build artifacts |
| 164 | + uses: actions/download-artifact@v4 |
100 | 165 | with: |
101 | | - name: debug_${{ steps.libname.outputs.NAME }} |
102 | | - path: ./build/debug_${{ steps.libname.outputs.NAME }} |
103 | | - if-no-files-found: error |
| 166 | + name: build-artifacts |
| 167 | + path: output/ |
104 | 168 |
|
105 | | - - name: Upload qmod artifact |
106 | | - uses: actions/upload-artifact@v2 |
| 169 | + - name: Upload .qmod |
| 170 | + id: upload_file_qmod |
| 171 | + uses: softprops/action-gh-release@v2 |
107 | 172 | with: |
108 | | - name: ${{env.qmod_name}}.qmod |
109 | | - path: ./${{ env.qmod_name }}.qmod |
110 | | - if-no-files-found: error |
| 173 | + tag_name: ${{ github.event.inputs.version }} |
| 174 | + draft: false |
| 175 | + generate_release_notes: true |
| 176 | + files: | |
| 177 | + ./output/*.qmod |
| 178 | + env: |
| 179 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
111 | 180 |
|
112 | | - # if we had a tag, we should make a release |
113 | | - - name: Upload release artifacts |
114 | | - if: startsWith(github.ref, 'refs/tags/v') |
115 | | - id: upload_file_release |
116 | | - uses: softprops/action-gh-release@v0.1.15 |
| 181 | + - name: Upload .so artifacts |
| 182 | + id: upload_file_so |
| 183 | + uses: softprops/action-gh-release@v2 |
117 | 184 | with: |
118 | 185 | tag_name: ${{ github.event.inputs.version }} |
119 | 186 | files: | |
120 | | - ./build/${{ steps.libname.outputs.NAME }} |
121 | | - ./build/debug_${{ steps.libname.outputs.NAME }} |
122 | | - ./${{ env.qmod_name }}.qmod |
| 187 | + ./output/*.so |
123 | 188 | env: |
124 | 189 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 190 | + |
| 191 | + - name: Check if BSQMODS_TOKEN is set |
| 192 | + id: check-token |
| 193 | + run: | |
| 194 | + if [ -z "${{ secrets.BSQMODS_TOKEN }}" ]; then |
| 195 | + echo "TOKEN_SET=false" | tee -a "$GITHUB_OUTPUT" |
| 196 | + else |
| 197 | + echo "TOKEN_SET=true" | tee -a "$GITHUB_OUTPUT" |
| 198 | + fi |
| 199 | +
|
| 200 | + - name: Make PR to mod repository |
| 201 | + if: steps.check-token.outputs.TOKEN_SET == 'true' |
| 202 | + id: qmod-release |
| 203 | + uses: QuestPackageManager/qmod-repo-publish-action@main |
| 204 | + with: |
| 205 | + token: ${{ secrets.BSQMODS_TOKEN }} |
| 206 | + qmod_url: |
| 207 | + ${{ |
| 208 | + fromJSON(steps.upload_file_qmod.outputs.assets)[0].browser_download_url |
| 209 | + }} |
| 210 | + qmod_repo_owner: 'QuestPackageManager' |
| 211 | + qmod_repo_name: 'bsqmods' |
0 commit comments