|
| 1 | +name: Test Build |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: |
| 6 | + - opened |
| 7 | + - synchronize |
| 8 | + - reopened |
| 9 | + |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +jobs: |
| 13 | + test-build: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout repository |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + persist-credentials: true |
| 21 | + fetch-depth: 0 |
| 22 | + submodules: recursive |
| 23 | + |
| 24 | + - name: Set up Node.js |
| 25 | + uses: actions/setup-node@v2 |
| 26 | + with: |
| 27 | + node-version: '20' |
| 28 | + |
| 29 | + - name: Install pnpm |
| 30 | + run: npm install -g pnpm |
| 31 | + |
| 32 | + - name: Install Dependencies |
| 33 | + run: | |
| 34 | + pnpm install |
| 35 | + env: |
| 36 | + NODE_ENV: production |
| 37 | + |
| 38 | + - name: Build Plugin |
| 39 | + run: | |
| 40 | + pnpm run build |
| 41 | + env: |
| 42 | + NODE_ENV: production |
| 43 | + |
| 44 | + - name: Prepare Distribution Files |
| 45 | + run: | |
| 46 | +
|
| 47 | + mkdir -p dist |
| 48 | +
|
| 49 | + cp -r ".millennium" dist/.millennium 2>/dev/null || echo "::error::.millennium directory not found, it is required to run the plugin." |
| 50 | + cp "plugin.json" dist/plugin.json 2>/dev/null || { echo "::error::plugin.json was not found. It is required for plugins to have."; exit 1; } |
| 51 | + cp "requirements.txt" dist/requirements.txt 2>/dev/null || echo "::warning::requirements.txt not found, skipping." |
| 52 | + cp "README.md" dist/README.md 2>/dev/null || echo "::warning::README.md not found, skipping." |
| 53 | + cp "README" dist/README 2>/dev/null || echo "::warning::README not found, skipping." |
| 54 | +
|
| 55 | + BACKEND_DIR=$(jq -r '.backend' plugin.json) |
| 56 | + if [ "$BACKEND_DIR" != "null" ]; then |
| 57 | + cp -r "$BACKEND_DIR" ./dist/"$BACKEND_DIR" |
| 58 | + else |
| 59 | + cp -r "backend" ./dist/backend 2>/dev/null || echo "::warning::backend directory not found, skipping." |
| 60 | + fi |
| 61 | +
|
| 62 | + include=$(jq -r '.include // [] | .[]' plugin.json) |
| 63 | +
|
| 64 | + if [ -z "$include" ]; then |
| 65 | + echo "::notice::No additional files to include." |
| 66 | + else |
| 67 | + echo "::notice::Including additional files: $include" |
| 68 | + for item in $include; do |
| 69 | + mkdir -p "./dist/$(dirname "$item")" |
| 70 | + cp -r "./$item" "./dist/$item" |
| 71 | + done |
| 72 | + fi |
| 73 | +
|
| 74 | + echo "::notice::Computing plugin metadata..." |
| 75 | + echo "{\"commit\": \"$(git rev-parse HEAD)\", \"id\": \"$(git rev-list --max-parents=0 HEAD)\"}" > dist/metadata.json |
| 76 | +
|
| 77 | + id=$(jq -r '.id' dist/metadata.json) |
| 78 | +
|
| 79 | + cd dist |
| 80 | + echo "::notice::Building plugin archive..." |
| 81 | + zip -r build.zip . |
| 82 | +
|
| 83 | + echo "::notice::Successfully built plugin." |
| 84 | +
|
| 85 | + - name: Upload Plugin |
| 86 | + uses: actions/upload-artifact@v4 |
| 87 | + with: |
| 88 | + name: build |
| 89 | + path: dist/build.zip |
| 90 | + |
0 commit comments