Skip to content

Commit fdb8708

Browse files
Merge pull request #1430 from nhsuk/release-zip-filename
Set release zip filename using `NPM_PACKAGE_VERSION`
2 parents 04a1139 + 8f310cb commit fdb8708

2 files changed

Lines changed: 15 additions & 16 deletions

File tree

.github/workflows/release.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ jobs:
1010
name: Create release
1111
runs-on: ubuntu-latest
1212

13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
NPM_PACKAGE_VERSION: ${GITHUB_REF_NAME/v/}
16+
1317
steps:
1418
- name: Checkout
1519
uses: actions/checkout@v4
@@ -32,43 +36,35 @@ jobs:
3236
- name: Run tests
3337
run: npm test --ignore-scripts
3438

35-
- name: Get package version
36-
id: get_version
37-
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/}
38-
3939
- name: Create release artifact
4040
run: npm run release --workspace nhsuk-frontend
4141

4242
- name: Create release
4343
id: create_release
4444
uses: actions/create-release@v1
45-
env:
46-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4745
with:
4846
tag_name: ${{ github.ref }}
4947
release_name: ${{ github.ref }}
5048
draft: false
51-
prerelease: ${{ contains(steps.get_version.outputs.VERSION, '-') }}
49+
prerelease: ${{ contains(env.NPM_PACKAGE_VERSION, '-') }}
5250

5351
- name: Upload release asset
5452
id: upload-release-asset
5553
uses: actions/upload-release-asset@v1
56-
env:
57-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5854
with:
5955
upload_url: ${{ steps.create_release.outputs.upload_url }}
60-
asset_path: ./dist/nhsuk-frontend-${{ steps.get_version.outputs.VERSION }}.zip
61-
asset_name: nhsuk-frontend-${{ steps.get_version.outputs.VERSION }}.zip
56+
asset_path: ./dist/nhsuk-frontend-${{ env.NPM_PACKAGE_VERSION }}.zip
57+
asset_name: nhsuk-frontend-${{ env.NPM_PACKAGE_VERSION }}.zip
6258
asset_content_type: application/zip
6359

6460
- name: Publish npm package
65-
if: ${{ !contains(steps.get_version.outputs.VERSION, '-') }}
61+
if: ${{ !contains(env.NPM_PACKAGE_VERSION, '-') }}
6662
run: npm publish --dry-run --workspace nhsuk-frontend --tag latest
6763
env:
6864
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
6965

7066
- name: Publish npm package (pre-release)
71-
if: ${{ contains(steps.get_version.outputs.VERSION, '-') }}
67+
if: ${{ contains(env.NPM_PACKAGE_VERSION, '-') }}
7268
run: npm publish --dry-run --workspace nhsuk-frontend --tag next
7369
env:
7470
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

packages/nhsuk-frontend/tasks/release.mjs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import { files, task } from '@nhsuk/frontend-tasks'
55
import gulp from 'gulp'
66
import gulpZip from 'gulp-zip'
77

8+
// Prefer release version if available
9+
const { NPM_PACKAGE_VERSION = config.version } = process.env
10+
811
export const copy = gulp.parallel(
912
/**
1013
* Copy GitHub release logos, icons and other assets
@@ -23,7 +26,7 @@ export const copy = gulp.parallel(
2326
files.copy('nhsuk/nhsuk-frontend.min.js', {
2427
srcPath: join(config.paths.pkg, 'dist'),
2528
destPath: join(config.paths.root, 'dist'),
26-
output: { file: `nhsuk-frontend-${config.version}.min.js` }
29+
output: { file: `nhsuk-frontend-${NPM_PACKAGE_VERSION}.min.js` }
2730
})
2831
),
2932

@@ -34,7 +37,7 @@ export const copy = gulp.parallel(
3437
files.copy('nhsuk/nhsuk-frontend.min.css', {
3538
srcPath: join(config.paths.pkg, 'dist'),
3639
destPath: join(config.paths.root, 'dist'),
37-
output: { file: `nhsuk-frontend-${config.version}.min.css` }
40+
output: { file: `nhsuk-frontend-${NPM_PACKAGE_VERSION}.min.css` }
3841
})
3942
)
4043
)
@@ -56,7 +59,7 @@ export const zip = gulp.series(
5659
encoding: false
5760
}
5861
)
59-
.pipe(gulpZip(`nhsuk-frontend-${config.version}.zip`))
62+
.pipe(gulpZip(`nhsuk-frontend-${NPM_PACKAGE_VERSION}.zip`))
6063
.pipe(gulp.dest(join(config.paths.root, 'dist')))
6164
)
6265
)

0 commit comments

Comments
 (0)