Skip to content

updates

updates #388

## Publish packages/sites/** to npm
## This assumed tags will be prefixed with a "v" (e.g., v1.0.0)
name: NPM Publish Sites
on:
push:
tags:
- v*
jobs:
# Gather the names of the sites directories and store it as an output variable
dirs:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- id: set-matrix
run: echo "matrix=$(ls packages/sites | jq -Rsc '. / "\n" - [""]')" >> $GITHUB_OUTPUT
# Build and publish sites packages to npm
# Skip publishing, if release tag does not begin with "v"
publish:
name: Build and publish ${{ matrix.dir }}
needs:
- dirs
runs-on: ubuntu-latest
env:
YARN_NPM_MINIMAL_AGE_GATE: 10080
permissions:
contents: read
id-token: write # required to use OIDC
strategy:
matrix:
dir: ${{fromJSON(needs.dirs.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '24.11.0'
- run: corepack enable
- name: Remove yarnPath to use corepack's Yarn 4.12.0
run: sed -i '/^yarnPath:/d' .yarnrc.yml
- uses: actions/cache@v4
with:
path: |
.yarn/cache
.yarn/install-state.gz
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn
- run: yarn nx bundle:npm @veupathdb/${{matrix.dir}}
env:
NODE_OPTIONS: '--max-old-space-size=4096'
- run: node tools/scripts/version.mjs packages/sites/${{ matrix.dir }} ${GITHUB_REF_NAME#v}
# figure out how to tag the release on npm - sets env.npm_tag
- run: |
# Extract the part of the git tag after the 'v' prefix
git_tag="${GITHUB_REF_NAME#v}"
# Check if the tag is a plain version (e.g., 1.2.3) and tag 'latest' on npm
if [[ "$git_tag" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "npm_tag=latest" >> $GITHUB_ENV
# else look for a word-like suffix (ignoring optional trailing .1, .2 etc) and tag with that word
# e.g. v.1.2.3-experimental will be tagged 'experimental' on npm
elif [[ "$git_tag" =~ ^[0-9]+\.[0-9]+\.[0-9]+-([a-zA-Z0-9]+)(\.[0-9]+)*$ ]]; then
npm_tag="${BASH_REMATCH[1]}"
echo "npm_tag=$npm_tag" >> $GITHUB_ENV
# or fall back to 'latest' just in case
else
echo "npm_tag=alpha" >> $GITHUB_ENV
fi
- uses: JS-DevTools/npm-publish@v4
with:
# use verified publisher; token: ${{ secrets.NPM_TOKEN }}
access: public
package: packages/sites/${{ matrix.dir }}/package.json
tag: ${{ env.npm_tag }}
tests:
name: Generate test reports
runs-on: ubuntu-latest
env:
YARN_NPM_MINIMAL_AGE_GATE: 10080
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '24.11.0'
- run: corepack enable
- name: Remove yarnPath to use corepack's Yarn 4.12.0
run: sed -i '/^yarnPath:/d' .yarnrc.yml
- uses: actions/cache@v4
with:
path: |
.yarn/cache
.yarn/install-state.gz
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn
- run: ./tools/scripts/test-report
- uses: actions/upload-artifact@v4
with:
name: Test report
path: ${{ github.workspace }}/test-report