chore(testing): set up vitest in parallel to jest and migrate pos-lab… #848
Workflow file for this run
This file contains hidden or 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: CI/CD | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [lts/*] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - run: npm ci | |
| - run: npm run lint --workspace=core --workspace elements --if-present | |
| - run: npm run typecheck --workspace=core | |
| - run: npm run build --workspace=core | |
| - run: npm run build --workspace=elements | |
| - run: npm test --workspace=core --workspace elements | |
| - name: Save @pod-os/core build | |
| if: github.ref == 'refs/heads/main' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: core-build | |
| path: | | |
| core/dist/ | |
| core/lib/ | |
| core/types/ | |
| core/package.json | |
| retention-days: 1 | |
| - name: Save @pod-os/elements build | |
| if: github.ref == 'refs/heads/main' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: elements-build | |
| path: | | |
| elements/dist/ | |
| elements/loader/ | |
| elements/package.json | |
| retention-days: 1 | |
| npm-publish-core-snapshot: | |
| if: github.ref == 'refs/heads/main' | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| outputs: | |
| prereleaseVersion: ${{ steps.prerelease.outputs.version }} | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: core-build | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: lts/* | |
| registry-url: "https://registry.npmjs.org" | |
| - uses: rlespinasse/github-slug-action@v4.4.1 | |
| - name: prerelease version | |
| run: | | |
| echo "version=$(npm version prerelease --preid rc.${GITHUB_SHA_SHORT} --no-git-tag-version)" >> $GITHUB_OUTPUT | |
| id: prerelease | |
| - run: echo prerelease version is ${{ steps.prerelease.outputs.version }} | |
| - name: Publish @pod-os/core | |
| uses: JS-DevTools/npm-publish@v4 | |
| with: | |
| access: public | |
| provenance: true | |
| tag: ${{ env.GITHUB_REF_SLUG }} | |
| npm-publish-elements-snapshot: | |
| if: github.ref == 'refs/heads/main' | |
| needs: [build, npm-publish-core-snapshot] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| outputs: | |
| prereleaseVersion: ${{ steps.prerelease.outputs.version }} | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: elements-build | |
| - name: Update core dependency to snapshot version | |
| run: | | |
| CORE_SNAPSHOT="${{ needs.npm-publish-core-snapshot.outputs.prereleaseVersion }}" | |
| sed -i "s/\"@pod-os\/core\": \"[^\"]*\"/\"@pod-os\/core\": \"${CORE_SNAPSHOT}\"/" package.json | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: lts/* | |
| registry-url: "https://registry.npmjs.org" | |
| - uses: rlespinasse/github-slug-action@v4.4.1 | |
| - name: prerelease version | |
| run: | | |
| echo "version=$(npm version prerelease --preid rc.${GITHUB_SHA_SHORT} --no-git-tag-version)" >> $GITHUB_OUTPUT | |
| id: prerelease | |
| - run: echo prerelease version is ${{ steps.prerelease.outputs.version }} | |
| - name: Publish @pod-os/elements | |
| uses: JS-DevTools/npm-publish@v4 | |
| with: | |
| access: public | |
| provenance: true | |
| tag: ${{ env.GITHUB_REF_SLUG }} | |
| deploy-preview-pod-os-browser: | |
| needs: npm-publish-elements-snapshot | |
| if: needs.npm-publish-elements-snapshot.outputs.releaseType != 'none' | |
| runs-on: ubuntu-22.04 | |
| environment: | |
| name: preview | |
| url: ${{ steps.deploy.outputs.deploy_url }} | |
| env: | |
| POD_OS_ELEMENTS_VERSION: | |
| ${{ needs.npm-publish-elements-snapshot.outputs.prereleaseVersion }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Deploy to Netlify (Preview) | |
| id: deploy | |
| uses: ./.github/actions/deploy-pod-os-app | |
| with: | |
| app-name: pos-app-browser | |
| netlify-site-id: ${{ secrets.NETLIFY_POD_OS_BROWSER_SITE_ID }} | |
| netlify-auth-token: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
| approve-release: | |
| if: github.ref == 'refs/heads/main' | |
| needs: npm-publish-elements-snapshot | |
| runs-on: ubuntu-latest | |
| continue-on-error: true | |
| environment: release-approval | |
| outputs: | |
| approved: ${{ steps.approval.outputs.approved }} | |
| steps: | |
| - name: Approve release | |
| id: approval | |
| run: | | |
| echo "approved=true" >> $GITHUB_OUTPUT | |
| echo "Release approved, proceeding" | |
| build-pages: | |
| if: github.ref == 'refs/heads/main' | |
| needs: | |
| - npm-publish-elements-snapshot | |
| - npm-publish-core-snapshot | |
| runs-on: ubuntu-latest | |
| steps: | |
| - run: | |
| echo elements version is ${{ | |
| needs.npm-publish-elements-snapshot.outputs.prereleaseVersion }} | |
| - run: | |
| echo core version is ${{ | |
| needs.npm-publish-core-snapshot.outputs.prereleaseVersion }} | |
| - uses: actions/checkout@v4 | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Use Node.js 20 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install storybook | |
| working-directory: ./storybook | |
| run: npm ci | |
| - name: Build storybook | |
| working-directory: ./storybook | |
| env: | |
| STORYBOOK_POD_OS_ELEMENTS_DIST_URL: | |
| https://cdn.jsdelivr.net/npm/@pod-os/elements@${{ | |
| needs.npm-publish-elements-snapshot.outputs.prereleaseVersion | |
| }}/dist/elements | |
| run: npm run build | |
| - name: Upload pages | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: "gh-pages" | |
| deploy-pages: | |
| if: github.ref == 'refs/heads/main' | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: build-pages | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| npm-release-core: | |
| if: | |
| github.ref == 'refs/heads/main' && needs.approve-release.outputs.approved == 'true' | |
| needs: [build, npm-publish-core-snapshot, approve-release] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| outputs: | |
| releaseVersion: ${{ steps.release.outputs.version }} | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: core-build | |
| - name: Prepare release version | |
| run: sed -i 's/-next\.0//' package.json | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: lts/* | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Release @pod-os/core | |
| id: release | |
| uses: JS-DevTools/npm-publish@v4 | |
| with: | |
| access: public | |
| provenance: true | |
| tag: latest | |
| npm-release-elements: | |
| needs: [build, npm-publish-elements-snapshot, npm-release-core] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| outputs: | |
| releaseVersion: ${{ steps.release.outputs.version }} | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: elements-build | |
| - name: Update core dependency to release version | |
| run: | | |
| CORE_VERSION="${{ needs.npm-release-core.outputs.releaseVersion }}" | |
| sed -i "s/\"@pod-os\/core\": \"[^\"]*\"/\"@pod-os\/core\": \"^${CORE_VERSION}\"/" package.json | |
| - name: Prepare release version | |
| run: sed -i 's/-next\.0//' package.json | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: lts/* | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Release @pod-os/elements | |
| id: release | |
| uses: JS-DevTools/npm-publish@v4 | |
| with: | |
| access: public | |
| provenance: true | |
| tag: latest | |
| deploy-prod-pod-os-browser: | |
| needs: npm-release-elements | |
| if: github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-22.04 | |
| environment: | |
| name: production | |
| url: ${{ steps.deploy.outputs.deploy_url }} | |
| env: | |
| POD_OS_ELEMENTS_VERSION: | |
| ${{ needs.npm-release-elements.outputs.releaseVersion }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Deploy to Netlify (Production) | |
| id: deploy | |
| uses: ./.github/actions/deploy-pod-os-app | |
| with: | |
| app-name: pos-app-browser | |
| netlify-flags: "--prod" | |
| netlify-site-id: ${{ secrets.NETLIFY_POD_OS_BROWSER_SITE_ID }} | |
| netlify-auth-token: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
| bump-snapshot-versions: | |
| if: github.ref == 'refs/heads/main' | |
| needs: [npm-release-core, npm-release-elements] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Bump core to next development version | |
| id: bump-core | |
| uses: ./.github/actions/bump-version | |
| with: | |
| release-version: ${{ needs.npm-release-core.outputs.releaseVersion }} | |
| working-directory: ./core | |
| - name: Bump elements to next development version | |
| id: bump-elements | |
| uses: ./.github/actions/bump-version | |
| with: | |
| release-version: | |
| ${{ needs.npm-release-elements.outputs.releaseVersion }} | |
| working-directory: ./elements | |
| - name: Update elements core dependency | |
| working-directory: ./elements | |
| run: | | |
| sed -i "s/\"@pod-os\/core\": \"[^\"]*\"/\"@pod-os\/core\": \"${{ steps.bump-core.outputs.next-version }}\"/" package.json | |
| - name: Update package-lock.json | |
| run: npm install --package-lock-only | |
| - name: Commit and push version bumps | |
| run: | | |
| git add core/package.json elements/package.json package-lock.json | |
| git commit -m "chore: bump to next development versions [skip ci]" | |
| git push |