From 53246b8c361bb653e8ea7467f767f8311eb9c5c1 Mon Sep 17 00:00:00 2001 From: Imants Date: Wed, 9 Jul 2025 20:50:35 +0300 Subject: [PATCH 1/9] feat: add reusable build workflow for plugin --- .github/workflows/build.yml | 50 +++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..b5a9277e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,50 @@ +name: Build Reusable + +on: + workflow_call: + inputs: + ref: + required: false + type: string + default: core + +jobs: + build: + runs-on: ubuntu-latest + 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 dependencies + run: | + npm install + + - name: Get version + id: get_version + run: | + if [ "${{ inputs.ref }}" = "core" ] || [ -z "${{ inputs.ref }}" ]; then + VERSION=$(jq -r .version package.json) + else + VERSION="${{ inputs.ref }}" + fi + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Build plugin + run: npm run bundle + + - name: Upload built zip + uses: actions/upload-artifact@v4 + with: + name: code-snippets-${{ steps.get_version.outputs.version }}.zip + path: bundle/code-snippets*.zip From cfff9b55737a42a0b697ad1253ee6c947f6cfae3 Mon Sep 17 00:00:00 2001 From: Imants Date: Wed, 9 Jul 2025 20:50:39 +0300 Subject: [PATCH 2/9] feat: add pull request build workflow --- .github/workflows/pull-request.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/pull-request.yml diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 00000000..697c0309 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,28 @@ +name: Build for Pull Request + +on: + pull_request: + types: [labeled] + +jobs: + build: + if: contains(github.event.pull_request.labels.*.name, 'build') + uses: ./.github/workflows/build.yml + with: + ref: ${{ github.head_ref }} + + upload: + needs: build + runs-on: ubuntu-latest + steps: + - name: Download built zip + uses: actions/download-artifact@v4 + with: + name: code-snippets-${{ github.head_ref }}.zip + path: ./dist + + - name: Upload PR artifact + uses: actions/upload-artifact@v4 + with: + name: code-snippets-${{ github.head_ref }}.zip + path: ./dist/code-snippets-*.zip From 8549970e4f4c9dcd3fc6168f140bd989da09d957 Mon Sep 17 00:00:00 2001 From: Imants Date: Wed, 9 Jul 2025 20:50:47 +0300 Subject: [PATCH 3/9] feat: add release workflow for building and uploading assets --- .github/workflows/release.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..0f350ba1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: (On Release) Build & Upload + +on: + release: + types: [created] + +jobs: + build: + uses: ./.github/workflows/build.yml + with: + ref: ${{ github.event.release.tag_name }} + + upload: + needs: build + runs-on: ubuntu-latest + steps: + - name: Download built zip + uses: actions/download-artifact@v4 + with: + name: code-snippets-${{ github.sha }}.zip + path: ./dist + + - name: Upload release asset + uses: softprops/action-gh-release@v2 + with: + files: ./dist/code-snippets-*.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # deploy: + # needs: upload + # uses: ./.github/workflows/svn_push.yml + # with: + # ref: ${{ github.event.release.tag_name }} \ No newline at end of file From e9ff1324c4ae41d9286167b0c19a1c479d9e9a08 Mon Sep 17 00:00:00 2001 From: Imants Date: Wed, 9 Jul 2025 23:36:51 +0300 Subject: [PATCH 4/9] feat: update build workflow --- .github/workflows/build.yml | 40 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b5a9277e..6bc15aea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,5 @@ -name: Build Reusable +name: Build Plugin + on: workflow_call: @@ -6,11 +7,18 @@ on: ref: required: false type: string - default: core - + 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 }}.zip + artifact_url: ${{ steps.artifacts.outputs.artifact-url }} steps: - uses: actions/checkout@v4 with: @@ -26,25 +34,15 @@ jobs: with: node-version-file: .node-version - - name: Install dependencies + - name: Install & Build + id: build run: | - npm install - - - name: Get version - id: get_version - run: | - if [ "${{ inputs.ref }}" = "core" ] || [ -z "${{ inputs.ref }}" ]; then - VERSION=$(jq -r .version package.json) - else - VERSION="${{ inputs.ref }}" - fi - echo "version=$VERSION" >> $GITHUB_OUTPUT - - - name: Build plugin - run: npm run bundle + npm install && npm run bundle + echo "name=$(jq -r .name package.json)" >> $GITHUB_OUTPUT - - name: Upload built zip + - name: Upload + id: artifacts uses: actions/upload-artifact@v4 with: - name: code-snippets-${{ steps.get_version.outputs.version }}.zip - path: bundle/code-snippets*.zip + name: ${{ steps.build.outputs.name }} + path: ./bundle From 26426a8dc2c3ac4244118c3f81cbc81a3c308832 Mon Sep 17 00:00:00 2001 From: Imants Date: Wed, 9 Jul 2025 23:37:08 +0300 Subject: [PATCH 5/9] feat: refactor pull request workflow to include comment on build start and publish artifact link --- .github/workflows/pull-request.yml | 37 +++++++++++++++++++----------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 697c0309..99cd21f3 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -5,24 +5,35 @@ on: types: [labeled] jobs: - build: + 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.. + + install: + needs: comment uses: ./.github/workflows/build.yml with: ref: ${{ github.head_ref }} - upload: - needs: build + publish: + needs: ['comment', 'install'] runs-on: ubuntu-latest steps: - - name: Download built zip - uses: actions/download-artifact@v4 - with: - name: code-snippets-${{ github.head_ref }}.zip - path: ./dist - - - name: Upload PR artifact - uses: actions/upload-artifact@v4 + - name: Publish comment + if: ${{ needs.install.outputs.artifact_name || needs.install.outputs.artifact_url }} + uses: peter-evans/create-or-update-comment@v4 with: - name: code-snippets-${{ github.head_ref }}.zip - path: ./dist/code-snippets-*.zip + comment-id: ${{ needs.comment.outputs.comment_id }} + body: | + ### Download and install + 📦 [${{ needs.install.outputs.artifact_name }}](${{ needs.install.outputs.artifact_url }}) From 54e8d12b07f9a68435eb1cd9f7721421d6d8cf8d Mon Sep 17 00:00:00 2001 From: Imants Date: Wed, 9 Jul 2025 23:41:51 +0300 Subject: [PATCH 6/9] feat: enhance pull request workflow comment to include download link information --- .github/workflows/pull-request.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 99cd21f3..e0063d2a 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -17,7 +17,7 @@ jobs: with: issue-number: ${{ github.event.pull_request.number }} body: | - 👌 Build started.. + 👌 Build started.. a link to download the built zip file will appear here soon.. install: needs: comment @@ -33,6 +33,7 @@ jobs: 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 From 575229088528157380728073306de552916f2731 Mon Sep 17 00:00:00 2001 From: Imants Date: Thu, 10 Jul 2025 01:39:15 +0300 Subject: [PATCH 7/9] feat: update build workflow name and artifact output format --- .github/workflows/build.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6bc15aea..eb930d58 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,4 @@ -name: Build Plugin - +name: "(Build): Plugin" on: workflow_call: @@ -17,7 +16,7 @@ jobs: build: runs-on: ubuntu-latest outputs: - artifact_name: ${{ steps.build.outputs.name }}.zip + artifact_name: ${{ steps.build.outputs.name }} artifact_url: ${{ steps.artifacts.outputs.artifact-url }} steps: - uses: actions/checkout@v4 From 05ddabc6ef6e96f4f55a3b24ac730821e81e8257 Mon Sep 17 00:00:00 2001 From: Imants Date: Thu, 10 Jul 2025 01:39:21 +0300 Subject: [PATCH 8/9] feat: update pull request workflow name and improve comment clarity --- .github/workflows/pull-request.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index e0063d2a..154d07f4 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,4 +1,4 @@ -name: Build for Pull Request +name: "(Pull Request): Build" on: pull_request: @@ -17,7 +17,7 @@ jobs: with: issue-number: ${{ github.event.pull_request.number }} body: | - 👌 Build started.. a link to download the built zip file will appear here soon.. + 👌 Build started.. a link to the built zip file will appear here soon.. install: needs: comment @@ -37,4 +37,4 @@ jobs: comment-id: ${{ needs.comment.outputs.comment_id }} body: | ### Download and install - 📦 [${{ needs.install.outputs.artifact_name }}](${{ needs.install.outputs.artifact_url }}) + 📦 [${{ needs.install.outputs.artifact_name }}.zip](${{ needs.install.outputs.artifact_url }}) From df5402c99bf1f24d7d44b9f0511f3a7d689fed01 Mon Sep 17 00:00:00 2001 From: Imants Date: Thu, 10 Jul 2025 01:39:27 +0300 Subject: [PATCH 9/9] feat: update release workflow to improve artifact handling and naming --- .github/workflows/release.yml | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0f350ba1..f10c23f0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,31 +1,48 @@ -name: (On Release) Build & Upload +name: "(Release): Build" on: release: types: [created] jobs: - build: + install: uses: ./.github/workflows/build.yml with: ref: ${{ github.event.release.tag_name }} upload: - needs: build + 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: - name: code-snippets-${{ github.sha }}.zip + 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: ./dist/code-snippets-*.zip - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + files: ${{ steps.zip.outputs.path }} # deploy: # needs: upload