Skip to content

v1.0.161

v1.0.161 #202

## Publish packages/sites/** to npm
## This assumed tags will be prefixed with a "v" (e.g., v1.0.0)
name: NPM Publish Sites
on:
release:
types:
- published
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@v3
- 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
strategy:
matrix:
dir: ${{fromJSON(needs.dirs.outputs.matrix)}}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14
cache: 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
# if prerelease is checked, use "prerelease" for the npm tag
elif ${{ github.event.release.prerelease }}; then
echo "npm_tag=prerelease" >> $GITHUB_ENV
# or fall back to 'latest' just in case
else
echo "npm_tag=latest" >> $GITHUB_ENV
fi
- uses: JS-DevTools/npm-publish@v2
if: ${{ startsWith(github.event.release.tag_name, 'v') }}
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
package: packages/sites/${{ matrix.dir }}/package.json
tag: ${{ env.npm_tag }}
- run: ./tools/scripts/test-report
- uses: actions/upload-artifact@v3
with:
name: Test report
path: ${{ github.workspace }}/test-report