feat: pass Google Analytics ID as Sphinx config parameter (#55) #62
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 library | |
| on: | |
| push: | |
| branches: | |
| - main | |
| # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
| permissions: | |
| contents: write | |
| pages: write | |
| packages: write | |
| id-token: write | |
| jobs: | |
| lint_node: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: volta-cli/action@v5 | |
| - name: Install pnpm via Volta | |
| run: volta install node && volta install pnpm | |
| - name: Lint documentation UI JS package | |
| working-directory: documentation-ui | |
| run: | | |
| pnpm i --frozen-lockfile | |
| pnpm run lint | |
| test_node: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: volta-cli/action@v5 | |
| - name: Install pnpm via Volta | |
| run: volta install node && volta install pnpm | |
| - name: Test documentation UI JS package | |
| working-directory: documentation-ui | |
| run: | | |
| pnpm i --frozen-lockfile | |
| pnpm test -- --run | |
| build_and_release_node: | |
| runs-on: ubuntu-latest | |
| needs: [lint_node, test_node] | |
| outputs: | |
| released: ${{ steps.detect_release.outputs.released }} | |
| version: ${{ steps.detect_release.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - uses: volta-cli/action@v5 | |
| - name: Install pnpm via Volta | |
| run: volta install node && volta install pnpm | |
| - name: Capture latest tag before release | |
| id: before_release | |
| run: | | |
| git fetch --tags --force | |
| latest_tag=$(git for-each-ref --sort=-creatordate --format='%(refname:short)' refs/tags | head -n 1) | |
| echo "latest_tag=$latest_tag" >> "$GITHUB_OUTPUT" | |
| - name: Build documentation UI JS package | |
| working-directory: documentation-ui | |
| run: | | |
| pnpm i --frozen-lockfile | |
| pnpm run build | |
| - name: Release documentation UI JS package | |
| working-directory: documentation-ui | |
| run: | | |
| pnpm exec semantic-release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Detect semantic-release tag | |
| id: detect_release | |
| run: | | |
| git fetch --tags --force | |
| before_tag='${{ steps.before_release.outputs.latest_tag }}' | |
| after_tag=$(git for-each-ref --sort=-creatordate --format='%(refname:short)' refs/tags | head -n 1) | |
| if [ -n "$after_tag" ] && [ "$after_tag" != "$before_tag" ]; then | |
| echo "released=true" >> "$GITHUB_OUTPUT" | |
| echo "version=${after_tag#v}" >> "$GITHUB_OUTPUT" | |
| echo "Detected new release tag: $after_tag" | |
| else | |
| echo "released=false" >> "$GITHUB_OUTPUT" | |
| echo "version=" >> "$GITHUB_OUTPUT" | |
| echo "No new release tag detected." | |
| fi | |
| - name: Build storybook site | |
| working-directory: documentation-ui | |
| run: pnpm run build-storybook | |
| - name: Upload static files as artifact | |
| id: deployment | |
| uses: actions/upload-pages-artifact@v5 | |
| with: | |
| path: documentation-ui/storybook-static/ | |
| deploy-site: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: build_and_release_node | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v5 | |
| release_pypi: | |
| runs-on: ubuntu-latest | |
| needs: build_and_release_node | |
| if: github.ref == 'refs/heads/main' && needs.build_and_release_node.outputs.released == 'true' | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.12" | |
| - name: Install UV | |
| uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 | |
| - uses: volta-cli/action@v5 | |
| - name: Install pnpm via Volta | |
| run: volta install node && volta install pnpm | |
| - name: Build documentation UI JS package | |
| working-directory: documentation-ui | |
| run: | | |
| pnpm i --frozen-lockfile | |
| pnpm run build | |
| - name: Generate UI Assets | |
| working-directory: sphinx-ui/react | |
| run: | | |
| echo "🔨 Generating UI assets..." | |
| pnpm i --frozen-lockfile | |
| pnpm run lint | |
| pnpm run build | |
| cp ./build/injectNav.iife.js ../quantinuum_sphinx/static/injectNav.iife.js | |
| cp ./build/syncTheme.iife.js ../quantinuum_sphinx/static/syncTheme.iife.js | |
| cp ./node_modules/@quantinuum/documentation-ui/dist/tokens.css ../quantinuum_sphinx/static/styles/quantinuum-ui-tokens.css | |
| pnpm exec tailwindcss --postcss ./postcss.config.mjs -i ./index.css -o ../quantinuum_sphinx/static/styles/quantinuum-ui-tailwind.css | |
| echo ✅ "Done. Generated UI assets." | |
| - name: Build PyPI distributions | |
| working-directory: sphinx-ui | |
| env: | |
| PYPI_VERSION: ${{ needs.build_and_release_node.outputs.version }} | |
| SETUPTOOLS_SCM_PRETEND_VERSION: ${{ needs.build_and_release_node.outputs.version }} | |
| SETUPTOOLS_SCM_PRETEND_VERSION_FOR_QUANTINUUM_SPHINX: ${{ needs.build_and_release_node.outputs.version }} | |
| run: | | |
| echo "📦 Building quantinuum_sphinx ${PYPI_VERSION}..." | |
| uv build | |
| ls -l dist | |
| test -f "dist/quantinuum_sphinx-${PYPI_VERSION}.tar.gz" | |
| test -f "dist/quantinuum_sphinx-${PYPI_VERSION}-py3-none-any.whl" | |
| echo ✅ "Done. Built PyPI distributions." | |
| - name: Upload PyPI distributions as artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: quantinuum-sphinx-dist-${{ needs.build_and_release_node.outputs.version }} | |
| path: | | |
| sphinx-ui/dist/*.tar.gz | |
| sphinx-ui/dist/*.whl | |
| if-no-files-found: error | |
| - name: Publish PyPI distributions | |
| working-directory: sphinx-ui | |
| env: | |
| UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }} | |
| run: | | |
| echo "📦 Publishing quantinuum_sphinx distributions to PyPI..." | |
| uv publish | |
| echo ✅ "Done. Published Package to PyPI." |