diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..675db9c4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,85 @@ +# .github/workflows/release.yml +name: Tag from composer.json version + +on: + workflow_dispatch: + push: + branches: [ "3.x" ] + paths: + - composer.json + +permissions: + contents: write + +jobs: + create-tag: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository (with history & tags) + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install jq + run: sudo apt-get update && sudo apt-get install -y jq + + - name: Get current and previous version + id: versions + shell: bash + run: | + # extract current version from composer.json + CURR_VERSION=$(jq -r '.version // empty' composer.json) + if [ -z "$CURR_VERSION" ] || [ "$CURR_VERSION" = "null" ]; then + echo "composer.json has no .version field – aborting." + exit 1 + fi + + # get previous version from previous commit if composer.json existed there + if git rev-parse HEAD~1 >/dev/null 2>&1; then + if git show HEAD~1:composer.json >/dev/null 2>&1; then + PREV_VERSION=$(git show HEAD~1:composer.json | jq -r '.version // empty') + else + PREV_VERSION="" + fi + else + PREV_VERSION="" + fi + + echo "curr=$CURR_VERSION" >> "$GITHUB_OUTPUT" + echo "prev=$PREV_VERSION" >> "$GITHUB_OUTPUT" + + - name: Continue only if version changed + if: steps.versions.outputs.curr != steps.versions.outputs.prev + run: | + echo "Version changed: ${{ steps.versions.outputs.prev }} -> ${{ steps.versions.outputs.curr }}" + + - name: Stop if version is unchanged + if: steps.versions.outputs.curr == steps.versions.outputs.prev + run: | + echo "Version unchanged (${{ steps.versions.outputs.curr }}) – no tag needed." + exit 0 + + - name: Check if tag already exists + id: check_tag + run: | + TAG="v${{ steps.versions.outputs.curr }}" + if git rev-parse "refs/tags/$TAG" >/dev/null 2>&1 || \ + git ls-remote --tags origin "refs/tags/$TAG" | grep -q .; then + echo "exists=true" >> "$GITHUB_OUTPUT" + else + echo "exists=false" >> "$GITHUB_OUTPUT" + fi + + - name: Create and push tag (with v prefix) + if: steps.check_tag.outputs.exists == 'false' + run: | + TAG="v${{ steps.versions.outputs.curr }}" + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git tag "$TAG" + git push origin "$TAG" + + - name: Info if tag already exists + if: steps.check_tag.outputs.exists == 'true' + run: echo "Tag v${{ steps.versions.outputs.curr }} already exists – nothing to do." diff --git a/composer.json b/composer.json index f0267585..0a7d3a30 100644 --- a/composer.json +++ b/composer.json @@ -1,70 +1,71 @@ { - "name": "ebics-api/ebics-client-php", - "type": "library", - "description": "PHP library to communicate with bank through EBICS protocol.", - "keywords": [ - "ebics", - "PHP", - "client", - "openssl", - "rsa", - "x509", - "cfonb.120", - "cfonb.240", - "mt940", - "mt942" - ], - "authors": [ - { - "name": "Andrew Svirin" + "name": "ebics-api/ebics-client-php", + "version": "3.0.1", + "type": "library", + "description": "PHP library to communicate with bank through EBICS protocol.", + "keywords": [ + "ebics", + "PHP", + "client", + "openssl", + "rsa", + "x509", + "cfonb.120", + "cfonb.240", + "mt940", + "mt942" + ], + "authors": [ + { + "name": "Andrew Svirin" + } + ], + "license": "MIT", + "require": { + "php": "^8.1", + "ext-bcmath": "*", + "ext-curl": "*", + "ext-dom": "*", + "ext-json": "*", + "ext-openssl": "*", + "ext-zip": "*", + "ext-zlib": "*", + "ext-libxml": "*" + }, + "require-dev": { + "ebics-api/cfonb-php": "^1.0", + "ebics-api/mt942-php": "^1.0", + "phpseclib/phpseclib": "~2.0.48", + "phpstan/phpstan": "~1.9.18", + "phpunit/phpunit": "~9.6.24", + "psr/http-client": "^1.0", + "psr/http-factory": "^1.0", + "setasign/fpdf": "^1.8", + "squizlabs/php_codesniffer": "~3.7.2" + }, + "autoload": { + "psr-4": { + "EbicsApi\\Ebics\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "EbicsApi\\Ebics\\Tests\\": "tests" + } + }, + "suggest": { + "ebics-api/cfonb-php": "If you need to parse format CFONB from FDL requests.", + "ebics-api/mt942-php": "If you need to parse format MT942 from VMK, STA requests.", + "setasign/fpdf": "If you need to generate PDF file letter for Bank." + }, + "config": { + "sort-packages": true + }, + "minimum-stability": "dev", + "prefer-stable": true, + "scripts": { + "code-test": "vendor/bin/phpunit", + "code-style": "vendor/bin/phpcs", + "code-analyse": "vendor/bin/phpstan" } - ], - "license": "MIT", - "require": { - "php": "^8.1", - "ext-bcmath": "*", - "ext-curl": "*", - "ext-dom": "*", - "ext-json": "*", - "ext-openssl": "*", - "ext-zip": "*", - "ext-zlib": "*", - "ext-libxml": "*" - }, - "require-dev": { - "ebics-api/cfonb-php": "^1.0", - "ebics-api/mt942-php": "^1.0", - "phpseclib/phpseclib": "~2.0.48", - "phpstan/phpstan": "~1.9.18", - "phpunit/phpunit": "~9.6.24", - "psr/http-client": "^1.0", - "psr/http-factory": "^1.0", - "setasign/fpdf": "^1.8", - "squizlabs/php_codesniffer": "~3.7.2" - }, - "autoload": { - "psr-4": { - "EbicsApi\\Ebics\\": "src" - } - }, - "autoload-dev": { - "psr-4": { - "EbicsApi\\Ebics\\Tests\\": "tests" - } - }, - "suggest": { - "ebics-api/cfonb-php": "If you need to parse format CFONB from FDL requests.", - "ebics-api/mt942-php": "If you need to parse format MT942 from VMK, STA requests.", - "setasign/fpdf": "If you need to generate PDF file letter for Bank." - }, - "config": { - "sort-packages": true - }, - "minimum-stability": "dev", - "prefer-stable": true, - "scripts": { - "code-test": "vendor/bin/phpunit", - "code-style": "vendor/bin/phpcs", - "code-analyse": "vendor/bin/phpstan" - } }