diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e3ecb2b..24eeb0b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,204 +16,14 @@ on: type: boolean default: false -env: - # Package-specific configuration - customize these for each package - PACKAGE_NAME: ${{ vars.PACKAGE_NAME || 'wp-cli-builtnorth' }} - PACKAGE_DISPLAY_NAME: ${{ vars.PACKAGE_DISPLAY_NAME || 'WP-CLI Built North' }} - COMPOSER_NAMESPACE: ${{ vars.COMPOSER_NAMESPACE || 'builtnorth/wp-cli-builtnorth' }} - jobs: release: - name: Create Release - runs-on: ubuntu-latest + uses: builtnorth/.github/.github/workflows/composer-package-release.yml@main + with: + package-name: 'wp-cli-builtnorth' + package-display-name: 'WP CLI Built North' + composer-namespace: 'builtnorth/wp-cli-builtnorth' + version: ${{ inputs.version }} + prerelease: ${{ inputs.prerelease }} permissions: contents: write - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Determine version - id: version - run: | - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - VERSION="${{ github.event.inputs.version }}" - if [[ ! "$VERSION" =~ ^v ]]; then - VERSION="v$VERSION" - fi - else - VERSION="${{ github.ref_name }}" - fi - echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "version_number=${VERSION#v}" >> $GITHUB_OUTPUT - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.2' - tools: composer:v2 - - # Skip composer.json version update - version tracked via git tags only - # This prevents merge conflicts between branches - - - name: Update package.json version - if: contains(fromJSON('["package.json"]'), 'package.json') - run: | - if [ -f package.json ]; then - npm version ${{ steps.version.outputs.version_number }} --no-git-tag-version --allow-same-version - fi - - - name: Commit version updates - if: github.event_name == 'workflow_dispatch' - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - - # Skip adding composer.json - version tracked via git tags only - if [ -f package.json ]; then - git add package.json package-lock.json - fi - - if ! git diff --cached --quiet; then - git commit -m "chore: bump version to ${{ steps.version.outputs.version_number }}" - git push origin HEAD:${{ github.ref_name }} - fi - - - name: Create and push tag - if: github.event_name == 'workflow_dispatch' - run: | - git tag -a ${{ steps.version.outputs.version }} -m "Release ${{ steps.version.outputs.version }}" - git push origin ${{ steps.version.outputs.version }} - - - name: Generate changelog - id: changelog - run: | - # Get the previous tag - PREVIOUS_TAG=$(git describe --tags --abbrev=0 ${{ steps.version.outputs.version }}^ 2>/dev/null || echo "") - - if [ -z "$PREVIOUS_TAG" ]; then - echo "No previous tag found, including all commits" - COMMITS=$(git log --pretty=format:"- %s (%h)" --reverse) - else - echo "Generating changelog from $PREVIOUS_TAG to ${{ steps.version.outputs.version }}" - COMMITS=$(git log ${PREVIOUS_TAG}..${{ steps.version.outputs.version }} --pretty=format:"- %s (%h)" --reverse) - fi - - # Format changelog - CHANGELOG="## What's Changed in ${{ env.PACKAGE_DISPLAY_NAME }} ${{ steps.version.outputs.version }}" - CHANGELOG="$CHANGELOG"$'\n\n' - - # Group commits by type - FEATURES=$(echo "$COMMITS" | grep -E "^- (feat|feature):" || true) - FIXES=$(echo "$COMMITS" | grep -E "^- (fix|bugfix):" || true) - DOCS=$(echo "$COMMITS" | grep -E "^- (docs|documentation):" || true) - STYLE=$(echo "$COMMITS" | grep -E "^- (style|formatting):" || true) - REFACTOR=$(echo "$COMMITS" | grep -E "^- (refactor|refactoring):" || true) - TEST=$(echo "$COMMITS" | grep -E "^- (test|tests):" || true) - CHORE=$(echo "$COMMITS" | grep -E "^- (chore|build|ci):" || true) - OTHER=$(echo "$COMMITS" | grep -vE "^- (feat|feature|fix|bugfix|docs|documentation|style|formatting|refactor|refactoring|test|tests|chore|build|ci):" || true) - - if [ -n "$FEATURES" ]; then - CHANGELOG="$CHANGELOG"$'\n'"### Features"$'\n'"$FEATURES"$'\n' - fi - if [ -n "$FIXES" ]; then - CHANGELOG="$CHANGELOG"$'\n'"### Bug Fixes"$'\n'"$FIXES"$'\n' - fi - if [ -n "$DOCS" ]; then - CHANGELOG="$CHANGELOG"$'\n'"### Documentation"$'\n'"$DOCS"$'\n' - fi - if [ -n "$REFACTOR" ]; then - CHANGELOG="$CHANGELOG"$'\n'"### Refactoring"$'\n'"$REFACTOR"$'\n' - fi - if [ -n "$TEST" ]; then - CHANGELOG="$CHANGELOG"$'\n'"### Tests"$'\n'"$TEST"$'\n' - fi - if [ -n "$CHORE" ]; then - CHANGELOG="$CHANGELOG"$'\n'"### Maintenance"$'\n'"$CHORE"$'\n' - fi - if [ -n "$OTHER" ]; then - CHANGELOG="$CHANGELOG"$'\n'"### Other Changes"$'\n'"$OTHER"$'\n' - fi - - CHANGELOG="$CHANGELOG"$'\n'"**Full Changelog**: " - if [ -n "$PREVIOUS_TAG" ]; then - CHANGELOG="$CHANGELOG""https://github.com/${{ github.repository }}/compare/${PREVIOUS_TAG}...${{ steps.version.outputs.version }}" - else - CHANGELOG="$CHANGELOG""https://github.com/${{ github.repository }}/commits/${{ steps.version.outputs.version }}" - fi - - # Save to file for the release - echo "$CHANGELOG" > release_notes.md - - - name: Create release archive - run: | - # Create a clean release directory - mkdir -p release-archive - - # Copy all files except those that should be excluded - rsync -av \ - --exclude='.git' \ - --exclude='.github' \ - --exclude='composer.lock' \ - --exclude='release-archive' \ - --exclude='release_notes.md' \ - --exclude='node_modules' \ - --exclude='.env' \ - --exclude='tests' \ - --exclude='docs' \ - --exclude='examples' \ - --exclude='build' \ - --exclude='.vscode' \ - --exclude='.idea' \ - --exclude='*.log' \ - --exclude='.DS_Store' \ - --exclude='Thumbs.db' \ - --exclude='.gitignore' \ - --exclude='.gitattributes' \ - --exclude='phpunit.xml*' \ - --exclude='phpstan.neon*' \ - --exclude='.phpcs.xml*' \ - --exclude='Makefile' \ - --exclude='*.md' \ - . release-archive/ - - # Create zip archive - cd release-archive - zip -r ../${{ env.PACKAGE_NAME }}-${{ steps.version.outputs.version_number }}.zip . - cd .. - - - name: Create GitHub Release - uses: softprops/action-gh-release@v1 - with: - tag_name: ${{ steps.version.outputs.version }} - name: ${{ steps.version.outputs.version }} - body_path: release_notes.md - draft: false - prerelease: ${{ github.event.inputs.prerelease == 'true' }} - generate_release_notes: false - files: | - ${{ env.PACKAGE_NAME }}-${{ steps.version.outputs.version_number }}.zip - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Release summary - if: success() - run: | - echo "Release created successfully!" - echo "" - echo "To use this version in other packages:" - echo "" - echo " \"require\": {" - echo " \"${{ env.COMPOSER_NAMESPACE }}\": \"${{ steps.version.outputs.version_number }}\"" - echo " }" - echo "" - echo "With VCS repository:" - echo " \"repositories\": [" - echo " {" - echo " \"type\": \"vcs\"," - echo " \"url\": \"https://github.com/${{ github.repository }}\"" - echo " }" - echo " ]" \ No newline at end of file diff --git a/.github/workflows/scheduled-ci.yml b/.github/workflows/scheduled-ci.yml new file mode 100644 index 0000000..425f432 --- /dev/null +++ b/.github/workflows/scheduled-ci.yml @@ -0,0 +1,14 @@ +name: Scheduled CI + +on: + schedule: + # Run every Monday at 10:00 AM ET (2:00 PM UTC) + - cron: '0 14 * * 1' + workflow_dispatch: + +jobs: + scheduled-ci: + uses: builtnorth/.github/.github/workflows/composer-package-ci.yml@main + secrets: inherit + with: + composer-repository-profile: coding-standards-only \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index be568aa..97ce417 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,70 +1,13 @@ name: Tests on: - push: - branches: [ main ] pull_request: branches: [ main ] workflow_dispatch: jobs: - test: - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - php-version: ['8.1', '8.2', '8.3', '8.4'] - - name: PHP ${{ matrix.php-version }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - coverage: none - tools: composer:v2 - - - name: Get composer cache directory - id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - name: Cache dependencies - uses: actions/cache@v4 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Validate composer.json - run: composer validate --strict --no-check-lock - - - name: Install dependencies - run: composer install --prefer-dist --no-progress --no-interaction - - - name: Security check for vulnerabilities - run: composer audit --no-dev - - - name: Run tests - run: composer test - - test-status: - name: CI Status - runs-on: ubuntu-latest - needs: test - if: always() - - steps: - - name: Check results - run: | - if [ "${{ needs.test.result }}" == "success" ]; then - echo "✅ All checks passed!" - exit 0 - else - echo "❌ Tests failed!" - exit 1 - fi \ No newline at end of file + ci: + uses: builtnorth/.github/.github/workflows/composer-package-ci.yml@main + secrets: inherit + with: + composer-repository-profile: coding-standards-only diff --git a/composer.json b/composer.json index ed17587..16b1a45 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "php": ">=8.1", + "php": ">=8.0", "wp-cli/wp-cli": "^2.5" }, "require-dev": {