improvement: remove base-url from index.html, instead infer it (#2975) #1348
This file contains 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: Publish dev release of marimo-base | |
# Publish development release to test pypi on pushes to main | |
on: | |
push: | |
branches: | |
- main | |
env: | |
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | |
TURBO_TEAM: marimo | |
jobs: | |
publish_dev_release: | |
name: 📤 Publish dev release | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- name: 🛑 Cancel Previous Runs | |
uses: styfle/[email protected] | |
- name: ⬇️ Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
# get tag history for version number | |
fetch-depth: 0 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 9 | |
- name: ⎔ Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'pnpm' | |
cache-dependency-path: '**/pnpm-lock.yaml' | |
registry-url: 'https://registry.npmjs.org' | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: 📦 Build frontend | |
run: make fe | |
- name: 🥚 Install Hatch | |
uses: pypa/hatch@install | |
- name: Adapt pyproject.toml to build marimo-base | |
run: ./scripts/modify_pyproject_for_marimo_base.sh | |
# patch __init__.py version to be of the form | |
# X.Y.<Z+1>-dev{n-commits-since-last-tag} | |
- name: 🔨 Patch version number | |
run: | | |
# Get the version number and increment patch | |
# - assumes version is on a line of the form __version__ == "x.y.z" | |
incremented_version=`grep '__version__' marimo/__init__.py | awk '{print $3}' | awk -F. '{printf "%d.%d.%d", $1, $2, $3+1}'` | |
# Get the number of commits since last tag | |
n_commits=`git rev-list $(git describe --tags --abbrev=0)..HEAD --count` | |
# Form the new version, which is one patch ahead of the last version | |
# so installing from Test PyPI does the right thing | |
MARIMO_VERSION="${incremented_version}-dev${n_commits}" | |
# Set the version in the environment for later steps | |
echo "MARIMO_VERSION=$MARIMO_VERSION" >> $GITHUB_ENV | |
sed -i "s/__version__ = \".*\"/__version__ = \"$MARIMO_VERSION\"/" marimo/__init__.py | |
- name: 📦 Build marimo | |
run: hatch build --clean | |
- name: 📦 Validate wheel under 2mb | |
run: ./scripts/validate_base_wheel_size.sh | |
- name: 📤 Upload to TestPyPI | |
env: | |
HATCH_INDEX_USER: ${{ secrets.TEST_PYPI_USER }} | |
HATCH_INDEX_AUTH: ${{ secrets.TEST_PYPI_MARIMO_BASE_PASSWORD }} | |
run: hatch publish --repo test | |
- name: 📦 Update package.json version from CLI | |
working-directory: frontend | |
run: | | |
echo "Updating package.json version to ${{ env.MARIMO_VERSION }}" | |
npm version ${{ env.MARIMO_VERSION }} --no-git-tag-version | |
- name: 📤 Upload wasm to npm | |
working-directory: frontend | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: | | |
for i in {1..3}; do | |
npm publish --access public && break || { | |
echo "Publish attempt $i failed, retrying..." | |
sleep 10 | |
} | |
done | |
- name: 📦 Update package.json name to @marimo-team/islands | |
working-directory: frontend | |
run: | | |
sed -i 's/"name": "@marimo-team\/frontend"/"name": "@marimo-team\/islands"/' package.json | |
- name: 📦 Rebuild frontend | |
working-directory: frontend | |
env: | |
NODE_ENV: production | |
VITE_MARIMO_ISLANDS: 'true' | |
VITE_MARIMO_VERSION: ${{ env.MARIMO_VERSION }} | |
run: | | |
pnpm turbo build:islands | |
./islands/validate.sh | |
- name: 📤 Upload islands to npm | |
working-directory: frontend | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: | | |
for i in {1..3}; do | |
npm publish --access public && break || { | |
echo "Publish attempt $i failed, retrying..." | |
sleep 10 | |
} | |
done | |
- name: 📝 Comment PR | |
uses: actions/github-script@v7 | |
continue-on-error: true | |
with: | |
script: | | |
try { | |
const pullRequest = await github.rest.search.issuesAndPullRequests({ | |
q: `sha:${context.sha} is:pr is:merged` | |
}); | |
if (pullRequest.data.items.length > 0) { | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: pullRequest.data.items[0].number, | |
body: `🚀 Development release published. You may be able to view the changes at https://marimo.app?v=${process.env.MARIMO_VERSION}` | |
}); | |
} else { | |
console.log("No merged PR found for this SHA."); | |
} | |
} catch (err) { | |
console.error(err); | |
} |