From d9ef2b8205f020729a890e58dbea50a85ca0674e Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Mon, 8 May 2023 11:52:42 +0300 Subject: [PATCH 1/4] build(lib): add release workflows --- .github/workflows/commands-handler.yml | 43 +++++++++++++++++++ .github/workflows/release.yml | 59 ++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 .github/workflows/commands-handler.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/commands-handler.yml b/.github/workflows/commands-handler.yml new file mode 100644 index 00000000..fb5ba7f1 --- /dev/null +++ b/.github/workflows/commands-handler.yml @@ -0,0 +1,43 @@ +name: Commands processor + +on: + issue_comment: + types: [created] +defaults: + run: + shell: bash + +jobs: + process: + name: Process command + if: github.event.issue.pull_request && endsWith(github.repository, '-private') != true + runs-on: ubuntu-latest + steps: + - name: Check referred user + id: user-check + env: + CLEN_BOT: ${{ secrets.CLEN_BOT }} + run: echo "expected-user=${{ startsWith(github.event.comment.body, format('@{0} ', env.CLEN_BOT)) }}" >> $GITHUB_OUTPUT + - name: Regular comment + if: steps.user-check.outputs.expected-user != 'true' + run: echo -e "\033[38;2;19;181;255mThis is regular commit which should be ignored.\033[0m" + - name: Checkout repository + if: steps.user-check.outputs.expected-user == 'true' + uses: actions/checkout@v3 + with: + token: ${{ secrets.GH_TOKEN }} + - name: Checkout release actions + if: steps.user-check.outputs.expected-user == 'true' + uses: actions/checkout@v3 + with: + repository: pubnub/client-engineering-deployment-tools + ref: v1 + token: ${{ secrets.GH_TOKEN }} + path: .github/.release/actions + - name: Process changelog entries + if: steps.user-check.outputs.expected-user == 'true' + uses: ./.github/.release/actions/actions/commands + with: + token: ${{ secrets.GH_TOKEN }} + listener: ${{ secrets.CLEN_BOT }} + jira-api-key: ${{ secrets.JIRA_API_KEY }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..9a48614b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,59 @@ +name: Automated product release + +on: + pull_request: + branches: [master] + types: [closed] + +jobs: + check-release: + name: Check release required + runs-on: ubuntu-latest + if: github.event.pull_request.merged && endsWith(github.repository, '-private') != true + outputs: + release: ${{ steps.check.outputs.ready }} + steps: + - name: Checkout actions + uses: actions/checkout@v3 + with: + repository: pubnub/client-engineering-deployment-tools + ref: v1 + token: ${{ secrets.GH_TOKEN }} + path: .github/.release/actions + - id: check + name: Check pre-release completed + uses: ./.github/.release/actions/actions/checks/release + with: + token: ${{ secrets.GH_TOKEN }} + publish: + name: Publish package + runs-on: ubuntu-latest + needs: check-release + if: needs.check-release.outputs.release == 'true' + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + # This should be the same as the one specified for on.pull_request.branches + ref: master + - name: Checkout actions + uses: actions/checkout@v3 + with: + repository: pubnub/client-engineering-deployment-tools + ref: v1 + token: ${{ secrets.GH_TOKEN }} + path: .github/.release/actions + - name: Publish to NPM + uses: ./.github/.release/actions/actions/services/npm + with: + token: ${{ secrets.GH_TOKEN }} + npm-token: ${{ secrets.NPM_TOKEN }} + check-ownership: false + build-command: npm run build + - name: Create Release + uses: ./.github/.release/actions/actions/services/github-release + with: + token: ${{ secrets.GH_TOKEN }} + artifacts-folder: upload/normal/ + jira-api-key: ${{ secrets.JIRA_API_KEY }} + last-service: true \ No newline at end of file From 6088836f350b7b0020b8490fe4d61d76c04acfec Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Mon, 8 May 2023 17:18:14 +0300 Subject: [PATCH 2/4] build(lib): add version bump --- .github/workflows/release/versions.json | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/release/versions.json diff --git a/.github/workflows/release/versions.json b/.github/workflows/release/versions.json new file mode 100644 index 00000000..77635906 --- /dev/null +++ b/.github/workflows/release/versions.json @@ -0,0 +1,48 @@ +{ + ".pubnub.yml": [ + { + "pattern": "^version: \"(v?(\\d+\\.?){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?)\"$", + "clearedPrefix": true, + "clearedSuffix": false + }, + { + "pattern": "/refs/tags/(v?(\\d+\\.?){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?)\\.zip", + "cleared": false + }, + { + "pattern": "/releases/download/(v?(\\d+\\.?){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?)/", + "cleared": false + }, + { + "pattern": "/releases/download/.+/pubnub\\.(v?(\\d+\\.?){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?)\\.js$", + "clearedPrefix": true, + "clearedSuffix": false + } + ], + "package.json": [ + { + "pattern": "^\\s{2,}\"version\": \"(v?(\\d+\\.?){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?)\",$", + "clearedPrefix": true, + "clearedSuffix": false + } + ], + "src/core/components/config.js": [ + { + "pattern": "^\\s{2,}return '(v?(\\.?\\d+){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?)';$", + "clearedPrefix": true, + "clearedSuffix": false + } + ], + "README.md": [ + { + "pattern": "javascript/pubnub.(v?(\\.?\\d+){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?).js$", + "clearedPrefix": true, + "clearedSuffix": false + }, + { + "pattern": "javascript/pubnub.(v?(\\.?\\d+){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?).min.js$", + "clearedPrefix": true, + "clearedSuffix": false + } + ] +} From f868ec9b8ad1cc31d8bc886448e2dbcdabafc1cb Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Mon, 8 May 2023 17:21:37 +0300 Subject: [PATCH 3/4] build: adjust version match regex --- .github/workflows/release/versions.json | 42 ++----------------------- 1 file changed, 2 insertions(+), 40 deletions(-) diff --git a/.github/workflows/release/versions.json b/.github/workflows/release/versions.json index 77635906..984136ac 100644 --- a/.github/workflows/release/versions.json +++ b/.github/workflows/release/versions.json @@ -1,48 +1,10 @@ { - ".pubnub.yml": [ - { - "pattern": "^version: \"(v?(\\d+\\.?){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?)\"$", - "clearedPrefix": true, - "clearedSuffix": false - }, - { - "pattern": "/refs/tags/(v?(\\d+\\.?){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?)\\.zip", - "cleared": false - }, - { - "pattern": "/releases/download/(v?(\\d+\\.?){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?)/", - "cleared": false - }, - { - "pattern": "/releases/download/.+/pubnub\\.(v?(\\d+\\.?){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?)\\.js$", - "clearedPrefix": true, - "clearedSuffix": false - } - ], - "package.json": [ + ".pubnub.yml": [{ "pattern": "^version: (v?(\\d+\\.?){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?)$" }], + "lib/package.json": [ { "pattern": "^\\s{2,}\"version\": \"(v?(\\d+\\.?){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?)\",$", "clearedPrefix": true, "clearedSuffix": false } - ], - "src/core/components/config.js": [ - { - "pattern": "^\\s{2,}return '(v?(\\.?\\d+){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?)';$", - "clearedPrefix": true, - "clearedSuffix": false - } - ], - "README.md": [ - { - "pattern": "javascript/pubnub.(v?(\\.?\\d+){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?).js$", - "clearedPrefix": true, - "clearedSuffix": false - }, - { - "pattern": "javascript/pubnub.(v?(\\.?\\d+){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?).min.js$", - "clearedPrefix": true, - "clearedSuffix": false - } ] } From eabc9c9aa6eb9c82359409fc73aa158fc02e3a16 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Mon, 8 May 2023 17:26:08 +0300 Subject: [PATCH 4/4] build(lib): only NPM publish without artifacts release --- .github/workflows/release.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9a48614b..b8e829d6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -49,11 +49,4 @@ jobs: token: ${{ secrets.GH_TOKEN }} npm-token: ${{ secrets.NPM_TOKEN }} check-ownership: false - build-command: npm run build - - name: Create Release - uses: ./.github/.release/actions/actions/services/github-release - with: - token: ${{ secrets.GH_TOKEN }} - artifacts-folder: upload/normal/ - jira-api-key: ${{ secrets.JIRA_API_KEY }} - last-service: true \ No newline at end of file + actions: publish \ No newline at end of file