|
| 1 | +name: Publish npm Packages |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +# These currently require that the package version has been manually updated |
| 9 | +# We could potentially automate it by creating a separate script that fetches the current version on npm and compares it the the version in the package.json. If it matches, it auto-increments the number in package.json (ie from 2.1.11 to 2.1.12). And we run this script before the publish step. |
| 10 | +# Simpler solution is to use npm version command that can be used to increment the version number (npm version patch, npm version minor, npm version major) where format is major.minor.patch |
| 11 | +# Any version incrementing should probably happen on pushes to dev so that dev and main branch stay in sync. We can simply always increment the patch version |
| 12 | +# Think we can update github settings to ensure you merges fail if an action fails, but that means each merge updates all 3 packages |
| 13 | +jobs: |
| 14 | + publish-react: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Checkout repository |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Set up Node.js |
| 21 | + uses: actions/setup-node@v4 |
| 22 | + with: |
| 23 | + node-version: '20' # Use Node.js version 20 |
| 24 | + |
| 25 | + - name: Install dependencies for package-react |
| 26 | + working-directory: ./package-react |
| 27 | + run: npm install |
| 28 | + |
| 29 | + - name: Build package-react |
| 30 | + working-directory: ./package-react |
| 31 | + run: npm run build # If you have a build step, otherwise remove this step |
| 32 | + |
| 33 | + - name: Publish package-react |
| 34 | + working-directory: ./package-react |
| 35 | + env: |
| 36 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 37 | + run: npm publish |
| 38 | + |
| 39 | + publish-svelte: |
| 40 | + runs-on: ubuntu-latest |
| 41 | + steps: |
| 42 | + - name: Checkout repository |
| 43 | + uses: actions/checkout@v4 |
| 44 | + |
| 45 | + - name: Set up Node.js |
| 46 | + uses: actions/setup-node@v4 |
| 47 | + with: |
| 48 | + node-version: '20' # Use Node.js version 20 |
| 49 | + |
| 50 | + - name: Install dependencies for package-svelte |
| 51 | + working-directory: ./package-svelte |
| 52 | + run: npm install |
| 53 | + |
| 54 | + - name: Build package-svelte |
| 55 | + working-directory: ./package-svelte |
| 56 | + run: npm run build # If you have a build step, otherwise remove this step |
| 57 | + |
| 58 | + - name: Publish package-svelte |
| 59 | + working-directory: ./package-svelte |
| 60 | + env: |
| 61 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 62 | + run: npm publish |
| 63 | + |
| 64 | + publish-vue: |
| 65 | + runs-on: ubuntu-latest |
| 66 | + steps: |
| 67 | + - name: Checkout repository |
| 68 | + uses: actions/checkout@v4 |
| 69 | + |
| 70 | + - name: Set up Node.js |
| 71 | + uses: actions/setup-node@v4 |
| 72 | + with: |
| 73 | + node-version: '20' # Use Node.js version 20 |
| 74 | + |
| 75 | + - name: Install dependencies for package-vue |
| 76 | + working-directory: ./package-vue |
| 77 | + run: npm install |
| 78 | + |
| 79 | + - name: Build package-vue |
| 80 | + working-directory: ./package-vue |
| 81 | + run: npm run build # If you have a build step, otherwise remove this step |
| 82 | + |
| 83 | + - name: Publish package-vue |
| 84 | + working-directory: ./package-vue |
| 85 | + env: |
| 86 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 87 | + run: npm publish |
0 commit comments