|
| 1 | +name: publish |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - '*' |
| 6 | + |
| 7 | +jobs: |
| 8 | + publish: |
| 9 | + name: Ensure GitHub Release with extension TER artifact and publishing to TER |
| 10 | + if: startsWith(github.ref, 'refs/tags/') |
| 11 | + runs-on: ubuntu-latest |
| 12 | + env: |
| 13 | + TYPO3_EXTENSION_KEY: ${{ secrets.TYPO3_EXTENSION_KEY }} |
| 14 | + TYPO3_API_TOKEN: ${{ secrets.TYPO3_API_TOKEN }} |
| 15 | + permissions: |
| 16 | + contents: write |
| 17 | + steps: |
| 18 | + - name: Checkout repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Verify tag |
| 22 | + run: | |
| 23 | + if ! [[ ${{ github.ref }} =~ ^refs/tags/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ ]]; then |
| 24 | + echo "ERR: Invalid publish version tag: ${{ github.ref }}" |
| 25 | + exit 1 |
| 26 | + fi |
| 27 | +
|
| 28 | + - name: Get version |
| 29 | + id: get-version |
| 30 | + run: echo "version=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV |
| 31 | + |
| 32 | + - name: Get comment |
| 33 | + id: get-comment |
| 34 | + run: | |
| 35 | + readonly local releaseCommentPrependBody="$( git tag -l ${{ env.version }} --format '%(contents)' )" |
| 36 | + if (( $(grep -c . <<<"${releaseCommentPrependBody// }") > 1 )); then |
| 37 | + { |
| 38 | + echo 'releaseCommentPrependBody<<EOF' |
| 39 | + echo "$releaseCommentPrependBody" |
| 40 | + echo EOF |
| 41 | + } >> "$GITHUB_ENV" |
| 42 | + fi |
| 43 | + { |
| 44 | + echo 'terReleaseNotes<<EOF' |
| 45 | + echo "https://github.com/fgtclb/academic-persons/releases/tag/${{ env.version }}" |
| 46 | + echo EOF |
| 47 | + } >> "$GITHUB_ENV" |
| 48 | +
|
| 49 | + - name: Setup PHP 7.4 ( wv_deepltranslate 4.x ) |
| 50 | + if: github.event.base_ref == 'refs/heads/4' |
| 51 | + uses: shivammathur/setup-php@v2 |
| 52 | + with: |
| 53 | + php-version: 7.4 |
| 54 | + extensions: intl, mbstring, json, zip, curl |
| 55 | + tools: composer:v2 |
| 56 | + |
| 57 | + - name: Setup PHP 8.1 ( deepltranlsate-core 5.x ) |
| 58 | + if: github.event.base_ref == 'refs/heads/main' |
| 59 | + uses: shivammathur/setup-php@v2 |
| 60 | + with: |
| 61 | + php-version: 8.1 |
| 62 | + extensions: intl, mbstring, json, zip, curl |
| 63 | + tools: composer:v2 |
| 64 | + |
| 65 | + - name: Prepare vendor folder and autoload configuration for TER upload |
| 66 | + shell: bash |
| 67 | + run: | |
| 68 | + rm -rf vendor composer.lock composer.json.orig composer.json.pretty \ |
| 69 | + && mv composer.json composer.json.orig \ |
| 70 | + && composer init -n \ |
| 71 | + --type=project \ |
| 72 | + --license='GPL-2.0-or-later' \ |
| 73 | + --name=release/draft \ |
| 74 | + --description empty \ |
| 75 | + --author='release' \ |
| 76 | + && composer config allow-plugins.php-http/discovery true \ |
| 77 | + && composer require "deeplcom/deepl-php":"$( cat composer.json.orig | jq -r '.require."deeplcom/deepl-php"' )" \ |
| 78 | + && rm -rf composer.lock \ |
| 79 | + vendor/composer \ |
| 80 | + vendor/nyholm \ |
| 81 | + vendor/php-http/multipart-stream-builder \ |
| 82 | + vendor/psr \ |
| 83 | + vendor/symfony \ |
| 84 | + vendor/autoload.php \ |
| 85 | + vendor/bin \ |
| 86 | + && cat <<< $(jq --indent 4 '."autoload"."psr-4" += {"DeepL\\": "vendor/deeplcom/deepl-php/src", "Http\\Discovery\\": "vendor/php-http/discovery/src"}' composer.json.orig) > composer.json.pretty \ |
| 87 | + && rm -rf composer.json \ |
| 88 | + && mv composer.json.pretty composer.json \ |
| 89 | + && rm -rf composer.json.orig |
| 90 | +
|
| 91 | + - name: Install tailor |
| 92 | + run: composer global require typo3/tailor --prefer-dist --no-progress --no-suggest |
| 93 | + |
| 94 | + # Note that step will fail when `env.version` does not match the `ext_emconf.php` version. |
| 95 | + - name: Create local TER package upload artifact |
| 96 | + env: |
| 97 | + # See https://github.com/TYPO3/tailor?tab=readme-ov-file#exclude-paths-from-packaging |
| 98 | + TYPO3_EXCLUDE_FROM_PACKAGING: Build/tailor/ExcludeFromPackaging.php |
| 99 | + run: | |
| 100 | + php ~/.composer/vendor/bin/tailor create-artefact ${{ env.version }} ${{ env.DETECTED_EXTENSION_KEY }} |
| 101 | +
|
| 102 | + # Note that when release already exists for tag, only files will be uploaded and lets this acting as a |
| 103 | + # fallback to ensure that a real GitHub release is created for the tag along with extension artifacts. |
| 104 | + - name: Create release and upload artifacts in the same step |
| 105 | + uses: softprops/action-gh-release@v2 |
| 106 | + if: ${{startsWith(github.ref, 'refs/tags/') }} |
| 107 | + with: |
| 108 | + name: "[RELEASE] ${{ env.version }}" |
| 109 | + body: "${{ env.releaseCommentPrependBody }}" |
| 110 | + generate_release_notes: true |
| 111 | + files: | |
| 112 | + tailor-version-artefact/${{ env.DETECTED_EXTENSION_KEY }}_${{ env.version }}.zip |
| 113 | + LICENSE |
| 114 | + fail_on_unmatched_files: true |
| 115 | + |
| 116 | + # @todo Currently an issue exists with the TYPO3 Extension Repository (TER) tailor based uploads, which seems to |
| 117 | + # be WAF related and the T3O TER Team working on. Allow this step to fail (continue on error) for now until |
| 118 | + # issues has been sorted out. |
| 119 | + # https://github.com/TYPO3/tailor/issues/82 |
| 120 | + - name: Publish to TER |
| 121 | + # @todo Remove `continue-on-error` after upload with tailor has been fixed. |
| 122 | + continue-on-error: true |
| 123 | + run: | |
| 124 | + php ~/.composer/vendor/bin/tailor ter:publish --comment "${{ env.terReleaseNotes }}" ${{ env.version }} \ |
| 125 | + --artefact=tailor-version-artefact/${{ env.DETECTED_EXTENSION_KEY }}_${{ env.version }}.zip |
0 commit comments