Use NPM trusted publishing (#2174)

Co-authored-by: GCHQDeveloper581 <63102987+GCHQDeveloper581@users.noreply.github.com> (minor tweaks only)
This commit is contained in:
GCHQ Developer 85297
2026-02-04 14:20:22 +00:00
committed by GitHub
parent fa34e2fafc
commit 693b7d86dd
5 changed files with 159 additions and 152 deletions

View File

@@ -12,3 +12,7 @@ indent_size = 4
[{package.json,.travis.yml,nightwatch.json}] [{package.json,.travis.yml,nightwatch.json}]
indent_style = space indent_style = space
indent_size = 2 indent_size = 2
[.github/**.yml]
indent_style = space
indent_size = 2

View File

@@ -3,13 +3,13 @@ name: "CodeQL Analysis"
on: on:
workflow_dispatch: workflow_dispatch:
push: push:
branches: [ master ] branches: [master]
pull_request: pull_request:
# The branches below must be a subset of the branches above # The branches below must be a subset of the branches above
branches: [ master ] branches: [master]
types: [synchronize, opened, reopened] types: [synchronize, opened, reopened]
schedule: schedule:
- cron: '22 17 * * 5' - cron: "22 17 * * 5"
jobs: jobs:
analyze: analyze:
@@ -23,18 +23,18 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
language: [ 'javascript' ] language: ["javascript"]
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v6
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v2 uses: github/codeql-action/init@v2
with: with:
languages: ${{ matrix.language }} languages: ${{ matrix.language }}
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2 uses: github/codeql-action/analyze@v2
with: with:
category: "/language:${{matrix.language}}" category: "/language:${{matrix.language}}"

View File

@@ -4,55 +4,56 @@ on:
workflow_dispatch: workflow_dispatch:
push: push:
branches: branches:
- master - master
jobs: jobs:
main: main:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v6
- name: Set node version - name: Set node version
uses: actions/setup-node@v3 uses: actions/setup-node@v6
with: with:
node-version: '18.x' node-version: 18
registry-url: "https://registry.npmjs.org"
- name: Install - name: Install
run: | run: |
export DETECT_CHROMEDRIVER_VERSION=true export DETECT_CHROMEDRIVER_VERSION=true
npm install npm install
npm run setheapsize npm run setheapsize
- name: Lint - name: Lint
run: npx grunt lint run: npx grunt lint
- name: Unit Tests - name: Unit Tests
run: | run: |
npm test npm test
npm run testnodeconsumer npm run testnodeconsumer
- name: Production Build - name: Production Build
if: success() if: success()
run: npx grunt prod --msg="" run: npx grunt prod --msg=""
- name: Generate sitemap - name: Generate sitemap
run: npx grunt exec:sitemap run: npx grunt exec:sitemap
- name: UI Tests - name: UI Tests
if: success() if: success()
run: | run: |
sudo apt-get install xvfb sudo apt-get install xvfb
xvfb-run --server-args="-screen 0 1200x800x24" npx grunt testui xvfb-run --server-args="-screen 0 1200x800x24" npx grunt testui
- name: Prepare for GitHub Pages - name: Prepare for GitHub Pages
if: success() if: success()
run: npx grunt copy:ghPages run: npx grunt copy:ghPages
- name: Deploy to GitHub Pages - name: Deploy to GitHub Pages
if: success() && github.ref == 'refs/heads/master' if: success() && github.ref == 'refs/heads/master'
uses: crazy-max/ghaction-github-pages@v3 uses: crazy-max/ghaction-github-pages@v3
with: with:
target_branch: gh-pages target_branch: gh-pages
build_dir: ./build/prod build_dir: ./build/prod
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -9,47 +9,46 @@ jobs:
main: main:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v6
- name: Set node version - name: Set node version
uses: actions/setup-node@v3 uses: actions/setup-node@v6
with: with:
node-version: '18.x' node-version: 18
registry-url: "https://registry.npmjs.org"
- name: Install - name: Install
run: | run: |
export DETECT_CHROMEDRIVER_VERSION=true export DETECT_CHROMEDRIVER_VERSION=true
npm install npm install
npm run setheapsize npm run setheapsize
- name: Lint - name: Lint
run: npx grunt lint run: npx grunt lint
- name: Unit Tests - name: Unit Tests
run: | run: |
npm test npm test
npm run testnodeconsumer npm run testnodeconsumer
- name: Production Build - name: Production Build
if: success() if: success()
run: npx grunt prod run: npx grunt prod
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
- name: Production Image Build - name: Production Image Build
if: success() if: success()
id: build-image id: build-image
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
# Not being uploaded to any registry, use a simple name to allow Buildah to build correctly. platforms: linux/amd64,linux/arm64
image: cyberchef - name: UI Tests
platforms: linux/amd64,linux/arm64 if: success()
- name: UI Tests run: |
if: success() sudo apt-get install xvfb
run: | xvfb-run --server-args="-screen 0 1200x800x24" npx grunt testui
sudo apt-get install xvfb
xvfb-run --server-args="-screen 0 1200x800x24" npx grunt testui

View File

@@ -4,7 +4,11 @@ on:
workflow_dispatch: workflow_dispatch:
push: push:
tags: tags:
- 'v*' - "v*"
permissions:
id-token: write
contents: read
env: env:
REGISTRY: ghcr.io REGISTRY: ghcr.io
@@ -16,79 +20,78 @@ jobs:
main: main:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v6
- name: Set node version - name: Set node version
uses: actions/setup-node@v3 uses: actions/setup-node@v6
with: with:
node-version: '18.x' node-version: 18
registry-url: "https://registry.npmjs.org"
- name: Install - name: Install
run: | run: |
export DETECT_CHROMEDRIVER_VERSION=true export DETECT_CHROMEDRIVER_VERSION=true
npm ci npm ci
npm run setheapsize npm run setheapsize
- name: Lint - name: Lint
run: npx grunt lint run: npx grunt lint
- name: Unit Tests - name: Unit Tests
run: | run: |
npm test npm test
npm run testnodeconsumer npm run testnodeconsumer
- name: Production Build - name: Production Build
run: npx grunt prod run: npx grunt prod
- name: UI Tests - name: UI Tests
run: | run: |
sudo apt-get install xvfb sudo apt-get install xvfb
xvfb-run --server-args="-screen 0 1200x800x24" npx grunt testui xvfb-run --server-args="-screen 0 1200x800x24" npx grunt testui
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
- name: Image Metadata - name: Image Metadata
id: image-metadata id: image-metadata
uses: docker/metadata-action@v4 uses: docker/metadata-action@v4
with: with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: | tags: |
type=semver,pattern={{major}} type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{version}} type=semver,pattern={{version}}
- name: Log in to GHCR - name: Log in to GHCR
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: ${{ env.REGISTRY }} registry: ${{ env.REGISTRY }}
username: ${{ env.REGISTRY_USER }} username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }} password: ${{ env.REGISTRY_PASSWORD }}
- name: Publish to GHCR - name: Publish to GHCR
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: . context: .
push: true push: true
tags: ${{ steps.image-metadata.outputs.tags }} tags: ${{ steps.image-metadata.outputs.tags }}
labels: ${{ steps.image-metadata.outputs.labels }} labels: ${{ steps.image-metadata.outputs.labels }}
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
- name: Upload Release Assets - name: Upload Release Assets
id: upload-release-assets id: upload-release-assets
uses: svenstaro/upload-release-action@v2 uses: svenstaro/upload-release-action@v2
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/prod/*.zip file: build/prod/*.zip
tag: ${{ github.ref }} tag: ${{ github.ref }}
overwrite: true overwrite: true
file_glob: true file_glob: true
body: "See the [CHANGELOG](https://github.com/gchq/CyberChef/blob/master/CHANGELOG.md) and [commit messages](https://github.com/gchq/CyberChef/commits/master) for details." body: "See the [CHANGELOG](https://github.com/gchq/CyberChef/blob/master/CHANGELOG.md) and [commit messages](https://github.com/gchq/CyberChef/commits/master) for details."
- name: Publish to NPM - name: Publish to NPM
uses: JS-DevTools/npm-publish@v1 run: npm publish
with:
token: ${{ secrets.NPM_TOKEN }}