From 791f89bf6410125d6dcd6b160bead4d88b43e233 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 4 Sep 2025 12:44:10 +0200 Subject: [PATCH] chore(ci): set up automated releases --- .github/workflows/main.yml | 3 -- .github/workflows/release.yml | 68 +++++++++++++++++++++++++++++++++++ .releaserc.json | 11 ++++++ 3 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .releaserc.json diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index afeb2bb..f05844d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,9 +2,6 @@ name: CI on: pull_request: - push: - branches: - - master jobs: tests: runs-on: ubuntu-latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..fb8341c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,68 @@ +name: Automated release +on: + push: + branches: + - master +jobs: + tests: + runs-on: ubuntu-latest + + strategy: + matrix: + php: [ 8.1, 8.2, 8.3, 8.4 ] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-interaction --no-suggest + + - name: Execute Code Sniffer + run: vendor/bin/phpcs + + - name: Execute PHP Stan + run: vendor/bin/phpstan + + - name: Run test suite + run: | + php -S 127.0.0.1:8000 -t tests/data/app >/dev/null 2>&1 & + php -S 127.0.0.1:8010 -t tests/data/rest >/dev/null 2>&1 & + php vendor/bin/codecept run + + + release: + name: Automated release + needs: + - tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + persist-credentials: false + - uses: actions/setup-node@v4 + with: + node-version: 22 + - run: > + npx + -p "@semantic-release/commit-analyzer" + -p "@semantic-release/release-notes-generator" + -p conventional-changelog-conventionalcommits + -p semantic-release + -- semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +permissions: + packages: write + contents: write + pull-requests: write \ No newline at end of file diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000..8492546 --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,11 @@ +{ + "branches": ["master"], + "tagFormat": "${version}", + "plugins": [ + ["@semantic-release/commit-analyzer", { + "preset": "conventionalcommits", + "presetConfig": {} + }], + "@semantic-release/github", + "@semantic-release/release-notes-generator"] +} \ No newline at end of file