|
| 1 | +name: Build Artifacts |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + ref: |
| 7 | + type: string |
| 8 | + required: false |
| 9 | + description: "Git ref to checkout (commit SHA, branch, or tag)" |
| 10 | + version_override: |
| 11 | + type: string |
| 12 | + required: false |
| 13 | + description: "Override version (for manual releases)" |
| 14 | + outputs: |
| 15 | + build_number: |
| 16 | + description: "Build number for the artifacts" |
| 17 | + value: ${{ jobs.build-api.outputs.build_number }} |
| 18 | + secrets: |
| 19 | + VITE_ACCOUNT: |
| 20 | + required: true |
| 21 | + VITE_CONNECT: |
| 22 | + required: true |
| 23 | + VITE_UNRAID_NET: |
| 24 | + required: true |
| 25 | + VITE_CALLBACK_KEY: |
| 26 | + required: true |
| 27 | + UNRAID_BOT_GITHUB_ADMIN_TOKEN: |
| 28 | + required: false |
| 29 | + |
| 30 | +jobs: |
| 31 | + build-api: |
| 32 | + name: Build API |
| 33 | + runs-on: ubuntu-latest |
| 34 | + outputs: |
| 35 | + build_number: ${{ steps.buildnumber.outputs.build_number }} |
| 36 | + defaults: |
| 37 | + run: |
| 38 | + working-directory: api |
| 39 | + steps: |
| 40 | + - name: Checkout repo |
| 41 | + uses: actions/checkout@v5 |
| 42 | + with: |
| 43 | + ref: ${{ inputs.ref || github.ref }} |
| 44 | + fetch-depth: 0 |
| 45 | + |
| 46 | + - uses: pnpm/action-setup@v4 |
| 47 | + name: Install pnpm |
| 48 | + with: |
| 49 | + run_install: false |
| 50 | + |
| 51 | + - name: Install Node |
| 52 | + uses: actions/setup-node@v5 |
| 53 | + with: |
| 54 | + node-version-file: ".nvmrc" |
| 55 | + cache: 'pnpm' |
| 56 | + |
| 57 | + - name: Cache APT Packages |
| 58 | + uses: awalsh128/cache-apt-pkgs-action@v1.5.3 |
| 59 | + with: |
| 60 | + packages: bash procps python3 libvirt-dev jq zstd git build-essential |
| 61 | + version: 1.0 |
| 62 | + |
| 63 | + - name: PNPM Install |
| 64 | + run: | |
| 65 | + cd ${{ github.workspace }} |
| 66 | + pnpm install --frozen-lockfile |
| 67 | +
|
| 68 | + - name: Get Git Short Sha and API version |
| 69 | + id: vars |
| 70 | + run: | |
| 71 | + GIT_SHA=$(git rev-parse --short HEAD) |
| 72 | + IS_TAGGED=$(git describe --tags --abbrev=0 --exact-match || echo '') |
| 73 | + PACKAGE_LOCK_VERSION=$(jq -r '.version' package.json) |
| 74 | + API_VERSION=${{ inputs.version_override && format('"{0}"', inputs.version_override) || '${PACKAGE_LOCK_VERSION}' }} |
| 75 | + if [ -z "${{ inputs.version_override }}" ] && [ -z "$IS_TAGGED" ]; then |
| 76 | + API_VERSION="${PACKAGE_LOCK_VERSION}+${GIT_SHA}" |
| 77 | + fi |
| 78 | + export API_VERSION |
| 79 | + echo "API_VERSION=${API_VERSION}" >> $GITHUB_ENV |
| 80 | + echo "PACKAGE_LOCK_VERSION=${PACKAGE_LOCK_VERSION}" >> $GITHUB_OUTPUT |
| 81 | +
|
| 82 | + - name: Generate build number |
| 83 | + id: buildnumber |
| 84 | + uses: onyxmueller/build-tag-number@v1 |
| 85 | + with: |
| 86 | + token: ${{ secrets.UNRAID_BOT_GITHUB_ADMIN_TOKEN || github.token }} |
| 87 | + prefix: ${{ inputs.version_override || steps.vars.outputs.PACKAGE_LOCK_VERSION }} |
| 88 | + |
| 89 | + - name: Build |
| 90 | + run: | |
| 91 | + pnpm run build:release |
| 92 | + tar -czf deploy/unraid-api.tgz -C deploy/pack/ . |
| 93 | +
|
| 94 | + - name: Upload tgz to Github artifacts |
| 95 | + uses: actions/upload-artifact@v4 |
| 96 | + with: |
| 97 | + name: unraid-api |
| 98 | + path: ${{ github.workspace }}/api/deploy/unraid-api.tgz |
| 99 | + |
| 100 | + build-unraid-ui-webcomponents: |
| 101 | + name: Build Unraid UI Library (Webcomponent Version) |
| 102 | + defaults: |
| 103 | + run: |
| 104 | + working-directory: unraid-ui |
| 105 | + runs-on: ubuntu-latest |
| 106 | + steps: |
| 107 | + - name: Checkout repo |
| 108 | + uses: actions/checkout@v5 |
| 109 | + with: |
| 110 | + ref: ${{ inputs.ref || github.ref }} |
| 111 | + |
| 112 | + - uses: pnpm/action-setup@v4 |
| 113 | + name: Install pnpm |
| 114 | + with: |
| 115 | + run_install: false |
| 116 | + |
| 117 | + - name: Install Node |
| 118 | + uses: actions/setup-node@v5 |
| 119 | + with: |
| 120 | + node-version-file: ".nvmrc" |
| 121 | + cache: 'pnpm' |
| 122 | + |
| 123 | + - name: Cache APT Packages |
| 124 | + uses: awalsh128/cache-apt-pkgs-action@v1.5.3 |
| 125 | + with: |
| 126 | + packages: bash procps python3 libvirt-dev jq zstd git build-essential |
| 127 | + version: 1.0 |
| 128 | + |
| 129 | + - name: Install dependencies |
| 130 | + run: | |
| 131 | + cd ${{ github.workspace }} |
| 132 | + pnpm install --frozen-lockfile --filter @unraid/ui |
| 133 | +
|
| 134 | + - name: Lint |
| 135 | + run: pnpm run lint |
| 136 | + |
| 137 | + - name: Build |
| 138 | + run: pnpm run build:wc |
| 139 | + |
| 140 | + - name: Upload Artifact to Github |
| 141 | + uses: actions/upload-artifact@v4 |
| 142 | + with: |
| 143 | + name: unraid-wc-ui |
| 144 | + path: unraid-ui/dist-wc/ |
| 145 | + |
| 146 | + build-web: |
| 147 | + name: Build Web App |
| 148 | + defaults: |
| 149 | + run: |
| 150 | + working-directory: web |
| 151 | + runs-on: ubuntu-latest |
| 152 | + steps: |
| 153 | + - name: Checkout repo |
| 154 | + uses: actions/checkout@v5 |
| 155 | + with: |
| 156 | + ref: ${{ inputs.ref || github.ref }} |
| 157 | + |
| 158 | + - name: Create env file |
| 159 | + run: | |
| 160 | + touch .env |
| 161 | + echo VITE_ACCOUNT=${{ secrets.VITE_ACCOUNT }} >> .env |
| 162 | + echo VITE_CONNECT=${{ secrets.VITE_CONNECT }} >> .env |
| 163 | + echo VITE_UNRAID_NET=${{ secrets.VITE_UNRAID_NET }} >> .env |
| 164 | + echo VITE_CALLBACK_KEY=${{ secrets.VITE_CALLBACK_KEY }} >> .env |
| 165 | +
|
| 166 | + - uses: pnpm/action-setup@v4 |
| 167 | + name: Install pnpm |
| 168 | + with: |
| 169 | + run_install: false |
| 170 | + |
| 171 | + - name: Install Node |
| 172 | + uses: actions/setup-node@v5 |
| 173 | + with: |
| 174 | + node-version-file: ".nvmrc" |
| 175 | + cache: 'pnpm' |
| 176 | + |
| 177 | + - name: PNPM Install |
| 178 | + run: | |
| 179 | + cd ${{ github.workspace }} |
| 180 | + pnpm install --frozen-lockfile --filter @unraid/web --filter @unraid/ui |
| 181 | +
|
| 182 | + - name: Build Unraid UI |
| 183 | + run: | |
| 184 | + cd ${{ github.workspace }}/unraid-ui |
| 185 | + pnpm run build |
| 186 | +
|
| 187 | + - name: Lint files |
| 188 | + run: pnpm run lint |
| 189 | + |
| 190 | + - name: Type Check |
| 191 | + run: pnpm run type-check |
| 192 | + |
| 193 | + - name: Build |
| 194 | + run: pnpm run build |
| 195 | + |
| 196 | + - name: Upload build to Github artifacts |
| 197 | + uses: actions/upload-artifact@v4 |
| 198 | + with: |
| 199 | + name: unraid-wc-rich |
| 200 | + path: web/dist |
| 201 | + |
0 commit comments