|
| 1 | +name: Continuous Deployment (Test) |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + tag: |
| 6 | + description: 'Version of the data pack' |
| 7 | + required: true |
| 8 | + default: '1.0' |
| 9 | + mc_version: |
| 10 | + description: 'Minecraft version(s) the data pack runs in (human readable)' |
| 11 | + required: true |
| 12 | + default: '1.17x-1.20x' |
| 13 | + mc_version_range: |
| 14 | + description: 'Minecraft version(s) the data pack runs in (encoded in version range spec)' |
| 15 | + required: true |
| 16 | + default: '>=1.17 <=1.20.4' |
| 17 | + |
| 18 | +jobs: |
| 19 | + deploy: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + name: Build and publish project |
| 22 | + steps: |
| 23 | + - name: Checkout code |
| 24 | + uses: actions/checkout@v4 |
| 25 | + with: |
| 26 | + show-progress: false |
| 27 | + - name: Extract tag |
| 28 | + id: tag_version |
| 29 | + run: echo "TAG_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV |
| 30 | + |
| 31 | + # Automatically set version numbers |
| 32 | + - name: Find and replace uninstall file name |
| 33 | + uses: jacobtomlinson/gha-find-replace@v3 |
| 34 | + with: |
| 35 | + find: "${file_name}" |
| 36 | + replace: ${{ github.event.repository.name }}-v${{ github.event.inputs.tag }}-mc${{ github.event.inputs.mc_version }}-datapack.zip |
| 37 | + regex: false |
| 38 | + include: "**uninstall.mcfunction" |
| 39 | + - name: Find and replace data pack version |
| 40 | + uses: jacobtomlinson/gha-find-replace@v3 |
| 41 | + with: |
| 42 | + find: "${version}" |
| 43 | + replace: ${{ github.event.inputs.tag }} |
| 44 | + regex: false |
| 45 | + - name: Find and replace supported mc versions |
| 46 | + uses: jacobtomlinson/gha-find-replace@v3 |
| 47 | + with: |
| 48 | + find: "${mc_version}" |
| 49 | + replace: ${{ github.event.inputs.mc_version }} |
| 50 | + regex: false |
| 51 | + |
| 52 | + # Check for existence of datapack, mod and/or resourcepack folders. |
| 53 | + - name: Check for data folder |
| 54 | + id: check_datapack_folder |
| 55 | + uses: andstor/file-existence-action@v3 |
| 56 | + with: |
| 57 | + files: "data" |
| 58 | + - name: Check for mod folders |
| 59 | + id: check_mod_folder |
| 60 | + uses: andstor/file-existence-action@v3 |
| 61 | + with: |
| 62 | + files: "META-INF, net, fabric.mod.json, assets" |
| 63 | + - name: Check for resource pack folder |
| 64 | + id: check_assets_folder |
| 65 | + uses: andstor/file-existence-action@v3 |
| 66 | + with: |
| 67 | + files: "assets/minecraft" |
| 68 | + |
| 69 | + # Package project |
| 70 | + - name: Create data pack zip file |
| 71 | + uses: montudor/action-zip@v1 |
| 72 | + if: steps.check_datapack_folder.outputs.files_exists == 'true' |
| 73 | + with: |
| 74 | + args: zip -qq "${{ github.event.repository.name }}-v${{ github.event.inputs.tag }}-mc${{ github.event.inputs.mc_version }}-datapack.zip" -r data 'overlay_*' pack.mcmeta pack.png LICENSE README.md |
| 75 | + - name: Create mod jar file |
| 76 | + uses: montudor/action-zip@v1 |
| 77 | + if: steps.check_mod_folder.outputs.files_exists == 'true' |
| 78 | + with: |
| 79 | + args: zip -qq "${{ github.event.repository.name }}-v${{ github.event.inputs.tag }}-mc${{ github.event.inputs.mc_version }}-mod.jar" -r data 'overlay_*' assets META-INF net fabric.mod.json pack.mcmeta pack.png LICENSE README.md |
| 80 | + - name: Create asset pack zip file |
| 81 | + uses: montudor/action-zip@v1 |
| 82 | + if: steps.check_assets_folder.outputs.files_exists == 'true' |
| 83 | + with: |
| 84 | + args: zip -qq "${{ github.event.repository.name }}-v${{ github.event.inputs.tag }}-mc${{ github.event.inputs.mc_version }}-resourcepack.zip" -r assets 'overlay_*' pack.mcmeta pack.png LICENSE README.md |
| 85 | + |
| 86 | + # Upload |
| 87 | + - name: Capture datapack build artifact |
| 88 | + if: steps.check_datapack_folder.outputs.files_exists == 'true' |
| 89 | + uses: actions/upload-artifact@v4 |
| 90 | + with: |
| 91 | + name: "Dynamic Lights (Datapack)" |
| 92 | + path: ./${{ github.event.repository.name }}-*.zip |
| 93 | + - name: Capture mod build artifact |
| 94 | + if: steps.check_mod_folder.outputs.files_exists == 'true' |
| 95 | + uses: actions/upload-artifact@v4 |
| 96 | + with: |
| 97 | + name: "Dynamic Lights (Mod)" |
| 98 | + path: ./${{ github.event.repository.name }}-*-mod.jar |
0 commit comments