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
12 changes: 12 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ on:
- minor
- major
default: 'none'
package_name:
description: 'Optional package to publish (for example @banegasn/m3-navigation-rail)'
required: false
type: string

jobs:
quality:
Expand All @@ -28,6 +32,12 @@ jobs:
packages: write

steps:
- name: Validate release selection
if: ${{ inputs.package_name != '' && inputs.version_type != 'none' }}
run: |
echo 'A package_name requires version_type=none; bump and commit its version first.' >&2
exit 1

- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
Expand Down Expand Up @@ -78,6 +88,7 @@ jobs:
run: pnpm run publish:npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
PUBLISH_PACKAGE_NAME: ${{ inputs.package_name }}

- name: Configure GitHub Packages registry
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
Expand All @@ -90,6 +101,7 @@ jobs:
run: pnpm run publish:github
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PUBLISH_PACKAGE_NAME: ${{ inputs.package_name }}

- name: Create git tags
if: github.event.inputs.version_type != 'none' && github.event.inputs.version_type != ''
Expand Down
12 changes: 11 additions & 1 deletion PUBLISHING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ All packages are configured to publish to GitHub Packages with the following set

## Publishing Workflow

For an individual package whose version is already committed to `main`, run
the GitHub Actions workflow with a package name:

```bash
gh workflow run publish.yml --ref main -f version_type=none -f package_name=@banegasn/m3-navigation-rail
```

The package filter applies to both npm and GitHub Packages. Omit
`package_name` only when publishing every missing package version; that also
requires this repository to have write access to each existing GitHub package.

### 1. Build the Packages

Ensure all packages are built before publishing:
Expand Down Expand Up @@ -162,4 +173,3 @@ pnpm publish:packages
# Publish single package
pnpm --filter @banegasn/example-component publish
```

11 changes: 11 additions & 0 deletions scripts/publish-unpublished.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ $FORCE && echo "Force mode: skipping published check"

PACKAGES_DIR="packages"
to_publish=()
package_filter="${PUBLISH_PACKAGE_NAME:-}"
matched_package=false

for pkg_dir in "$PACKAGES_DIR"/*/; do
pkg_json="$pkg_dir/package.json"
Expand All @@ -44,6 +46,10 @@ for pkg_dir in "$PACKAGES_DIR"/*/; do
private=$(node -p "require('./$pkg_json').private ?? false")

[[ "$private" == "true" ]] && continue
if [[ -n "$package_filter" && "$name" != "$package_filter" ]]; then
continue
fi
matched_package=true

if $FORCE; then
echo "QUEUED (force): ${name}@${version}"
Expand All @@ -56,6 +62,11 @@ for pkg_dir in "$PACKAGES_DIR"/*/; do
fi
done

if [[ -n "$package_filter" && "$matched_package" != true ]]; then
echo "Unknown publishable package: $package_filter" >&2
exit 1
fi

if [[ ${#to_publish[@]} -eq 0 ]]; then
echo -e "\nAll packages are already published."
exit 0
Expand Down
Loading