fix: Fix CI #51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| - push | |
| - pull_request | |
| - workflow_dispatch # Allow manual trigger from GitHub UI | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| plugin-matrix: ${{ steps.discover-plugins.outputs.plugin-matrix }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v2 | |
| with: | |
| submodules: recursive | |
| persist-credentials: true | |
| fetch-depth: 0 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v2 | |
| with: | |
| node-version: '20' | |
| - name: Install pnpm | |
| run: npm install -g pnpm | |
| - name: Discover plugins | |
| id: discover-plugins | |
| run: | | |
| plugins=$(find plugins/* -type d -maxdepth 0) | |
| matrix=$(echo "$plugins" | jq -R -s -c 'split("\n")[:-1] | map({ plugin: . })') | |
| echo "Matrix: $matrix" | |
| echo "::set-output name=plugin-matrix::$matrix" | |
| process-plugin: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| plugin: ${{ fromJson(needs.build.outputs.plugin-matrix) }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v2 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v2 | |
| with: | |
| node-version: '20' | |
| - name: Install pnpm | |
| run: npm install -g pnpm | |
| - name: Install dependencies and build plugin | |
| run: | | |
| echo "Available directories:" | |
| ls -l # This will list the directories in the current working directory | |
| cd ${{ matrix.plugin }} | |
| echo "Changed directory to ${{ matrix.plugin }}" | |
| # Check if the directory exists before trying to run pnpm | |
| if [ -d "$PWD" ]; then | |
| pnpm install | |
| pnpm run build | |
| else | |
| echo "Error: Directory ${{ matrix.plugin }} does not exist!" | |
| exit 1 # Fail the job if the directory does not exist | |
| fi | |
| env: | |
| NODE_ENV: production | |
| - name: Copy files to dist | |
| run: | | |
| plugin_dir="${{ matrix.plugin }}" # Use the full plugin path | |
| plugin_dir=${plugin_dir##*/} # Extract the plugin folder name | |
| mkdir -p dist/"$plugin_dir" | |
| cp -r "${{ matrix.plugin }}/plugin.json" dist/"$plugin_dir"/plugin.json | |
| cp -r "${{ matrix.plugin }}/requirements.txt" dist/"$plugin_dir"/requirements.txt | |
| cp -r "${{ matrix.plugin }}/README.md" dist/"$plugin_dir"/README.md || true | |
| cp -r "${{ matrix.plugin }}/README" dist/"$plugin_dir"/README || true | |
| cd "${{ matrix.plugin }}" | |
| # Handle backend | |
| backend=$(jq -r '.backend' plugin.json) | |
| if [ "$backend" != "null" ]; then | |
| cp -r "$backend" ../../dist/"$plugin_dir"/"$backend" | |
| fi | |
| # Handle include files | |
| include=$(jq -r '.include | join(" ")' plugin.json) | |
| if [ -n "$include" ]; then | |
| for file in $include; do | |
| cp -r "$file" ../../dist/"$plugin_dir"/"$file" | |
| done | |
| fi | |
| cd ../.. | |
| # Add metadata | |
| echo "{\"commit\": \"$(git rev-parse HEAD)\", \"id\": \"$(git rev-list --max-parents=0 HEAD)\"}" > dist/"$plugin_dir"/metadata.json | |
| - name: Zip the plugin | |
| run: | | |
| plugin_dir="${{ matrix.plugin }}" | |
| plugin_dir=${plugin_dir##*/} # Extract the plugin folder name | |
| mkdir -p build | |
| cd dist | |
| zip -r "$plugin_dir.zip" "$plugin_dir" | |
| mv "$plugin_dir.zip" ../build/"$plugin_dir.zip" | |
| finalize: | |
| needs: process-plugin | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: List built plugins | |
| run: ls -l build/ | |
| - name: Run Semantic Release | |
| run: | | |
| pnpm install --save-dev semantic-release @semantic-release/changelog @semantic-release/git @semantic-release/github | |
| npx semantic-release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |