|
| 1 | +name: Collect & Release Builds |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + tag_name: |
| 7 | + description: "Release name (e.g. v1.0.5 or v1.2-rc1)" |
| 8 | + required: true |
| 9 | + prerelease: |
| 10 | + description: "Is this a prerelease?" |
| 11 | + required: true |
| 12 | + type: boolean |
| 13 | + |
| 14 | +jobs: |
| 15 | + collect-release: |
| 16 | + name: Create Release Builds |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Download Windows Full Build |
| 24 | + uses: dawidd6/action-download-artifact@v2 |
| 25 | + with: |
| 26 | + workflow: windows.yml |
| 27 | + name: Codename Engine |
| 28 | + path: artifacts/windows/full_build |
| 29 | + allow_forks: false |
| 30 | + |
| 31 | + - name: Download Windows Executable |
| 32 | + uses: dawidd6/action-download-artifact@v2 |
| 33 | + with: |
| 34 | + workflow: windows.yml |
| 35 | + name: Codename Engine (Executable Only) |
| 36 | + path: artifacts/windows/executable |
| 37 | + allow_forks: false |
| 38 | + |
| 39 | + - name: Download macOS Full Build |
| 40 | + uses: dawidd6/action-download-artifact@v2 |
| 41 | + with: |
| 42 | + workflow: macos.yml |
| 43 | + name: Codename Engine |
| 44 | + path: artifacts/macos/full_build |
| 45 | + allow_forks: false |
| 46 | + |
| 47 | + - name: Download macOS Executable |
| 48 | + uses: dawidd6/action-download-artifact@v2 |
| 49 | + with: |
| 50 | + workflow: macos.yml |
| 51 | + name: Codename Engine (Executable Only) |
| 52 | + path: artifacts/macos/executable |
| 53 | + allow_forks: false |
| 54 | + |
| 55 | + - name: Download Linux Full Build |
| 56 | + uses: dawidd6/action-download-artifact@v2 |
| 57 | + with: |
| 58 | + workflow: linux.yml |
| 59 | + name: Codename Engine |
| 60 | + path: artifacts/linux/full_build |
| 61 | + allow_forks: false |
| 62 | + |
| 63 | + - name: Download Linux Executable |
| 64 | + uses: dawidd6/action-download-artifact@v2 |
| 65 | + with: |
| 66 | + workflow: linux.yml |
| 67 | + name: Codename Engine (Executable Only) |
| 68 | + path: artifacts/linux/executable |
| 69 | + allow_forks: false |
| 70 | + |
| 71 | + - name: Prepare artifacts |
| 72 | + run: | |
| 73 | + mkdir -p renamed |
| 74 | +
|
| 75 | + mv artifacts/windows/executable/CodenameEngine.exe renamed/update-windows.exe |
| 76 | + zip -r "renamed/Codename Engine-Windows.zip" artifacts/windows/full_build |
| 77 | +
|
| 78 | + mv artifacts/macos/executable/CodenameEngine renamed/update-mac |
| 79 | + zip -r "renamed/Codename Engine-Mac.zip" artifacts/macos/full_build |
| 80 | +
|
| 81 | + mv artifacts/linux/executable/CodenameEngine renamed/update-linux |
| 82 | + zip -r "renamed/Codename Engine-Linux.zip" artifacts/linux/full_build |
| 83 | +
|
| 84 | + - name: Find Base Release |
| 85 | + id: get_base_release |
| 86 | + env: |
| 87 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 88 | + run: | |
| 89 | + echo "Looking for base release..." |
| 90 | + PRERELEASE="${{ github.event.inputs.prerelease }}" |
| 91 | +
|
| 92 | + if [[ "$PRERELEASE" == "true" ]]; then |
| 93 | + BASE=$(gh release list --repo ${{ github.repository }} --json tagName,isPrerelease,isDraft \ |
| 94 | + -L 50 -q '.[] | select(.isPrerelease==false and .isDraft==false) | .tagName' | head -n 1) |
| 95 | +
|
| 96 | + if [ -z "$BASE" ]; then |
| 97 | + echo "No stable release found, resorting to prereleases" |
| 98 | + BASE=$(gh release list --repo ${{ github.repository }} --json tagName,isDraft \ |
| 99 | + -L 1 -q '.[] | select(.isDraft==false) | .tagName') |
| 100 | + fi |
| 101 | + else |
| 102 | + BASE=$(gh release list --repo ${{ github.repository }} --json tagName,isPrerelease,isDraft \ |
| 103 | + -L 50 -q '.[] | select(.isPrerelease==false and .isDraft==false) | .tagName' | head -n 1) |
| 104 | + fi |
| 105 | +
|
| 106 | + echo "Base release: $BASE" |
| 107 | + echo "base_release=$BASE" >> $GITHUB_OUTPUT |
| 108 | +
|
| 109 | + - name: Prepare update-assets.zip |
| 110 | + env: |
| 111 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 112 | + run: | |
| 113 | + mkdir -p update_assets_temp renamed |
| 114 | + echo "Downloading assets from release ${{ steps.get_base_release.outputs.base_release }}" |
| 115 | + gh release download "${{ steps.get_base_release.outputs.base_release }}" \ |
| 116 | + --repo ${{ github.repository }} \ |
| 117 | + --pattern "update-assets.zip" \ |
| 118 | + -D update_assets_temp |
| 119 | +
|
| 120 | + unzip -q update_assets_temp/update-assets.zip -d update_assets_temp |
| 121 | + cd update_assets_temp |
| 122 | + zip -r ../renamed/update-assets.zip assets |
| 123 | + cd .. |
| 124 | +
|
| 125 | + - name: Create GitHub Release with Assets |
| 126 | + uses: softprops/action-gh-release@v1 |
| 127 | + env: |
| 128 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 129 | + with: |
| 130 | + tag_name: ${{ github.event.inputs.tag_name }} |
| 131 | + name: Release ${{ github.event.inputs.tag_name }} |
| 132 | + draft: true |
| 133 | + prerelease: ${{ github.event.inputs.prerelease }} |
| 134 | + generate_release_notes: true |
| 135 | + files: | |
| 136 | + renamed/Codename Engine-Windows.zip |
| 137 | + renamed/update-windows.exe |
| 138 | + renamed/Codename Engine-Mac.zip |
| 139 | + renamed/update-mac |
| 140 | + renamed/Codename Engine-Linux.zip |
| 141 | + renamed/update-linux |
| 142 | + renamed/update-assets.zip |
0 commit comments