Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create release action build #214

Merged
merged 4 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
21 changes: 20 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand Down Expand Up @@ -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
*/
Expand All @@ -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 }
86 changes: 86 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Loading