Build and publish each JS package separately in CI
This commit is contained in:
parent
83082ca265
commit
a9c357fa8b
1 changed files with 37 additions and 7 deletions
44
.github/workflows/typescript.yml
vendored
44
.github/workflows/typescript.yml
vendored
|
|
@ -9,9 +9,26 @@ on:
|
||||||
types: [published]
|
types: [published]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
detect-packages:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
packages: ${{ steps.find-packages.outputs.packages }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Find JS packages
|
||||||
|
id: find-packages
|
||||||
|
working-directory: src
|
||||||
|
run: |
|
||||||
|
PACKAGES=$(find . -name package.json -not -path "*/node_modules/*" -exec dirname {} \; | sed 's/^\.\///' | jq -R -s -c 'split("\n")[:-1]')
|
||||||
|
echo "packages=$PACKAGES" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
build:
|
||||||
|
needs: [detect-packages]
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
package: ${{ fromJson(needs.detect-packages.outputs.packages) }}
|
||||||
|
name: Build ${{ matrix.package }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
|
@ -20,14 +37,24 @@ jobs:
|
||||||
node-version: 18
|
node-version: 18
|
||||||
cache: npm
|
cache: npm
|
||||||
|
|
||||||
- run: npm ci
|
- name: Install dependencies
|
||||||
- run: npm run build
|
working-directory: src/${{ matrix.package }}
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Build package
|
||||||
|
working-directory: src/${{ matrix.package }}
|
||||||
|
run: npm run build
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs: [build, detect-packages]
|
||||||
if: github.event_name == 'release'
|
if: github.event_name == 'release'
|
||||||
environment: release
|
environment: release
|
||||||
needs: build
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
package: ${{ fromJson(needs.detect-packages.outputs.packages) }}
|
||||||
|
name: Publish ${{ matrix.package }}
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
@ -41,9 +68,12 @@ jobs:
|
||||||
cache: npm
|
cache: npm
|
||||||
registry-url: "https://registry.npmjs.org"
|
registry-url: "https://registry.npmjs.org"
|
||||||
|
|
||||||
- run: npm ci
|
- name: Install dependencies
|
||||||
|
working-directory: src/${{ matrix.package }}
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
# TODO: Add --provenance once the repo is public
|
- name: Publish package
|
||||||
- run: npm run publish-all
|
working-directory: src/${{ matrix.package }}
|
||||||
|
run: npm publish --provenance
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue