|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +env: |
| 7 | + HUSKY: 0 |
| 8 | + NX_REJECT_UNKNOWN_LOCAL_CACHE: 0 |
| 9 | + |
| 10 | +jobs: |
| 11 | + dry-run: |
| 12 | + name: Dry Run |
| 13 | + runs-on: ubuntu-latest |
| 14 | + environment: test |
| 15 | + permissions: |
| 16 | + contents: read |
| 17 | + id-token: write |
| 18 | + timeout-minutes: 15 |
| 19 | + steps: |
| 20 | + - name: Checkout repository |
| 21 | + uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + fetch-depth: 0 |
| 24 | + filter: tree:0 |
| 25 | + fetch-tags: true |
| 26 | + |
| 27 | + - uses: ./.github/actions/setup-node |
| 28 | + |
| 29 | + - name: Run tests, linting and building |
| 30 | + run: pnpm nx run-many --target=test --parallel=3 -p="tag:npm:public" |
| 31 | + env: |
| 32 | + VITE_ACCESS_TOKEN: ${{ secrets.VITE_ACCESS_TOKEN }} |
| 33 | + VITE_SPACE_ID: ${{ vars.VITE_SPACE_ID }} |
| 34 | + |
| 35 | + - name: Dry run |
| 36 | + run: pnpm nx release --dry-run --verbose |
| 37 | + |
| 38 | + - name: Print Environment Info |
| 39 | + run: pnpm nx report |
| 40 | + |
| 41 | + # Production release requires human approval |
| 42 | + release: |
| 43 | + name: Release (Production) |
| 44 | + needs: dry-run |
| 45 | + runs-on: ubuntu-latest |
| 46 | + environment: production |
| 47 | + permissions: |
| 48 | + contents: write # Required for creating tags and commits |
| 49 | + id-token: write # Required for npm provenance |
| 50 | + pull-requests: write # Required for GitHub releases |
| 51 | + timeout-minutes: 20 |
| 52 | + steps: |
| 53 | + - name: Checkout repository |
| 54 | + uses: actions/checkout@v4 |
| 55 | + with: |
| 56 | + fetch-depth: 0 |
| 57 | + filter: tree:0 |
| 58 | + fetch-tags: true |
| 59 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + |
| 61 | + - uses: ./.github/actions/setup-node |
| 62 | + |
| 63 | + - name: Configure Git |
| 64 | + run: | |
| 65 | + git config --global user.name "github-actions[bot]" |
| 66 | + git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 67 | +
|
| 68 | + - name: Configure npm authentication |
| 69 | + run: pnpm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }} |
| 70 | + |
| 71 | + - name: Determine branch and npm tag |
| 72 | + id: release-info |
| 73 | + run: | |
| 74 | + BRANCH_NAME=${GITHUB_REF#refs/heads/} |
| 75 | + echo "branch=$BRANCH_NAME" >> $GITHUB_OUTPUT |
| 76 | +
|
| 77 | + case "$BRANCH_NAME" in |
| 78 | + "main") |
| 79 | + echo "npm_tag=latest" >> $GITHUB_OUTPUT |
| 80 | + ;; |
| 81 | + *) |
| 82 | + echo "npm_tag=$BRANCH_NAME" >> $GITHUB_OUTPUT |
| 83 | + ;; |
| 84 | + esac |
| 85 | +
|
| 86 | + - name: Build all packages |
| 87 | + run: pnpm nx run-many --target=build --parallel=3 -p="tag:npm:public" |
| 88 | + |
| 89 | + - name: Version and create release |
| 90 | + run: pnpm nx release --skip-publish --verbose |
| 91 | + |
| 92 | + - name: Publish packages to npm |
| 93 | + run: pnpm nx release publish --excludeTaskDependencies --tag=${{ steps.release-info.outputs.npm_tag }} --verbose |
0 commit comments