diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 7df2b4b..5583881 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -10,12 +10,33 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: '20' registry-url: 'https://registry.npmjs.org' - - run: npm ci - - run: npm publish + - name: Install dependencies + run: npm ci + + - name: Build release package + run: npm run release + + - name: Get package version + id: get_version + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + + - name: Upload Release Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./dist/nhsapp-frontend-${{ steps.get_version.outputs.VERSION }}.zip + asset_name: nhsapp-frontend-${{ steps.get_version.outputs.VERSION }}.zip + asset_content_type: application/zip + + - name: Publish NPM package + run: npm publish env: NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}} IS_PRERELEASE: ${{github.event.release.prerelease}} diff --git a/gulpfile.js b/gulpfile.js index 7ca7cdf..0a028f2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -2,6 +2,7 @@ import gulp from 'gulp' import * as dartSass from 'sass' import gulpSass from 'gulp-sass' import gulpClean from 'gulp-clean' +import zip from 'gulp-zip' import rename from 'gulp-rename' import cleanCSS from 'gulp-clean-css' import packageJson from './package.json' with { type: 'json' } @@ -62,6 +63,16 @@ function watch() { gulp.watch(['src/**/*'], compileCSS) } +/** + * Release tasks + */ +function createZip() { + return gulp + .src(['dist/nhsapp/**', `dist/nhsapp-${packageJson.version}.min.css`]) + .pipe(zip(`nhsapp-frontend-${packageJson.version}.zip`)) + .pipe(gulp.dest('dist')) +} + /** * The default task is to build everything, and watch for changes */ @@ -75,4 +86,12 @@ const bundle = gulp.series([ copySource ]) -export { clean, bundle, compileCSS } +const release = gulp.series([ + clean, + compileCSS, + minifyCSS, + copySource, + createZip +]) + +export { clean, bundle, compileCSS, release } diff --git a/package-lock.json b/package-lock.json index 9df5844..4bfadd2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,7 @@ "gulp-rename": "^2.0.0", "gulp-sass": "^5.1.0", "gulp-uglify": "^3.0.2", + "gulp-zip": "^6.0.0", "markdown-it-anchor": "^9.0.1", "nhsuk-frontend": "^8.1.1", "nunjucks": "^3.2.4", @@ -910,6 +911,15 @@ "ieee754": "^1.2.1" } }, + "node_modules/buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", + "dev": true, + "engines": { + "node": "*" + } + }, "node_modules/bytes": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-1.0.0.tgz", @@ -1914,6 +1924,18 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/get-stream": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", + "integrity": "sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==", + "dev": true, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", @@ -2399,6 +2421,61 @@ "node": ">= 0.10" } }, + "node_modules/gulp-zip": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/gulp-zip/-/gulp-zip-6.0.0.tgz", + "integrity": "sha512-fPGvNve2dBoZxGKcviTU7mOa77eQibyhwgGLTxnF+ZCKX8RFaTZKkPbdPnmw0r4TNPRjPCkQB/0VuP+MzgkEYg==", + "dev": true, + "dependencies": { + "get-stream": "^8.0.1", + "gulp-plugin-extras": "^0.3.0", + "vinyl": "^3.0.0", + "yazl": "^2.5.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + }, + "peerDependencies": { + "gulp": ">=4" + }, + "peerDependenciesMeta": { + "gulp": { + "optional": true + } + } + }, + "node_modules/gulp-zip/node_modules/chalk": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", + "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", + "dev": true, + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/gulp-zip/node_modules/gulp-plugin-extras": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/gulp-plugin-extras/-/gulp-plugin-extras-0.3.0.tgz", + "integrity": "sha512-I/kOBSpo61QsGQZcqozZYEnDseKvpudUafVVWDLYgBFAUJ37kW5R8Sjw9cMYzpGyPUfEYOeoY4p+dkfLqgyJUQ==", + "dev": true, + "dependencies": { + "@types/vinyl": "^2.0.9", + "chalk": "^5.3.0", + "easy-transform-stream": "^1.0.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/gulplog": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/gulplog/-/gulplog-2.2.0.tgz", @@ -4970,6 +5047,15 @@ "engines": { "node": ">=10" } + }, + "node_modules/yazl": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/yazl/-/yazl-2.5.1.tgz", + "integrity": "sha512-phENi2PLiHnHb6QBVot+dJnaAZ0xosj7p3fWl+znIjBDlnMI2PsZCJZ306BPTFOaHf5qdDEI8x5qFrSOBN5vrw==", + "dev": true, + "dependencies": { + "buffer-crc32": "~0.2.3" + } } } } diff --git a/package.json b/package.json index 5fe252b..00cda59 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ ], "scripts": { "prepack": "gulp bundle", + "release": "gulp release", "lint": "prettier --check .", "start": "concurrently npm:docs:serve npm:css:watch", "docs:serve": "npm run css:build && npx @11ty/eleventy --serve", @@ -40,6 +41,7 @@ "gulp-rename": "^2.0.0", "gulp-sass": "^5.1.0", "gulp-uglify": "^3.0.2", + "gulp-zip": "^6.0.0", "markdown-it-anchor": "^9.0.1", "nhsuk-frontend": "^8.1.1", "nunjucks": "^3.2.4",