ortho 7 banner final update #278
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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@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 | |
# or fall back to 'latest' just in case | |
else | |
echo "npm_tag=alpha" >> $GITHUB_ENV | |
fi | |
- uses: JS-DevTools/npm-publish@v2 | |
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 |