diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..eb930d58 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,47 @@ +name: "(Build): Plugin" + +on: + workflow_call: + inputs: + ref: + required: false + type: string + default: ${{ inputs.ref }} + outputs: + artifact_name: + value: ${{ jobs.build.outputs.artifact_name }} + artifact_url: + value: ${{ jobs.build.outputs.artifact_url }} +jobs: + build: + runs-on: ubuntu-latest + outputs: + artifact_name: ${{ steps.build.outputs.name }} + artifact_url: ${{ steps.artifacts.outputs.artifact-url }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref }} + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version-file: .node-version + + - name: Install & Build + id: build + run: | + npm install && npm run bundle + echo "name=$(jq -r .name package.json)" >> $GITHUB_OUTPUT + + - name: Upload + id: artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.build.outputs.name }} + path: ./bundle diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 00000000..154d07f4 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,40 @@ +name: "(Pull Request): Build" + +on: + pull_request: + types: [labeled] + +jobs: + comment: + if: contains(github.event.pull_request.labels.*.name, 'build') + runs-on: ubuntu-latest + outputs: + comment_id: ${{ steps.comment.outputs.comment-id }} + steps: + - name: Comment + id: comment + uses: peter-evans/create-or-update-comment@v4 + with: + issue-number: ${{ github.event.pull_request.number }} + body: | + 👌 Build started.. a link to the built zip file will appear here soon.. + + install: + needs: comment + uses: ./.github/workflows/build.yml + with: + ref: ${{ github.head_ref }} + + publish: + needs: ['comment', 'install'] + runs-on: ubuntu-latest + steps: + - name: Publish comment + if: ${{ needs.install.outputs.artifact_name || needs.install.outputs.artifact_url }} + uses: peter-evans/create-or-update-comment@v4 + with: + edit-mode: replace + comment-id: ${{ needs.comment.outputs.comment_id }} + body: | + ### Download and install + 📦 [${{ needs.install.outputs.artifact_name }}.zip](${{ needs.install.outputs.artifact_url }}) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..f10c23f0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,51 @@ +name: "(Release): Build" + +on: + release: + types: [created] + +jobs: + install: + uses: ./.github/workflows/build.yml + with: + ref: ${{ github.event.release.tag_name }} + + upload: + needs: install + runs-on: ubuntu-latest + steps: + - name: Get artifact url + id: artifact + run: | + url="${{ needs.install.outputs.artifact_url }}" + id="${url##*/}" + echo "id=$id" >> $GITHUB_OUTPUT + + - name: Download built zip + id: download + uses: actions/download-artifact@v4 + with: + artifact-ids: ${{ steps.artifact.outputs.id }} + path: ./dist + + - name: Get artifact url + id: zip + run: | + zip_name="${{ needs.install.outputs.artifact_name }}.zip" + + cd ./dist/${{ needs.install.outputs.artifact_name }} + zip -r "../$zip_name" . + cd .. + + echo "path=$(pwd)/$zip_name" >> $GITHUB_OUTPUT + + - name: Upload release asset + uses: softprops/action-gh-release@v2 + with: + files: ${{ steps.zip.outputs.path }} + + # deploy: + # needs: upload + # uses: ./.github/workflows/svn_push.yml + # with: + # ref: ${{ github.event.release.tag_name }} \ No newline at end of file