Skip to content

Commit d68d217

Browse files
committed
[TASK] Backport publish workflow
This change backports the streamlined and modernized publish workflow to the `4.x` branch and enables it to allow specific adjustments in the future.
1 parent 1cdc2fb commit d68d217

File tree

4 files changed

+186
-53
lines changed

4 files changed

+186
-53
lines changed

.github/workflows/publish.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
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

.github/workflows/publish.yml.disabled

Lines changed: 0 additions & 53 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ Build/testing-docker/.env
1717
/config/
1818
Build/node_modules/
1919
vendor
20+
21+
tailor-version-artefact/
22+
tailor-version-upload/

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,61 @@ the DeepL Translate Extension for TYPO3.
7171
### DeepL "Add automatic translation flag and hint" sponsored by
7272

7373
* [FH Aachen](https://www.fh-aachen.de/)
74+
75+
## Create a release (maintainers only)
76+
77+
Prerequisites:
78+
79+
* git binary
80+
* ssh key allowed to push new branches to the repository
81+
* GitHub command line tool `gh` installed and configured with user having permission to create pull requests.
82+
83+
**Prepare release locally**
84+
85+
> Set `RELEASE_BRANCH` to branch release should happen, for example: 'main'.
86+
> Set `RELEASE_VERSION` to release version working on, for example: '4.4.4'.
87+
88+
```shell
89+
echo '>> Prepare release pull-request' ; \
90+
RELEASE_BRANCH='main' ; \
91+
RELEASE_VERSION='4.4.4' ; \
92+
git checkout main && \
93+
git fetch --all && \
94+
git pull --rebase && \
95+
git checkout ${RELEASE_BRANCH} && \
96+
git pull --rebase && \
97+
git checkout -b prepare-release-${RELEASE_VERSION} && \
98+
composer require --dev "typo3/tailor" && \
99+
./.Build/bin/tailor set-version ${RELEASE_VERSION} && \
100+
composer remove --dev "typo3/tailor" && \
101+
git add . && \
102+
git commit -m "[TASK] Prepare release ${RELEASE_VERSION}" && \
103+
git push --set-upstream origin prepare-release-${RELEASE_VERSION} && \
104+
gh pr create --fill-verbose --base ${RELEASE_BRANCH} --title "[TASK] Prepare release for ${RELEASE_VERSION} on ${RELEASE_BRANCH}" && \
105+
git checkout main && \
106+
git branch -D prepare-release-${RELEASE_VERSION}
107+
```
108+
109+
Check pull-request and the pipeline run.
110+
111+
**Merge approved pull-request and push version tag**
112+
113+
> Set `RELEASE_PR_NUMBER` with the pull-request number of the preparation pull-request.
114+
> Set `RELEASE_BRANCH` to branch release should happen, for example: 'main' (same as in previous step).
115+
> Set `RELEASE_VERSION` to release version working on, for example: `4.4.4` (same as in previous step).
116+
117+
```shell
118+
RELEASE_BRANCH='main' ; \
119+
RELEASE_VERSION='4.4.4' ; \
120+
RELEASE_PR_NUMBER='123' ; \
121+
git checkout main && \
122+
git fetch --all && \
123+
git pull --rebase && \
124+
gh pr checkout ${RELEASE_PR_NUMBER} && \
125+
gh pr merge -rd ${RELEASE_PR_NUMBER} && \
126+
git tag ${RELEASE_VERSION} && \
127+
git push --tags
128+
```
129+
130+
This triggers the `on push tags` workflow (`publish.yml`) which creates the upload package,
131+
creates the GitHub release and also uploads the release to the TYPO3 Extension Repository.

0 commit comments

Comments
 (0)