fix(cli): enable serve feature by default and fix asset path #15
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: Publish Packages | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| dry_run: | |
| description: 'Run publish dry-run' | |
| required: false | |
| default: 'true' | |
| permissions: | |
| contents: read | |
| id-token: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| publish-packages: | |
| name: Publish crates and npm packages | |
| runs-on: ubuntu-latest | |
| environment: prod | |
| env: | |
| DRY_RUN: ${{ inputs.dry_run || 'false' }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: wasm32-unknown-unknown | |
| - name: Install wasm-pack | |
| run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| cache: 'yarn' | |
| - name: Upgrade npm | |
| run: npm install -g npm@11.5.1 | |
| - name: Install dependencies | |
| run: yarn install | |
| - name: Build WASM | |
| run: wasm-pack build crates/flowscope-wasm --target web --out-dir ../../packages/core/wasm | |
| - name: Build core package | |
| run: yarn workspace @pondpilot/flowscope-core build | |
| - name: Build react package | |
| run: yarn workspace @pondpilot/flowscope-react build | |
| - name: Resolve crate version | |
| id: crate_version | |
| run: | | |
| python - <<'PY' >> "$GITHUB_OUTPUT" | |
| import pathlib | |
| import re | |
| data = pathlib.Path('Cargo.toml').read_text() | |
| match = re.search(r'^version\s*=\s*"([^"]+)"', data, re.MULTILINE) | |
| if not match: | |
| raise SystemExit('Could not find workspace version in Cargo.toml') | |
| print(f"workspace_version={match.group(1)}") | |
| PY | |
| - name: Dry-run publish crates | |
| if: ${{ env.DRY_RUN == 'true' }} | |
| run: | | |
| cargo publish -p flowscope-core --dry-run --locked | |
| cargo publish -p flowscope-export --dry-run --locked | |
| cargo publish -p flowscope-cli --dry-run --locked | |
| - name: Publish crates | |
| if: ${{ env.DRY_RUN != 'true' }} | |
| run: | | |
| if [ -z "${CARGO_REGISTRY_TOKEN}" ]; then | |
| echo "CARGO_REGISTRY_TOKEN is missing." | |
| exit 1 | |
| fi | |
| VERSION="${{ steps.crate_version.outputs.workspace_version }}" | |
| for CRATE in flowscope-core flowscope-export flowscope-cli; do | |
| STATUS=$(curl -s -o /dev/null -w "%{http_code}" \ | |
| -H "User-Agent: flowscope-ci" \ | |
| -H "Accept: application/json" \ | |
| "https://crates.io/api/v1/crates/${CRATE}/${VERSION}") | |
| if [ "$STATUS" = "200" ]; then | |
| echo "${CRATE}@${VERSION} already published; skipping." | |
| elif [ "$STATUS" = "404" ]; then | |
| cargo publish -p "${CRATE}" --locked | |
| else | |
| echo "Unexpected crates.io status ${STATUS} for ${CRATE}@${VERSION}." | |
| exit 1 | |
| fi | |
| done | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| - name: Dry-run npm pack (core) | |
| if: ${{ env.DRY_RUN == 'true' }} | |
| working-directory: packages/core | |
| run: npm pack --dry-run --workspaces=false | |
| - name: Dry-run npm pack (react) | |
| if: ${{ env.DRY_RUN == 'true' }} | |
| working-directory: packages/react | |
| run: npm pack --dry-run --workspaces=false | |
| - name: Publish npm package (core) | |
| if: ${{ env.DRY_RUN != 'true' }} | |
| working-directory: packages/core | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| if npm view "@pondpilot/flowscope-core@${VERSION}" version >/dev/null 2>&1; then | |
| echo "@pondpilot/flowscope-core@${VERSION} already published; skipping." | |
| else | |
| npm publish --workspaces=false | |
| fi | |
| env: | |
| NODE_AUTH_TOKEN: '' | |
| - name: Publish npm package (react) | |
| if: ${{ env.DRY_RUN != 'true' }} | |
| run: echo "Skipping @pondpilot/flowscope-react publish." |