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
55 changes: 0 additions & 55 deletions .github/RELEASE_PROCESS.md

This file was deleted.

24 changes: 8 additions & 16 deletions .github/release-template.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
{
"branches": ["main"],
"plugins": [
["@semantic-release/commit-analyzer", {
"preset": "angular",
"releaseRules": [
{"type": "feat", "release": "minor"},
{"type": "fix", "release": "patch"},
{"type": "docs", "release": "patch"},
{"type": "style", "release": "patch"},
{"type": "refactor", "release": "patch"},
{"type": "perf", "release": "patch"},
{"type": "test", "release": "patch"},
{"type": "build", "release": "patch"},
{"type": "ci", "release": "patch"},
{"type": "chore", "scope": "deps", "release": "patch"}
]
}],
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
"@semantic-release/github"
["@semantic-release/github", {
"assets": []
}],
["@semantic-release/git", {
"assets": ["package.json"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}]
]
}
135 changes: 135 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: Publish Packages to npm

on:
push:
branches:
- main
paths:
- 'packages/**'
workflow_dispatch:
inputs:
package:
description: 'Package to publish (leave empty to detect changes)'
required: false
type: string
force_publish:
description: 'Force publish even without version change'
required: false
type: boolean
default: false

jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Find changed packages
id: changed-packages
if: ${{ github.event.inputs.package == '' }}
run: |
# Get all packages
PACKAGES=$(find packages -type f -name "package.json" -not -path "*/node_modules/*" | grep -o 'packages/[^/]*' | sort | uniq)

# Get last successful run commit
git fetch origin
LAST_COMMIT=$(git rev-parse HEAD^)

# Initialize array for changed packages
CHANGED=()

# Check each package
for PKG in $PACKAGES; do
if git diff --name-only $LAST_COMMIT HEAD | grep -q "^$PKG/"; then
echo "$PKG has changes"
PKG_NAME=$(basename $PKG)
CHANGED+=("$PKG_NAME")
fi
done

# Convert to JSON array for matrix directly using jq
if [ ${#CHANGED[@]} -eq 0 ]; then
echo "No changes detected in any package"
echo "matrix=[]" >> $GITHUB_OUTPUT
else
JSON_ARRAY=$(printf '%s\n' "${CHANGED[@]}" | jq -R . | jq -c -s .)
echo "Changed packages: $JSON_ARRAY"
echo "matrix=$JSON_ARRAY" >> $GITHUB_OUTPUT
fi

- name: Use manually specified package
id: manual-package
if: ${{ github.event.inputs.package != '' }}
run: |
PACKAGE="${{ github.event.inputs.package }}"
echo "Publishing package: $PACKAGE"
echo "matrix=[\"$PACKAGE\"]" >> $GITHUB_OUTPUT

- name: Set matrix
id: set-matrix
run: |
if [[ "${{ github.event.inputs.package }}" != "" ]]; then
echo "matrix=${{ steps.manual-package.outputs.matrix }}" >> $GITHUB_OUTPUT
elif [[ "${{ steps.changed-packages.outputs.matrix }}" == "[]" || -z "${{ steps.changed-packages.outputs.matrix }}" ]]; then
echo "No changes detected in any package"
echo "matrix=[]" >> $GITHUB_OUTPUT
else
echo "matrix=${{ steps.changed-packages.outputs.matrix }}" >> $GITHUB_OUTPUT
fi

publish:
needs: detect-changes
if: ${{ needs.detect-changes.outputs.matrix != '[]' }}
runs-on: ubuntu-latest
strategy:
matrix:
package: ${{ fromJson(needs.detect-changes.outputs.matrix) }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'

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

- name: Build package
run: |
cd packages/${{ matrix.package }}
yarn build

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
FORCE_PUBLISH: ${{ github.event.inputs.force_publish }}
run: |
cd packages/${{ matrix.package }}
# Check if .releaserc.json exists, create if not
if [ ! -f .releaserc.json ]; then
echo "Creating .releaserc.json from template"
cp ../../.github/release-template.json .releaserc.json
fi
# Install semantic-release if not in package.json
if ! grep -q "semantic-release" package.json; then
yarn add --dev semantic-release @semantic-release/git
fi

# Add force publish flag if specified
if [ "$FORCE_PUBLISH" == "true" ]; then
echo "Running with force publish flag"
npx semantic-release --no-ci
else
npx semantic-release
85 changes: 0 additions & 85 deletions .github/workflows/pullrequest.yml

This file was deleted.

Loading