diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ee4307a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,40 @@ +name: CI + +on: + schedule: + - cron: "0 0 * * *" + push: + branches: [ main, develop, feature/** ] + pull_request: + branches: [ main, develop, feature/** ] + +permissions: + contents: read + +jobs: + tests: + uses: myerscode/workflows/.github/workflows/php-tests.yml@v1 + with: + php-versions: "['8.5']" + os: "['ubuntu-latest', 'macos-latest', 'windows-latest']" + extensions: "json" + + lint: + uses: myerscode/workflows/.github/workflows/php-lint.yml@v1 + with: + php-version: "8.5" + extensions: "json" + + audit: + uses: myerscode/workflows/.github/workflows/php-security-audit.yml@v1 + with: + php-version: "8.5" + extensions: "json" + + coverage: + uses: myerscode/workflows/.github/workflows/php-coverage.yml@v1 + with: + php-version: "8.5" + extensions: "json" + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml deleted file mode 100644 index c9baddf..0000000 --- a/.github/workflows/codecov.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: codecov - -on: - schedule: - - cron: "0 0 * * *" - push: - branches: [ main ] - -permissions: - contents: read - -jobs: - run: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ ubuntu-latest ] - php-versions: [ '8.5' ] - - name: PHP ${{ matrix.php-versions }} - ${{ matrix.os }} - steps: - - name: Checkout - uses: actions/checkout@v7 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - coverage: xdebug - extensions: json - - name: Install dependencies - run: composer install --prefer-dist --no-progress --no-interaction - - name: Run Test Suite - run: vendor/bin/phpunit --testdox --coverage-clover ./coverage.xml - - name: Code Coverage - uses: codecov/codecov-action@v7 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ./coverage.xml - verbose: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d8e39fc..d6d1ae7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,123 +4,21 @@ on: workflow_dispatch: inputs: version: - description: 'Version (e.g. 2026.0.0 or 1.2.3)' + description: 'CalVer version (e.g. 2026.0.0)' required: true type: string - scheme: - description: 'Version scheme' - required: true - type: choice - options: - - calver - - semver - default: calver push: tags: - '[0-9][0-9][0-9][0-9].*' permissions: contents: write - pull-requests: write jobs: release: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v7 - with: - ref: main - fetch-depth: 0 - token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} - persist-credentials: true - - - name: Determine version and scheme - id: version - run: | - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - TAG="${{ github.event.inputs.version }}" - SCHEME="${{ github.event.inputs.scheme }}" - else - TAG="${GITHUB_REF_NAME}" - if echo "$TAG" | grep -qE '^[0-9]{4}\.[0-9]+\.[0-9]+$'; then - SCHEME="calver" - else - SCHEME="semver" - fi - fi - echo "tag=$TAG" >> "$GITHUB_OUTPUT" - echo "scheme=$SCHEME" >> "$GITHUB_OUTPUT" - - - name: Validate version format - run: | - TAG="${{ steps.version.outputs.tag }}" - SCHEME="${{ steps.version.outputs.scheme }}" - if [ "$SCHEME" = "calver" ]; then - if ! echo "$TAG" | grep -qE '^[0-9]{4}\.[0-9]+\.[0-9]+$'; then - echo "Error: Version must be in CalVer format YYYY.MINOR.PATCH (e.g. 2026.0.0)" - exit 1 - fi - else - if ! echo "$TAG" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then - echo "Error: Version must be in SemVer format MAJOR.MINOR.PATCH (e.g. 1.2.3)" - exit 1 - fi - fi - - - name: Create and push tag - if: github.event_name == 'workflow_dispatch' - run: | - git tag "${{ steps.version.outputs.tag }}" - git push origin "${{ steps.version.outputs.tag }}" - - - name: Get previous tag - id: previous - run: | - CURRENT="${{ steps.version.outputs.tag }}" - PREVIOUS=$(git tag --list --sort=-version:refname '[0-9]*' | grep -v "^${CURRENT}$" | head -1) - if [ -n "$PREVIOUS" ]; then - echo "tag=$PREVIOUS" >> "$GITHUB_OUTPUT" - echo "found=true" >> "$GITHUB_OUTPUT" - else - echo "tag=" >> "$GITHUB_OUTPUT" - echo "found=false" >> "$GITHUB_OUTPUT" - fi - - - name: Generate changelog - if: steps.previous.outputs.found == 'true' - id: changelog - uses: requarks/changelog-action@v1 - with: - token: ${{ github.token }} - fromTag: ${{ steps.version.outputs.tag }} - toTag: ${{ steps.previous.outputs.tag }} - excludeTypes: build,docs,other,style,ci,chore - useGitmojis: false - writeToFile: false - - - name: Create GitHub release - uses: softprops/action-gh-release@v3 - with: - tag_name: ${{ steps.version.outputs.tag }} - name: ${{ steps.version.outputs.tag }} - body: ${{ steps.changelog.outputs.changes || 'Initial release' }} - - - name: Write changelog to file - if: steps.previous.outputs.found == 'true' - uses: requarks/changelog-action@v1 - with: - token: ${{ github.token }} - fromTag: ${{ steps.version.outputs.tag }} - toTag: ${{ steps.previous.outputs.tag }} - excludeTypes: build,docs,other,style,ci,chore - useGitmojis: false - writeToFile: true - - - name: Commit updated CHANGELOG - if: steps.previous.outputs.found == 'true' - uses: stefanzweifel/git-auto-commit-action@v7 - with: - branch: main - commit_message: "docs: update CHANGELOG for ${{ steps.version.outputs.tag }}" - file_pattern: CHANGELOG.md + uses: myerscode/workflows/.github/workflows/php-release.yml@v1 + with: + version: ${{ github.event.inputs.version }} + scheme: calver + secrets: + PAT: ${{ secrets.PAT }} diff --git a/.github/workflows/security-audit.yml b/.github/workflows/security-audit.yml deleted file mode 100644 index 2c4d7b8..0000000 --- a/.github/workflows/security-audit.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Security Audit - -on: - schedule: - - cron: "0 6 * * *" - push: - branches: [ main ] - pull_request: - branches: [ main ] - -permissions: - contents: read - -jobs: - audit: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v7 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.5' - extensions: json - - name: Install dependencies - run: composer install --prefer-dist --no-progress --no-interaction - - name: Run security audit - run: composer audit diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 433f860..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Tests - -on: - schedule: - - cron: "0 0 * * *" - push: - branches: [ main, develop, feature/** ] - pull_request: - branches: [ main, develop, feature/** ] - -permissions: - contents: read - -jobs: - run: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - php-versions: [ '8.5' ] - - name: PHP ${{ matrix.php-versions }} - ${{ matrix.os }} - steps: - - name: Checkout - uses: actions/checkout@v7 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - extensions: json - - name: Install dependencies - run: composer install --prefer-dist --no-progress --no-interaction - - name: Run test suite - run: vendor/bin/phpunit --testdox --no-coverage diff --git a/.github/workflows/update-changelog.yml b/.github/workflows/update-changelog.yml new file mode 100644 index 0000000..dd1623a --- /dev/null +++ b/.github/workflows/update-changelog.yml @@ -0,0 +1,20 @@ +name: Update Changelog + +on: + workflow_dispatch: + inputs: + version: + description: 'Release version to regenerate changelog for' + required: true + type: string + +permissions: + contents: write + +jobs: + changelog: + uses: myerscode/workflows/.github/workflows/php-changelog.yml@v1 + with: + version: ${{ github.event.inputs.version }} + secrets: + PAT: ${{ secrets.PAT }}