Fix client script warning from theme provider #411
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: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: {} | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: false | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| id-token: write | |
| jobs: | |
| release: | |
| if: github.repository_owner == 'cossistantcom' | |
| runs-on: ubuntu-latest | |
| env: | |
| AWS_ROLE_ARN: ${{ vars.AWS_ROLE_ARN }} | |
| CLOUDFRONT_DISTRIBUTION_ID: ${{ vars.CLOUDFRONT_DISTRIBUTION_ID }} | |
| S3_BUCKET_NAME: ${{ vars.S3_BUCKET_NAME }} | |
| S3_CDN_BASE_URL: ${{ vars.S3_CDN_BASE_URL }} | |
| S3_REGION: ${{ vars.S3_REGION }} | |
| WIDGET_CDN_PREFIX: widget | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: 1.3.1 | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Check types | |
| run: bun run check-types | |
| - name: Build example integration app | |
| run: bun run build --filter @cossistant/example-nextjs-tailwind | |
| - name: Create Release PR or Publish | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| version: node .github/changeset-version.js | |
| publish: bun run changeset:publish | |
| title: "chore(release): version packages" | |
| commit: "chore(release): version packages" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} | |
| # Temporarily disabled while we pause widget JS/CDN release automation. | |
| # - name: Resolve published browser package | |
| # if: steps.changesets.outputs.published == 'true' | |
| # id: browser_package | |
| # uses: actions/github-script@v7 | |
| # env: | |
| # PACKAGES: ${{ steps.changesets.outputs.publishedPackages }} | |
| # with: | |
| # script: | | |
| # const packages = JSON.parse(process.env.PACKAGES ?? "[]"); | |
| # const browser = packages.find((pkg) => pkg.name === "@cossistant/browser"); | |
| # core.setOutput("published", browser ? "true" : "false"); | |
| # core.setOutput("version", browser?.version ?? ""); | |
| # | |
| # if (browser) { | |
| # core.info(`Published @cossistant/browser@${browser.version}`); | |
| # } else { | |
| # core.notice("Browser package was not published in this release run."); | |
| # } | |
| # | |
| # - name: Validate widget CDN configuration | |
| # if: steps.browser_package.outputs.published == 'true' | |
| # shell: bash | |
| # run: | | |
| # required_vars=( | |
| # AWS_ROLE_ARN | |
| # CLOUDFRONT_DISTRIBUTION_ID | |
| # S3_BUCKET_NAME | |
| # S3_CDN_BASE_URL | |
| # S3_REGION | |
| # ) | |
| # | |
| # for name in "${required_vars[@]}"; do | |
| # if [ -z "${!name}" ]; then | |
| # echo "::error::Missing required workflow variable: ${name}" | |
| # exit 1 | |
| # fi | |
| # done | |
| # | |
| # - name: Configure AWS credentials | |
| # if: steps.browser_package.outputs.published == 'true' | |
| # uses: aws-actions/configure-aws-credentials@v4 | |
| # with: | |
| # aws-region: ${{ env.S3_REGION }} | |
| # role-to-assume: ${{ env.AWS_ROLE_ARN }} | |
| # | |
| # - name: Build browser CDN assets | |
| # if: steps.browser_package.outputs.published == 'true' | |
| # run: bun run --filter @cossistant/browser build:embed | |
| # | |
| # - name: Upload browser CDN assets | |
| # if: steps.browser_package.outputs.published == 'true' | |
| # shell: bash | |
| # env: | |
| # BROWSER_VERSION: ${{ steps.browser_package.outputs.version }} | |
| # run: | | |
| # version_prefix="s3://${S3_BUCKET_NAME}/${WIDGET_CDN_PREFIX}/${BROWSER_VERSION}" | |
| # latest_prefix="s3://${S3_BUCKET_NAME}/${WIDGET_CDN_PREFIX}/latest" | |
| # | |
| # for file in loader.js widget.js widget.css; do | |
| # local_path="packages/browser/dist/embed/${file}" | |
| # | |
| # if [[ "${file}" == *.css ]]; then | |
| # content_type="text/css; charset=utf-8" | |
| # else | |
| # content_type="text/javascript; charset=utf-8" | |
| # fi | |
| # | |
| # aws s3 cp "${local_path}" "${version_prefix}/${file}" \ | |
| # --cache-control "public, max-age=31536000, immutable" \ | |
| # --content-type "${content_type}" | |
| # | |
| # aws s3 cp "${local_path}" "${latest_prefix}/${file}" \ | |
| # --cache-control "public, max-age=300, must-revalidate" \ | |
| # --content-type "${content_type}" | |
| # done | |
| # | |
| # cdn_base_url="${S3_CDN_BASE_URL%/}" | |
| # { | |
| # echo "## Browser Widget CDN" | |
| # echo "" | |
| # echo "- Versioned loader: ${cdn_base_url}/${WIDGET_CDN_PREFIX}/${BROWSER_VERSION}/loader.js" | |
| # echo "- Latest loader: ${cdn_base_url}/${WIDGET_CDN_PREFIX}/latest/loader.js" | |
| # } >> "${GITHUB_STEP_SUMMARY}" | |
| # | |
| # - name: Invalidate latest widget assets | |
| # if: steps.browser_package.outputs.published == 'true' | |
| # run: | | |
| # aws cloudfront create-invalidation \ | |
| # --distribution-id "${CLOUDFRONT_DISTRIBUTION_ID}" \ | |
| # --paths "/${WIDGET_CDN_PREFIX}/latest/*" | |
| - name: Create GitHub releases | |
| if: steps.changesets.outputs.published == 'true' | |
| uses: actions/github-script@v7 | |
| env: | |
| PACKAGES: ${{ steps.changesets.outputs.publishedPackages }} | |
| with: | |
| script: | | |
| const packages = JSON.parse(process.env.PACKAGES ?? "[]"); | |
| if (!packages.length) { | |
| core.notice("No packages published, skipping release creation."); | |
| return; | |
| } | |
| const { execSync } = require("child_process"); | |
| for (const pkg of packages) { | |
| const tag = `${pkg.name}@${pkg.version}`; | |
| let body = ""; | |
| try { | |
| body = execSync(`node .github/generate-release-notes.js ${tag}`, { | |
| cwd: process.env.GITHUB_WORKSPACE, | |
| stdio: ["ignore", "pipe", "inherit"], | |
| }).toString(); | |
| } catch (error) { | |
| core.warning(`Failed to generate release notes for ${tag}: ${error.message}`); | |
| body = `${tag} published via Changesets.`; | |
| } | |
| try { | |
| await github.rest.repos.createRelease({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| tag_name: tag, | |
| name: `${pkg.name} v${pkg.version}`, | |
| body, | |
| draft: false, | |
| prerelease: false, | |
| }); | |
| core.info(`Created release for ${tag}`); | |
| } catch (error) { | |
| if (error.status === 422) { | |
| core.warning(`Release for ${tag} already exists. Skipping.`); | |
| } else { | |
| throw error; | |
| } | |
| } | |
| } |