From 5907da9131e0c69fc221cc29e20dfa6b43a3e83c Mon Sep 17 00:00:00 2001 From: Samuel Olwe Date: Tue, 9 Apr 2024 14:46:24 +0300 Subject: [PATCH 01/11] Added action to publish to npm on release --- .github/workflows/publish-on-release.yml | 48 ++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/publish-on-release.yml diff --git a/.github/workflows/publish-on-release.yml b/.github/workflows/publish-on-release.yml new file mode 100644 index 00000000..a7738073 --- /dev/null +++ b/.github/workflows/publish-on-release.yml @@ -0,0 +1,48 @@ +name: Publish Cookie Policy release + +on: + release: + types: [published] + +jobs: + build: + name: Build Cookie Policy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Read cookie-policy version from package.json + run: | + node -p "require('./package.json').version" > CURRENT_VERSION + echo "Building Cookie Policy v$(cat CURRENT_VERSION)" + - run: yarn install + - run: yarn build + - run: yarn test + - name: Show size of the build file + run: stat -c '%s' build/css/build.css + - run: cp CURRENT_VERSION build/css + - uses: actions/upload-artifact@v4 + with: + name: css + path: build/css + + publish-npm: + name: Publish to NPM + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 12 + registry-url: https://registry.npmjs.org/ + - if: ${{ !github.event.release.prerelease }} + run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + - if: ${{ github.event.release.prerelease }} + run: npm publish --tag next + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} From 642e5c7cac0a428de560637de9f4a9a0683090e2 Mon Sep 17 00:00:00 2001 From: Samuel Olwe Date: Tue, 9 Apr 2024 14:59:28 +0300 Subject: [PATCH 02/11] Test publish --- .github/workflows/publish-on-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-on-release.yml b/.github/workflows/publish-on-release.yml index a7738073..869eb6b3 100644 --- a/.github/workflows/publish-on-release.yml +++ b/.github/workflows/publish-on-release.yml @@ -1,8 +1,8 @@ name: Publish Cookie Policy release +# Only for testing. Should be on: release: types: [published] on: - release: - types: [published] + - push jobs: build: From 462b9850d3f13f48446de78e804d3f3e77778187 Mon Sep 17 00:00:00 2001 From: Samuel Olwe Date: Tue, 9 Apr 2024 15:04:14 +0300 Subject: [PATCH 03/11] Fix build file path --- .github/workflows/publish-on-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-on-release.yml b/.github/workflows/publish-on-release.yml index 869eb6b3..ad98b27c 100644 --- a/.github/workflows/publish-on-release.yml +++ b/.github/workflows/publish-on-release.yml @@ -21,7 +21,7 @@ jobs: - run: yarn build - run: yarn test - name: Show size of the build file - run: stat -c '%s' build/css/build.css + run: stat -c '%s' build/css/cookie-policy.css - run: cp CURRENT_VERSION build/css - uses: actions/upload-artifact@v4 with: From c0db7535a1fbcb1c3be8beaeec721a13fe2c1757 Mon Sep 17 00:00:00 2001 From: Samuel Olwe Date: Tue, 9 Apr 2024 15:18:33 +0300 Subject: [PATCH 04/11] Merge into a single file --- .github/workflows/publish-on-release.yml | 32 +++++------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/.github/workflows/publish-on-release.yml b/.github/workflows/publish-on-release.yml index ad98b27c..afcfde13 100644 --- a/.github/workflows/publish-on-release.yml +++ b/.github/workflows/publish-on-release.yml @@ -5,39 +5,19 @@ on: - push jobs: - build: - name: Build Cookie Policy + build-and-publish: + name: Publish Cookie Policy to NPM runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 18 - - name: Read cookie-policy version from package.json + - name: Build Cookie Policy run: | - node -p "require('./package.json').version" > CURRENT_VERSION - echo "Building Cookie Policy v$(cat CURRENT_VERSION)" - - run: yarn install - - run: yarn build - - run: yarn test - - name: Show size of the build file - run: stat -c '%s' build/css/cookie-policy.css - - run: cp CURRENT_VERSION build/css - - uses: actions/upload-artifact@v4 - with: - name: css - path: build/css - - publish-npm: - name: Publish to NPM - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 12 - registry-url: https://registry.npmjs.org/ + yarn install + yarn build + yarn test - if: ${{ !github.event.release.prerelease }} run: npm publish env: From 1715d65284bd028cc093c8ef4bbef90b19a71108 Mon Sep 17 00:00:00 2001 From: Samuel Olwe Date: Tue, 9 Apr 2024 15:39:48 +0300 Subject: [PATCH 05/11] Use node 12 to publish --- .github/workflows/publish-on-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-on-release.yml b/.github/workflows/publish-on-release.yml index afcfde13..dee15fc2 100644 --- a/.github/workflows/publish-on-release.yml +++ b/.github/workflows/publish-on-release.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 12 - name: Build Cookie Policy run: | yarn install From ff58800507f214a500219f0e7666c6aa00bfb3a7 Mon Sep 17 00:00:00 2001 From: Samuel Olwe Date: Tue, 9 Apr 2024 15:43:00 +0300 Subject: [PATCH 06/11] Use separate node versions for build and publish --- .github/workflows/publish-on-release.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-on-release.yml b/.github/workflows/publish-on-release.yml index dee15fc2..e3d2c184 100644 --- a/.github/workflows/publish-on-release.yml +++ b/.github/workflows/publish-on-release.yml @@ -12,12 +12,15 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 12 + node-version: 18 - name: Build Cookie Policy run: | yarn install yarn build yarn test + - uses: actions/setup-node@v4 + with: + node-version: 12 - if: ${{ !github.event.release.prerelease }} run: npm publish env: From f91179f872bda2d9c5ea876769efb6eee841dfd3 Mon Sep 17 00:00:00 2001 From: Samuel Olwe Date: Tue, 9 Apr 2024 15:48:08 +0300 Subject: [PATCH 07/11] Specify npm URL --- .github/workflows/publish-on-release.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/publish-on-release.yml b/.github/workflows/publish-on-release.yml index e3d2c184..6cfdb8b7 100644 --- a/.github/workflows/publish-on-release.yml +++ b/.github/workflows/publish-on-release.yml @@ -13,14 +13,12 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 18 + registry-url: https://registry.npmjs.org/ - name: Build Cookie Policy run: | yarn install yarn build yarn test - - uses: actions/setup-node@v4 - with: - node-version: 12 - if: ${{ !github.event.release.prerelease }} run: npm publish env: From 388d833c4ccb91aff8148275e5c7b5d0a0cdf949 Mon Sep 17 00:00:00 2001 From: Olwe Samuel Date: Tue, 9 Apr 2024 17:00:33 +0300 Subject: [PATCH 08/11] Update .github/workflows/publish-on-release.yml Co-authored-by: Bartek Szopka <83575+bartaz@users.noreply.github.com> --- .github/workflows/publish-on-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-on-release.yml b/.github/workflows/publish-on-release.yml index 6cfdb8b7..35c8107f 100644 --- a/.github/workflows/publish-on-release.yml +++ b/.github/workflows/publish-on-release.yml @@ -24,6 +24,6 @@ jobs: env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} - if: ${{ github.event.release.prerelease }} - run: npm publish --tag next + run: npm publish --tag next --access public env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} From 34ff54382b1a5c45bd9b78e287864ba352432fa2 Mon Sep 17 00:00:00 2001 From: Samuel Olwe Date: Tue, 9 Apr 2024 15:54:15 +0300 Subject: [PATCH 09/11] Only publish on event --- .github/workflows/publish-on-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-on-release.yml b/.github/workflows/publish-on-release.yml index 35c8107f..d47f0293 100644 --- a/.github/workflows/publish-on-release.yml +++ b/.github/workflows/publish-on-release.yml @@ -1,8 +1,8 @@ name: Publish Cookie Policy release -# Only for testing. Should be on: release: types: [published] on: - - push + release: + types: [published] jobs: build-and-publish: From ea4ff225e754e8d31662b1edc4d8358e52cc085c Mon Sep 17 00:00:00 2001 From: Olwe Samuel Date: Thu, 11 Apr 2024 11:29:23 +0300 Subject: [PATCH 10/11] Update .github/workflows/publish-on-release.yml Co-authored-by: Bartek Szopka <83575+bartaz@users.noreply.github.com> --- .github/workflows/publish-on-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-on-release.yml b/.github/workflows/publish-on-release.yml index d47f0293..03bd0670 100644 --- a/.github/workflows/publish-on-release.yml +++ b/.github/workflows/publish-on-release.yml @@ -20,7 +20,7 @@ jobs: yarn build yarn test - if: ${{ !github.event.release.prerelease }} - run: npm publish + run: npm publish --access public env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} - if: ${{ github.event.release.prerelease }} From 30144cae1ab6e9ebb8a69393515027bafd46654d Mon Sep 17 00:00:00 2001 From: Samuel Olwe Date: Thu, 11 Apr 2024 11:30:21 +0300 Subject: [PATCH 11/11] Bump version to 3.6.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f32393d5..6db6541d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@canonical/cookie-policy", - "version": "3.6.2", + "version": "3.6.3", "description": "A script and style sheet that displays a cookie policy notification", "main": "build/js/module.js", "iife": "build/js/cookie-policy.js",