From 650672ede852420ccdccb6e19612fcb8c7249095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20P=C3=89RONNET?= Date: Sat, 12 Aug 2023 23:47:02 +0200 Subject: [PATCH] feat(ci) Automatically prepare release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre PÉRONNET --- .github/workflows/release.yml | 41 +++++++++++++++++++++++++++++++++++ .gitignore | 3 +++ build.lst | 6 +++++ composer.json | 7 ++++++ 4 files changed, 57 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 build.lst diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..cfd3eca --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,41 @@ +name: Release + +on: + push: + branches: [ "main" ] + +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: Build release + run: composer run-script build + + - name: Version + id: version + run: |- + echo P2CF_VERSION="$(composer run-script version)" >> "$GITHUB_OUTPUT" + git log $(git describe --tags --abbrev=0)..HEAD --oneline > changes.txt + + - uses: ncipollo/release-action@v1 + with: + artifacts: "p2cf.zip" + bodyFile: changes.txt + tag: "v${{ steps.version.outputs.P2CF_VERSION }}" + artifactErrorsFailBuild: true + draft: true diff --git a/.gitignore b/.gitignore index d8d604a..eeaab2f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ bin *.bak .phpunit.result.cache junit-result.xml + +build +p2cf.zip diff --git a/build.lst b/build.lst new file mode 100644 index 0000000..40add82 --- /dev/null +++ b/build.lst @@ -0,0 +1,6 @@ +classes/ +css/ +js/ +languages/*.json +languages/*.mo +vendor/ diff --git a/composer.json b/composer.json index 3350539..0197547 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,13 @@ "./bin/install-wp-tests.sh wordpress root root localhost latest true", "phpunit --no-interaction --log-junit junit-result.xml" ], + "build": [ + "composer install --dev --prefer-dist --no-interaction --no-progress --no-suggest", + "composer run-script i18n-build", + "composer install --no-dev --prefer-dist --optimize-autoloader --no-interaction --no-progress --no-suggest", + "composer dump-autoload --no-dev --optimize --classmap-authoritative", + "zip -9vr p2cf.zip . -i@build.lst -i *.php" + ], "test": [ "phpunit" ]