From 57ee685017e5924431dd72f65259ac54bbd1863d Mon Sep 17 00:00:00 2001 From: moorl Date: Fri, 26 Sep 2025 11:23:15 +0200 Subject: [PATCH 1/2] Initial release action --- .github/workflows/release.yml | 85 +++++++++++++++++++++ composer.json | 135 +++++++++++++++++----------------- 2 files changed, 153 insertions(+), 67 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..58d91454 --- /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" - } } From 24b8140e2c298d83f319ce85d996f1b898e472dc Mon Sep 17 00:00:00 2001 From: moorl Date: Fri, 26 Sep 2025 11:29:05 +0200 Subject: [PATCH 2/2] Initial release action --- .github/workflows/release.yml | 112 +++++++++++++++++----------------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 58d91454..675db9c4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,7 @@ name: Tag from composer.json version on: workflow_dispatch: push: - branches: [ 3.x ] + branches: [ "3.x" ] paths: - composer.json @@ -16,70 +16,70 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout repository (with history & tags) - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - 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: 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 + - 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 + # 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 + 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: 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: 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: 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: 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." + - 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."