Update ci.yml #72
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 | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| submodule-matrix: ${{ steps.discover-submodules.outputs.submodule-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 submodules | |
| id: discover-submodules | |
| run: | | |
| sudo node ./scripts/discover-submodules.js > submodules.json | |
| echo "Original Submodule JSON content:" | |
| cat submodules.json | |
| # Transform JSON into a list of 'owner/repo' strings | |
| jq -c '[.[] | "\(.owner)/\(.repo)"]' submodules.json > transformed-submodules.json | |
| echo "Transformed Submodule JSON content:" | |
| cat transformed-submodules.json | |
| # Set the output for the submodule matrix | |
| echo "::set-output name=submodule-matrix::$(cat transformed-submodules.json)" | |
| process-plugin: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| repository: ${{ fromJson(needs.build.outputs.submodule-matrix) }} | |
| steps: | |
| - name: Checkout specific submodule repository | |
| uses: actions/checkout@v2 | |
| with: | |
| repository: ${{ matrix.repository }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| 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: | | |
| repo_name="${{ matrix.repository }}" | |
| repo_name=${repo_name##*/} # Extract the repo name | |
| echo "Processing plugin: $repo_name" | |
| cd "$repo_name" | |
| # list recursively all files and directories in the current directory | |
| ls -R | |
| pwd | |
| pnpm install | |
| pnpm run build | |
| env: | |
| NODE_ENV: production | |
| - name: Copy files to dist | |
| run: | | |
| mkdir -p dist | |
| pwd | |
| cp -r "plugin.json" dist/plugin.json | |
| cp -r "requirements.txt" dist/requirements.txt | |
| cp -r "README.md" dist/README.md || true | |
| cp -r "README" dist/README || true | |
| backend=$(jq -r '.backend' plugin.json) | |
| if [ "$backend" != "null" ]; then | |
| cp -r "$backend" ../../dist/"$backend" | |
| fi | |
| include=$(jq -r '.include | join(" ")' plugin.json) | |
| if [ -n "$include" ]; then | |
| for file in $include; do | |
| cp -r "$file" ../../dist/"$file" | |
| done | |
| fi | |
| cd ../.. | |
| echo "{\"commit\": \"$(git rev-parse HEAD)\", \"id\": \"$(git rev-list --max-parents=0 HEAD)\"}" > dist/metadata.json | |
| - name: Zip the plugin | |
| run: | | |
| repo_name="${{ matrix.repository }}" | |
| repo_name=${repo_name##*/} # Extract the repo name | |
| mkdir -p build | |
| cd dist | |
| zip -r "$repo_name.zip" "$repo_name" | |
| mv "$repo_name.zip" ../build/"$repo_name.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 }} |