Files
fleet/.github/workflows/release-fleetd-chrome.yml
T
Jordan Montgomery 8ae22b5586 Add npm min release age (#45268)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Related to, but does not resolve, #45267

Adds a 12h cooldown period such that when npm is resolving dependencies
it will not resolve anything released less than 12 hours ago. This
doesn't apply globally within the fleet project because some portions
use yarn which #45267 will take care of however this does add it to our
CI jobs and the .npmrc files for projects that use npm

I was going to set this as NPM_CONFIG_MIN_RELEASE_AGE in a github EV but
that won't automatically set it on every runner so leaving it in here
for now

As far as QA local builds and CI are both green. Tested
NPM_CONFIG_MIN_RELEASE_AGE=0.5 and min-release-age=0.5(in npmrc) locally
using the npm package feed https://registry.npmjs.org/-/rss to verify
that recently updated packages either chose an older version OR the
update was blocked if I tried to choose a newer one

# Checklist for submitter

## Testing

- [x] QA'd all new/changed functionality manually


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Chores**
* Enhanced npm supply-chain security by implementing package
installation policies across build workflows and configuration files to
exclude packages released within the last 12 hours.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/fleetdm/fleet/pull/45268)

<!-- review_stack_entry_end -->

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-05-13 10:20:13 -04:00

100 lines
3.4 KiB
YAML

name: Release fleetd-chrome
# Build and upload the following files:
# - fleetd.crx
# - updates.xml
# - meta.json
# - archive/YYYY-MM-DD_HH-MM-SS/fleetd.crx
# - archive/YYYY-MM-DD_HH-MM-SS/updates.xml
# - archive/YYYY-MM-DD_HH-MM-SS/meta.json
on:
push:
tags:
- 'fleetd-chrome-**'
- '!fleetd-chrome-**-beta'
# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id}}
cancel-in-progress: true
defaults:
run:
# fail-fast using bash -eo pipefail. See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
shell: bash
permissions:
contents: read
env:
# Supply-chain guard: refuse npm packages younger than 12 hours. See .npmrc.
NPM_CONFIG_MIN_RELEASE_AGE: 0.5
jobs:
release-fleetd-chrome:
runs-on: ubuntu-latest
permissions:
contents: read
env:
BASE_URL: https://chrome.fleetdm.com
steps:
- name: Harden Runner
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Run test
working-directory: ./ee/fleetd-chrome
run: |
npm install --no-save && npm run test
- name: Set the version
working-directory: ./ee/fleetd-chrome
run: |
echo "FLEETD_CHROME_VERSION=$(npm pkg get version --workspaces=false | tr -d \")" >> $GITHUB_ENV
- name: Build & sign extension
working-directory: ./ee/fleetd-chrome
env:
CHROME_SIGNING_KEY: ${{ secrets.FLEETD_CHROME_SIGNING_KEY }}
run: |
echo -e 'FLEET_URL=""\nFLEET_ENROLL_SECRET=""' > .env
npm run build
sed -i "s/FLEETD_CHROME_VERSION/${{ env.FLEETD_CHROME_VERSION }}/g" updates.xml
echo "$CHROME_SIGNING_KEY" > chrome.pem
/usr/bin/google-chrome --pack-extension=./dist --pack-extension-key=chrome.pem
- name: Prepare files for upload
id: prepare-files
working-directory: ./ee/fleetd-chrome
run: |
mv dist.crx fleetd.crx
datedir=$(date -u +%Y-%m-%d_%H-%M-%S)
mkdir -p archive/$datedir
cp fleetd.crx archive/$datedir
cp updates.xml archive/$datedir
echo "{
\"fleetd_crx_url\": \"${{ env.BASE_URL }}/archive/$datedir/fleetd.crx\",
\"updates_xml\": \"${{ env.BASE_URL }}/archive/$datedir/updates.xml\",
\"version\": \"$datedir\"
}" > meta.json
: # Check that meta.json is valid
jq -e . >/dev/null 2>&1 <<< $(cat meta.json)
cp meta.json archive/$datedir
echo "datedir=$datedir" >> $GITHUB_OUTPUT
- name: Upload extension
uses: ./.github/actions/r2-upload
env:
R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }}
R2_ACCESS_KEY_ID: ${{ secrets.R2_CHROME_ACCESS_KEY_ID }}
R2_ACCESS_KEY_SECRET: ${{ secrets.R2_CHROME_ACCESS_KEY_SECRET }}
R2_BUCKET: chrome
with:
working-directory: ./ee/fleetd-chrome
filenames: fleetd.crx,updates.xml,meta.json,archive/${{ steps.prepare-files.outputs.datedir }}/fleetd.crx,archive/${{ steps.prepare-files.outputs.datedir }}/updates.xml,archive/${{ steps.prepare-files.outputs.datedir }}/meta.json