|
| 1 | +name: 🏷️ Publish NPM Latest |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + dryrun: |
| 7 | + type: boolean |
| 8 | + description: Dry-Run |
| 9 | + graduate: |
| 10 | + type: boolean |
| 11 | + description: Force Conventional Graduate |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: write |
| 15 | + id-token: write |
| 16 | + |
| 17 | +jobs: |
| 18 | + deploy-npm-latest: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + timeout-minutes: 30 |
| 21 | + steps: |
| 22 | + - name: Retrieve current Date Time in EST |
| 23 | + shell: bash |
| 24 | + run: echo "START_TIME=$(TZ=":America/New_York" date -R|sed 's/.....$//')" >> $GITHUB_ENV |
| 25 | + |
| 26 | + - name: Current datetime - ${{ env.START_TIME }} |
| 27 | + run: echo ${{ env.START_TIME }} |
| 28 | + |
| 29 | + - name: Clone repository |
| 30 | + uses: actions/checkout@v4 |
| 31 | + with: |
| 32 | + fetch-depth: 0 |
| 33 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 34 | + |
| 35 | + - if: ${{ github.event.pull_request.merged != true && contains('["ghiscoding"]', github.actor) != true }} |
| 36 | + name: Exit early when current actor is not allowed to push new release |
| 37 | + run: | |
| 38 | + echo "Error: Your GitHub username (${{ github.actor }}) is not on the allowed list of admins for this workflow" |
| 39 | + exit 1 |
| 40 | +
|
| 41 | + - name: Set NodeJS |
| 42 | + uses: actions/setup-node@v4 |
| 43 | + with: |
| 44 | + registry-url: 'https://registry.npmjs.org/' |
| 45 | + node-version: 22 |
| 46 | + |
| 47 | + - name: Install pnpm |
| 48 | + uses: pnpm/action-setup@v3 |
| 49 | + with: |
| 50 | + version: 10 |
| 51 | + run_install: false |
| 52 | + |
| 53 | + - name: Get pnpm store directory |
| 54 | + run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV |
| 55 | + |
| 56 | + - name: Setup pnpm cache |
| 57 | + uses: actions/cache@v4 |
| 58 | + with: |
| 59 | + path: ${{ env.STORE_PATH }} |
| 60 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 61 | + restore-keys: | |
| 62 | + ${{ runner.os }}-pnpm-store- |
| 63 | +
|
| 64 | + - name: Run pnpm install dependencies |
| 65 | + run: pnpm install |
| 66 | + |
| 67 | + - name: OTP |
| 68 | + if: ${{ inputs.dryrun != true }} |
| 69 | + uses: step-security/wait-for-secrets@v1 |
| 70 | + id: wait-for-secrets |
| 71 | + with: |
| 72 | + secrets: | |
| 73 | + OTP: |
| 74 | + name: 'OTP to publish package' |
| 75 | + description: 'OTP from authenticator app' |
| 76 | +
|
| 77 | + - name: Lerna Publish 📦 |
| 78 | + if: ${{ inputs.dryrun != true }} |
| 79 | + env: |
| 80 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 81 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 82 | + NPM_CONFIG_PROVENANCE: true |
| 83 | + HUSKY: 0 |
| 84 | + run: | |
| 85 | + pnpm exec lerna publish from-package --force-publish --yes --otp ${{ steps.wait-for-secrets.outputs.OTP }} |
| 86 | +
|
| 87 | + - name: Website Dev Build |
| 88 | + run: pnpm build:dev |
| 89 | + |
| 90 | + - name: Deploy to gh-pages |
| 91 | + if: github.ref == 'refs/heads/master' |
| 92 | + uses: peaceiris/actions-gh-pages@v4 |
| 93 | + with: |
| 94 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 95 | + publish_dir: ./website |
0 commit comments