Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [["@module-federation/astro"]],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": [
"example-host",
"example-remote"
]
}
5 changes: 5 additions & 0 deletions .changeset/fresh-forks-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/astro': patch
---

chore: align package metadata, release automation, and package build tooling with the module-federation/astro repository
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI

on:
pull_request:
branches:
- main
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
verify:
name: Verify
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.28.2

- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
registry-url: https://registry.npmjs.org/

- run: corepack enable

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build package and examples
run: pnpm turbo run build --filter=@module-federation/astro --filter="example-*"

- name: Test package
run: pnpm turbo run test --filter=@module-federation/astro

- name: Typecheck package
run: pnpm turbo run typecheck --filter=@module-federation/astro

- name: Lint package
run: pnpm turbo run lint --filter=@module-federation/astro

- name: Check package formatting
run: pnpm turbo run fmt.check --filter=@module-federation/astro
22 changes: 22 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Validate PR title

on:
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-pr-${{ github.event.pull_request.number }}
cancel-in-progress: true

permissions:
pull-requests: read

jobs:
semantic-pr:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5.5.3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
202 changes: 202 additions & 0 deletions .github/workflows/publish-on-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
name: Publish (GitHub Release)

on:
release:
types: [released, prereleased]
workflow_dispatch:
inputs:
version:
type: choice
description: Release Version
required: true
default: next
options:
- latest
- next
branch:
description: Release Branch (confirm release branch)
required: true
default: main

permissions:
contents: read
id-token: write

concurrency:
group: publish-${{ github.workflow }}-${{ github.ref_name || github.run_id }}
cancel-in-progress: false

jobs:
publish:
runs-on: ubuntu-latest
environment: Publish
steps:
- name: Checkout source
uses: actions/checkout@v5
with:
fetch-depth: 25
ref: ${{ github.event.release.tag_name || github.event.inputs.branch }}

- name: Cache tool downloads
uses: actions/cache@v4
with:
path: ~/.cache
key: ${{ runner.os }}-toolcache-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-toolcache-

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.28.2

- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
registry-url: https://registry.npmjs.org/

- run: corepack enable

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Generate preview version
if: github.event_name == 'workflow_dispatch' && github.event.inputs.version == 'next'
run: |
SAFE_BRANCH=$(echo "${{ github.event.inputs.branch }}" | sed 's/[^a-zA-Z0-9-]/-/g' | tr '[:upper:]' '[:lower:]')
npx changeset version --snapshot "$SAFE_BRANCH"

- name: Verify tag matches package version
if: github.event_name == 'release'
run: |
TAG="${{ github.event.release.tag_name }}"
if [ "${TAG#v}" != "$TAG" ]; then
echo "Invalid tag format; refusing to publish."
echo "Expected: 1.2.3 (no leading 'v')"
echo "Got: $TAG"
exit 1
fi

VERSION_FROM_TAG="$TAG"
PKG_VERSION="$(node -p "require('./packages/astro/package.json').version")"

if [ "$PKG_VERSION" != "$VERSION_FROM_TAG" ]; then
echo "Version mismatch; refusing to publish."
echo "Git tag: $TAG"
echo "packages/astro/package.json version: $PKG_VERSION"
exit 1
fi

- name: Patch prerelease version with next tag
if: github.event_name == 'release' && github.event.action == 'prereleased'
shell: bash
run: |
PACKAGE_NAME="@module-federation/astro"
CURRENT_VERSION="$(node -p "require('./packages/astro/package.json').version")"
BASE_VERSION="${CURRENT_VERSION%%-*}"
CURRENT_NEXT="$(npm view "$PACKAGE_NAME" "dist-tags.next" --json 2>/dev/null || true)"
CURRENT_NEXT="${CURRENT_NEXT#\"}"
CURRENT_NEXT="${CURRENT_NEXT%\"}"
if [ "$CURRENT_NEXT" = "null" ]; then
CURRENT_NEXT=""
fi

PREFIX_REGEX="^${BASE_VERSION//./\\.}-next\.([0-9]+)$"
if [[ "$CURRENT_NEXT" =~ $PREFIX_REGEX ]]; then
NEXT_NUMBER=$((BASH_REMATCH[1] + 1))
else
NEXT_NUMBER=1
fi

NEXT_VERSION="${BASE_VERSION}-next.${NEXT_NUMBER}"
npm pkg set version="$NEXT_VERSION" --workspace packages/astro
echo "Set prerelease version: $NEXT_VERSION"

- name: Build package
run: pnpm build:package

- name: Compute npm dist-tag
id: dist
shell: bash
run: |
DIST_TAG="latest"
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
if [ "${{ github.event.inputs.version }}" = "next" ]; then
DIST_TAG="next"
fi
else
if [ "${{ github.event.action }}" = "prereleased" ]; then
DIST_TAG="next"
fi
fi

echo "dist_tag=$DIST_TAG" >> "$GITHUB_OUTPUT"

- name: Resolve publish action
id: publish_action
shell: bash
run: |
PACKAGE_NAME="@module-federation/astro"
PKG_VERSION="$(node -p "require('./packages/astro/package.json').version")"
DIST_TAG="${{ steps.dist.outputs.dist_tag }}"
ACTION="publish"
REASON="new version not yet on npm"

EXISTING_VERSION="$(npm view "$PACKAGE_NAME@$PKG_VERSION" version --json 2>/dev/null || true)"
EXISTING_VERSION="${EXISTING_VERSION#\"}"
EXISTING_VERSION="${EXISTING_VERSION%\"}"

if [ "$EXISTING_VERSION" = "$PKG_VERSION" ]; then
CURRENT_TAG_VERSION="$(npm view "$PACKAGE_NAME" "dist-tags.$DIST_TAG" --json 2>/dev/null || true)"
CURRENT_TAG_VERSION="${CURRENT_TAG_VERSION#\"}"
CURRENT_TAG_VERSION="${CURRENT_TAG_VERSION%\"}"
if [ "$CURRENT_TAG_VERSION" = "null" ]; then
CURRENT_TAG_VERSION=""
fi

if [ "$CURRENT_TAG_VERSION" = "$PKG_VERSION" ]; then
ACTION="skip"
REASON="version already published and dist-tag already points to it"
else
echo "Refusing to republish existing npm version:"
echo "Package: $PACKAGE_NAME"
echo "Version: $PKG_VERSION"
echo "Target dist-tag: $DIST_TAG"
echo "Current '$DIST_TAG' dist-tag points to: ${CURRENT_TAG_VERSION:-<unset>}"
echo ""
echo "Trusted Publishers do not support dist-tag promotion without publishing."
echo "Use a new semver version for this release flow."
exit 1
fi
fi

echo "action=$ACTION" >> "$GITHUB_OUTPUT"
echo "reason=$REASON" >> "$GITHUB_OUTPUT"

- name: Publish to npm
if: steps.publish_action.outputs.action == 'publish'
run: npm publish --provenance --tag "${{ steps.dist.outputs.dist_tag }}" --access public --workspace packages/astro

- name: Skip npm publish
if: steps.publish_action.outputs.action == 'skip'
run: |
echo "Skipping npm publish:"
echo "${{ steps.publish_action.outputs.reason }}"

- name: Post summary
if: always()
continue-on-error: true
run: |
PKG_VERSION="$(node -p "require('./packages/astro/package.json').version")"
SOURCE_REF="${{ github.event.release.tag_name || github.event.inputs.branch }}"
echo "## npm publish" > "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "Package: \`@module-federation/astro\`" >> "$GITHUB_STEP_SUMMARY"
echo "Version: \`$PKG_VERSION\`" >> "$GITHUB_STEP_SUMMARY"
echo "Dist-tag: \`${{ steps.dist.outputs.dist_tag }}\`" >> "$GITHUB_STEP_SUMMARY"
echo "Action: \`${{ steps.publish_action.outputs.action || 'unknown' }}\`" >> "$GITHUB_STEP_SUMMARY"
echo "Reason: \`${{ steps.publish_action.outputs.reason || 'n/a' }}\`" >> "$GITHUB_STEP_SUMMARY"
echo "Trigger: \`${{ github.event_name }}\`" >> "$GITHUB_STEP_SUMMARY"
echo "Source ref: \`$SOURCE_REF\`" >> "$GITHUB_STEP_SUMMARY"
62 changes: 62 additions & 0 deletions .github/workflows/release-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Release Pull Request

on:
workflow_dispatch:
inputs:
version:
type: choice
description: Release Type (next, beta, alpha, latest)
required: true
default: latest
options:
- next
- beta
- alpha
- latest

jobs:
release:
name: Create Release Pull Request
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v5
with:
fetch-depth: 10

- name: Cache tool downloads
uses: actions/cache@v4
with:
path: ~/.cache
key: ${{ runner.os }}-toolcache-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-toolcache-

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.28.2

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
cache-dependency-path: pnpm-lock.yaml

- name: Install dependencies
run: pnpm install --ignore-scripts

- name: Create release pull request
uses: module-federation/actions@v2
with:
version: ${{ github.event.inputs.version || 'latest' }}
versionNumber: auto
type: pull request
tools: changeset
coreNpmName: '@module-federation/astro'
env:
GITHUB_TOKEN: ${{ secrets.REPO_SCOPED_TOKEN || secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
REPOSITORY: ${{ github.repository }}
REF: ${{ github.ref }}
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ jobs:
- name: Install dependencies
run: pnpm i

- name: Build
run: pnpm run build
- name: Build package
run: pnpm run build:package

- name: Resolve npm tag
id: npm-tag
run: |
VERSION=$(node -p 'require("./package.json").version')
TAG=$(node -p 'const version = require("./package.json").version; const prerelease = version.match(/-([0-9A-Za-z-]+)/); prerelease ? prerelease[1] : "latest"')
VERSION=$(node -p 'require("./packages/astro/package.json").version')
TAG=$(node -p 'const version = require("./packages/astro/package.json").version; const prerelease = version.match(/-([0-9A-Za-z-]+)/); prerelease ? prerelease[1] : "latest"')
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "Publishing version $VERSION with tag $TAG"

- name: Publish to npm
run: npm publish --tag ${{ steps.npm-tag.outputs.tag }}
run: npm publish --provenance --access public --tag ${{ steps.npm-tag.outputs.tag }} --workspace packages/astro
Loading
Loading