From 7fc7f342550f6a3f3fde6300912a91eb3124744d Mon Sep 17 00:00:00 2001 From: Ludovic Audibert Date: Fri, 17 Dec 2021 13:47:21 +0100 Subject: [PATCH 1/8] Added release package actions --- .github/workflows/release-package-dry-run.yml | 28 +++++++++++++++++++ .github/workflows/release-package.yml | 28 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 .github/workflows/release-package-dry-run.yml create mode 100644 .github/workflows/release-package.yml diff --git a/.github/workflows/release-package-dry-run.yml b/.github/workflows/release-package-dry-run.yml new file mode 100644 index 00000000000..b5561120228 --- /dev/null +++ b/.github/workflows/release-package-dry-run.yml @@ -0,0 +1,28 @@ +name: Release Package +on: + workflow_run: + workflows: [ "Kubernetes Javascript Client - Validation" ] + branches-ignore: [ master ] + types: + - completed +jobs: + release-package: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - name: Checkout + uses: actions/checkout@v2.3.1 + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: '14.x' + # Pre-check to validate that versions match between package.json + # and package-lock.json. Needs to run before npm install + - name: Validate package.json and package-lock.json versions + run: node version-check.js + - name: Install dependencies + run: npm ci + - name: Publish package + uses: JS-DevTools/npm-publish@v1 + with: + token: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release-package.yml b/.github/workflows/release-package.yml new file mode 100644 index 00000000000..0b81b2330bf --- /dev/null +++ b/.github/workflows/release-package.yml @@ -0,0 +1,28 @@ +name: Release Package +on: + workflow_run: + workflows: [ "Kubernetes Javascript Client - Validation" ] + branches: [ master ] + types: + - completed +jobs: + release-package: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - name: Checkout + uses: actions/checkout@v2.3.1 + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: '14.x' + # Pre-check to validate that versions match between package.json + # and package-lock.json. Needs to run before npm install + - name: Validate package.json and package-lock.json versions + run: node version-check.js + - name: Install dependencies + run: npm ci + - name: Publish package + uses: JS-DevTools/npm-publish@v1 + with: + token: ${{ secrets.NPM_TOKEN }} From f9bc0014503ee1314b5c47083ca6a752aa1e86af Mon Sep 17 00:00:00 2001 From: Ludovic Audibert Date: Fri, 17 Dec 2021 13:55:06 +0100 Subject: [PATCH 2/8] Renamed dry run release action --- .github/workflows/release-package-dry-run.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-package-dry-run.yml b/.github/workflows/release-package-dry-run.yml index b5561120228..3a9ef03d626 100644 --- a/.github/workflows/release-package-dry-run.yml +++ b/.github/workflows/release-package-dry-run.yml @@ -1,4 +1,4 @@ -name: Release Package +name: Release Package Dry Run on: workflow_run: workflows: [ "Kubernetes Javascript Client - Validation" ] From 187f84a460c4d346c6fd4ab3dcdbac346a4fd7cd Mon Sep 17 00:00:00 2001 From: Ludovic Audibert Date: Fri, 17 Dec 2021 14:17:33 +0100 Subject: [PATCH 3/8] Bundled build, tests and deploy in one workflow --- .github/workflows/ci.yml | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000000..67d30c1da02 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,48 @@ +name: Kubernetes Javascript Client + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + validation: + runs-on: ubuntu-latest + strategy: + matrix: + node: [ '16', '14', '12' ] + name: Node ${{ matrix.node }} validation + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + # Pre-check to validate that versions match between package.json + # and package-lock.json. Needs to run before npm install + - run: node version-check.js + - run: npm ci + - run: npm test + - run: npm run lint + - run: npm audit --audit-level=critical + release-package: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2.3.1 + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: '14.x' + # Pre-check to validate that versions match between package.json + # and package-lock.json. Needs to run before npm install + - name: Validate package.json and package-lock.json versions + run: node version-check.js + - name: Install dependencies + run: npm ci + - name: Publish package + uses: JS-DevTools/npm-publish@v1 + with: + token: ${{ secrets.NPM_TOKEN }} + dry-run: github.event_name == 'pull_request' + From ea69539690841eba40426084187407ed75150708 Mon Sep 17 00:00:00 2001 From: Ludovic Audibert Date: Fri, 17 Dec 2021 14:17:52 +0100 Subject: [PATCH 4/8] Bundled build, tests and deploy in one workflow --- .github/workflows/test.yml | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 86034dbe4d9..00000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Kubernetes Javascript Client - Validation - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - node: [ '16', '14', '12' ] - name: Node ${{ matrix.node }} validation - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node }} - # Pre-check to validate that versions match between package.json - # and package-lock.json. Needs to run before npm install - - run: node version-check.js - - run: npm ci - - run: npm test - - run: npm run lint - - run: npm audit --audit-level=critical - From 037dc84f352849f9f02cb4a70f1416428a29860d Mon Sep 17 00:00:00 2001 From: Ludovic Audibert Date: Fri, 17 Dec 2021 14:25:31 +0100 Subject: [PATCH 5/8] Fail workflow if version was already published --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 67d30c1da02..fb4204fd97c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,7 @@ jobs: - run: npm run lint - run: npm audit --audit-level=critical release-package: + name: Release Package runs-on: ubuntu-latest steps: - name: Checkout @@ -41,8 +42,12 @@ jobs: - name: Install dependencies run: npm ci - name: Publish package + id: publish uses: JS-DevTools/npm-publish@v1 with: token: ${{ secrets.NPM_TOKEN }} dry-run: github.event_name == 'pull_request' + - name: Check if version was already published + if: steps.publish.outputs.type == 'none' + run: exit 1 From 01a153a15a00ff58ef51c6d4cc9bca7001f8b001 Mon Sep 17 00:00:00 2001 From: Ludovic Audibert Date: Fri, 17 Dec 2021 14:28:20 +0100 Subject: [PATCH 6/8] Added dependency between validation job and release job --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb4204fd97c..e55677f74de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,8 @@ jobs: - run: npm audit --audit-level=critical release-package: name: Release Package - runs-on: ubuntu-latest + runs-on: ubuntu-latest + needs: validation steps: - name: Checkout uses: actions/checkout@v2.3.1 From 9bc88d332cb1d962e250783a635702423e5ea26a Mon Sep 17 00:00:00 2001 From: Ludovic Audibert Date: Fri, 17 Dec 2021 14:38:20 +0100 Subject: [PATCH 7/8] Better version check on npm publish --- .github/workflows/ci.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e55677f74de..65dfc565cff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,6 +49,9 @@ jobs: token: ${{ secrets.NPM_TOKEN }} dry-run: github.event_name == 'pull_request' - name: Check if version was already published - if: steps.publish.outputs.type == 'none' - run: exit 1 - + uses: actions/github-script@v5 + with: + script: | + if(${{ steps.publish.outputs.type == 'none' }}) { + core.setFailed('Version ${{ steps.publish.outputs.old-version }} was already published') + } From b7fc389f3ff5aa581d25cefdb06df2cb7065bf61 Mon Sep 17 00:00:00 2001 From: Ludovic Audibert Date: Fri, 17 Dec 2021 14:45:31 +0100 Subject: [PATCH 8/8] Cleaned up workflow files --- .github/workflows/release-package-dry-run.yml | 28 ------------------- .github/workflows/release-package.yml | 28 ------------------- 2 files changed, 56 deletions(-) delete mode 100644 .github/workflows/release-package-dry-run.yml delete mode 100644 .github/workflows/release-package.yml diff --git a/.github/workflows/release-package-dry-run.yml b/.github/workflows/release-package-dry-run.yml deleted file mode 100644 index 3a9ef03d626..00000000000 --- a/.github/workflows/release-package-dry-run.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Release Package Dry Run -on: - workflow_run: - workflows: [ "Kubernetes Javascript Client - Validation" ] - branches-ignore: [ master ] - types: - - completed -jobs: - release-package: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} - steps: - - name: Checkout - uses: actions/checkout@v2.3.1 - - name: Setup Node.js - uses: actions/setup-node@v2 - with: - node-version: '14.x' - # Pre-check to validate that versions match between package.json - # and package-lock.json. Needs to run before npm install - - name: Validate package.json and package-lock.json versions - run: node version-check.js - - name: Install dependencies - run: npm ci - - name: Publish package - uses: JS-DevTools/npm-publish@v1 - with: - token: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release-package.yml b/.github/workflows/release-package.yml deleted file mode 100644 index 0b81b2330bf..00000000000 --- a/.github/workflows/release-package.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Release Package -on: - workflow_run: - workflows: [ "Kubernetes Javascript Client - Validation" ] - branches: [ master ] - types: - - completed -jobs: - release-package: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} - steps: - - name: Checkout - uses: actions/checkout@v2.3.1 - - name: Setup Node.js - uses: actions/setup-node@v2 - with: - node-version: '14.x' - # Pre-check to validate that versions match between package.json - # and package-lock.json. Needs to run before npm install - - name: Validate package.json and package-lock.json versions - run: node version-check.js - - name: Install dependencies - run: npm ci - - name: Publish package - uses: JS-DevTools/npm-publish@v1 - with: - token: ${{ secrets.NPM_TOKEN }}