Merge pull request #15 from polkadot-ui/dependabot/npm_and_yarn/types… #9
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
name: Publish | |
on: | |
push: | |
branches: [main] | |
jobs: | |
# Dynamically fetches packages to publish from the `packages` folder. Uses `sed` to format the | |
# list with quotes and commas. Wraps command output in angle brackets, resulting in a JSON | |
# formatted string. | |
get-packages: | |
runs-on: ubuntu-latest | |
outputs: | |
packages: ${{ steps.get_packages.outputs.packages }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: "Get Packages" | |
id: get_packages | |
run: echo packages=[$(ls | sed 's,\(.*\),"\1"\,,')] >> "$GITHUB_OUTPUT" | |
working-directory: "packages" | |
# Uses the above list of packages to check for new versions, and publishes them if they are new. | |
# NOTE: Publishing currently frozen. | |
npm-publish: | |
runs-on: ubuntu-latest | |
needs: get-packages | |
strategy: | |
matrix: | |
package: ${{ fromJson(needs.get-packages.outputs.packages) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- run: yarn install && yarn build:mock | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
registry-url: https://registry.npmjs.org | |
# Check whether a package build is a new version. | |
- name: Check New Version From Build | |
id: check_new_version_build | |
uses: PostHog/check-package-version@v2 | |
with: | |
path: "./packages/${{ matrix.package }}/dist" | |
# Build the package if new version is available. | |
- name: Build Package | |
if: steps.check_new_version_build.outputs.is-new-version == 'true' | |
run: yarn build | |
working-directory: "packages/${{ matrix.package }}" | |
# Publish a package build from `dist` folder. Only runs if the package is a new version. | |
- name: Publish Package From Build | |
if: steps.check_new_version_build.outputs.is-new-version == 'true' | |
run: npm publish | |
working-directory: "packages/${{ matrix.package }}/dist" | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |