Skip to content

Commit 3c45bea

Browse files
committed
ci: purge jsdelivr cache and add version banner
1 parent 847f649 commit 3c45bea

5 files changed

Lines changed: 68 additions & 9 deletions

File tree

.github/actions/purge-jsdelivr

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Purge jsDelivr Cache
2+
description: Purges jsDelivr cache for a list of files
3+
inputs:
4+
package:
5+
description: Package name and version (e.g. cloudinary-video-player@1.0.0 or cloudinary-video-player@edge)
6+
required: true
7+
delay-ms:
8+
description: Delay between purge requests in milliseconds
9+
required: false
10+
default: "300"
11+
12+
runs:
13+
using: "composite"
14+
steps:
15+
- name: Purge jsDelivr cache
16+
shell: bash
17+
run: |
18+
echo "Purging jsDelivr cache for ${{ inputs.package }}"
19+
DELAY=${{ inputs.delay-ms }}
20+
21+
find dist -type f | while read file; do
22+
PURGE_URL="https://purge.jsdelivr.net/npm/${{ inputs.package }}/$file"
23+
echo "Purging: $PURGE_URL"
24+
curl --retry 3 --retry-delay 2 --fail -s "$PURGE_URL"
25+
sleep $(echo "$DELAY / 1000" | bc -l)
26+
done

.github/workflows/release-edge.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ jobs:
9393
SLACK_MESSAGE: ${{ steps.set-messages.outputs.SLACK_MESSAGE }}
9494
SLACK_FOOTER: ${{ steps.set-messages.outputs.SLACK_FOOTER }}
9595

96-
- uses: gacts/purge-jsdelivr-cache@v1
96+
- name: Purge jsDelivr Cache
97+
uses: ./.github/actions/purge-jsdelivr
9798
with:
98-
url: |
99-
https://cdn.jsdelivr.net/npm/cloudinary-video-player@edge
99+
package: cloudinary-video-player@edge

.github/workflows/release.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,8 @@ jobs:
6464
SLACK_MESSAGE: ${{ steps.set-messages.outputs.SLACK_MESSAGE }}
6565
SLACK_FOOTER: ${{ steps.set-messages.outputs.SLACK_FOOTER }}
6666

67-
- uses: gacts/purge-jsdelivr-cache@v1
67+
- name: Purge jsDelivr Cache
6868
if: steps.release.outputs.release_created
69+
uses: ./.github/actions/purge-jsdelivr
6970
with:
70-
url: |
71-
https://cdn.jsdelivr.net/npm/cloudinary-video-player
72-
https://cdn.jsdelivr.net/npm/cloudinary-video-player@edge
71+
package: cloudinary-video-player

webpack/build.config.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,38 @@ const { merge } = require('webpack-merge');
22
const webpackCommon = require('./common.config');
33
const TerserPlugin = require('terser-webpack-plugin');
44
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
5+
const BannerPlugin = require('webpack/lib/BannerPlugin');
56
const { isMin } = require('./build-utils');
67

8+
const VERSION = JSON.stringify(process.env.npm_package_version);
9+
710
module.exports = merge(webpackCommon, {
811
mode: 'production',
912

1013
optimization: isMin ? {
1114
minimize: true,
1215
minimizer: [
1316
new CssMinimizerPlugin(),
14-
new TerserPlugin()
17+
new TerserPlugin({
18+
terserOptions: {
19+
format: {
20+
comments: /^!/
21+
}
22+
},
23+
extractComments: false
24+
})
1525
]
16-
} : undefined
26+
} : undefined,
27+
28+
plugins: [
29+
new BannerPlugin({
30+
banner: `/*!
31+
* Cloudinary Video Player v${VERSION.replace(/"/g, '')}
32+
* Built on ${new Date().toISOString()}
33+
* https://github.com/cloudinary/cloudinary-video-player
34+
*/`,
35+
entryOnly: false,
36+
raw: true
37+
})
38+
]
1739
});

webpack/dev.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,25 @@ const webpackCommon = require('./common.config');
33
const path = require('path');
44
const HtmlWebpackPlugin = require('html-webpack-plugin');
55
const CopyWebpackPlugin = require('copy-webpack-plugin');
6+
const BannerPlugin = require('webpack/lib/BannerPlugin');
67

78
const env = require('../env');
89

10+
const VERSION = JSON.stringify(process.env.npm_package_version);
11+
912
module.exports = merge(webpackCommon, {
1013
mode: 'development',
1114

1215
plugins: [
16+
new BannerPlugin({
17+
banner: `/*!
18+
* Cloudinary Video Player v${VERSION.replace(/"/g, '')}
19+
* Built on ${new Date().toISOString()}
20+
* https://github.com/cloudinary/cloudinary-video-player
21+
*/`,
22+
entryOnly: false,
23+
raw: true
24+
}),
1325
new HtmlWebpackPlugin({
1426
inject: false,
1527
template: path.resolve(__dirname, '../docs/index.html')

0 commit comments

Comments
 (0)