|
| 1 | +name: Release to npm |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + types: |
| 8 | + - closed |
| 9 | + |
| 10 | +jobs: |
| 11 | + publish-to-npm: |
| 12 | + name: Publish to npm Registry |
| 13 | + runs-on: ubuntu-latest |
| 14 | + if: github.head_ref == 'changeset-release/main' |
| 15 | + steps: |
| 16 | + - name: Check out code |
| 17 | + uses: actions/checkout@v3 |
| 18 | + - uses: pnpm/action-setup@v4.0.0 |
| 19 | + with: |
| 20 | + version: 6.32.2 |
| 21 | + - name: Setup Node.js environment |
| 22 | + uses: actions/setup-node@v3 |
| 23 | + with: |
| 24 | + node-version-file: ".nvmrc" |
| 25 | + cache: "pnpm" |
| 26 | + |
| 27 | + - name: Install dependencies |
| 28 | + run: pnpm install |
| 29 | + |
| 30 | + - name: Build packages |
| 31 | + run: pnpm run build --filter=./packages |
| 32 | + |
| 33 | + # Delete existing .npmrc file if it exists |
| 34 | + - name: Delete existing .npmrc |
| 35 | + run: | |
| 36 | + if [ -f .npmrc ]; then |
| 37 | + echo "Deleting existing .npmrc file" |
| 38 | + rm .npmrc |
| 39 | + fi |
| 40 | +
|
| 41 | + - name: Create .npmrc for npm Registry |
| 42 | + run: | |
| 43 | + echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc |
| 44 | + echo "registry=https://registry.npmjs.org/" >> ~/.npmrc |
| 45 | +
|
| 46 | + - name: Publish Framework Package |
| 47 | + run: | |
| 48 | + current_version=$(jq -r '.version' packages/framework/package.json) |
| 49 | + latest_version=$(npm show @ensembleui/react-framework version || echo "none") |
| 50 | +
|
| 51 | + if [ "$current_version" != "$latest_version" ]; then |
| 52 | + echo "Publishing @ensembleui/react-framework version $current_version" |
| 53 | + pnpm publish --filter ./packages/framework --no-git-checks |
| 54 | + else |
| 55 | + echo "No version change detected for @ensembleui/react-framework. Skipping publish." |
| 56 | + fi |
| 57 | +
|
| 58 | + - name: Publish Runtime Package |
| 59 | + run: | |
| 60 | + current_version=$(jq -r '.version' packages/runtime/package.json) |
| 61 | + latest_version=$(npm show @ensembleui/react-runtime version || echo "none") |
| 62 | +
|
| 63 | + if [ "$current_version" != "$latest_version" ]; then |
| 64 | + echo "Publishing @ensembleui/react-runtime version $current_version" |
| 65 | + pnpm publish --filter ./packages/runtime --no-git-checks |
| 66 | + else |
| 67 | + echo "No version change detected for @ensembleui/react-runtime. Skipping publish." |
| 68 | + fi |
0 commit comments