Skip to content

Commit b86a091

Browse files
committed
[TASK] Enable streamlined publish workflow
The `publish` workflow has been added disabled when adding this addon after splitting it from original `deepltranslate-core` due to issues with `tailor` and `TER` in general and has been resolvend meanwhile. This change enables the publish workflow to have now automatic `TER` upload when tagged, using a slightly modernized workflow definition with soft fail option. The `README.md` file is extended with a section for maintainers only how a release will be created and done with all command(s) to have a streamlined flow across all public extensions.
1 parent 204ca0b commit b86a091

File tree

4 files changed

+147
-55
lines changed

4 files changed

+147
-55
lines changed

.github/workflows/publish.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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_API_TOKEN: ${{ secrets.TYPO3_API_TOKEN }}
14+
permissions:
15+
contents: write
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Verify tag
21+
run: |
22+
if ! [[ ${{ github.ref }} =~ ^refs/tags/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ ]]; then
23+
echo "ERR: Invalid publish version tag: ${{ github.ref }}"
24+
exit 1
25+
fi
26+
27+
- name: Get version
28+
id: get-version
29+
run: echo "version=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
30+
31+
- name: Determine extension key
32+
id: get-extension-key
33+
run: |
34+
echo "DETECTED_EXTENSION_KEY=$(cat composer.json | jq -r '.extra."typo3/cms"."extension-key"' )" >> "$GITHUB_ENV"
35+
36+
- name: Get comment
37+
id: get-comment
38+
run: |
39+
readonly local releaseCommentPrependBody="$( git tag -l ${{ env.version }} --format '%(contents)' )"
40+
if (( $(grep -c . <<<"${releaseCommentPrependBody// }") > 1 )); then
41+
{
42+
echo 'releaseCommentPrependBody<<EOF'
43+
echo "$releaseCommentPrependBody"
44+
echo EOF
45+
} >> "$GITHUB_ENV"
46+
fi
47+
{
48+
echo 'terReleaseNotes<<EOF'
49+
echo "https://github.com/web-vision/deepltranslate-glossary/releases/tag/${{ env.version }}"
50+
echo EOF
51+
} >> "$GITHUB_ENV"
52+
53+
- name: Setup PHP
54+
uses: shivammathur/setup-php@v2
55+
with:
56+
php-version: 8.0
57+
extensions: intl, mbstring, json, zip, curl
58+
tools: composer:v2
59+
60+
- name: Install tailor
61+
run: composer global require typo3/tailor --prefer-dist --no-progress --no-suggest
62+
63+
# Note that step will fail when `env.version` does not match the `ext_emconf.php` version.
64+
- name: Create local TER package upload artifact
65+
run: |
66+
php ~/.composer/vendor/bin/tailor create-artefact ${{ env.version }}
67+
68+
# Note that when release already exists for tag, only files will be uploaded and lets this acting as a
69+
# fallback to ensure that a real GitHub release is created for the tag along with extension artifacts.
70+
- name: Create release and upload artifacts in the same step
71+
uses: softprops/action-gh-release@v2
72+
if: ${{startsWith(github.ref, 'refs/tags/') }}
73+
with:
74+
name: "[RELEASE] ${{ env.version }}"
75+
body: "${{ env.releaseCommentPrependBody }}"
76+
generate_release_notes: true
77+
files: |
78+
tailor-version-artefact/${{ env.DETECTED_EXTENSION_KEY }}_${{ env.version }}.zip
79+
LICENSE
80+
fail_on_unmatched_files: true
81+
82+
- name: Publish to TER
83+
run: |
84+
php ~/.composer/vendor/bin/tailor ter:publish --comment "${{ env.terReleaseNotes }}" ${{ env.version }} \
85+
--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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ var
1313
/*.http
1414
http-client.env.json
1515
/.test-results
16-
Build/testing-docker/.env
16+
/Build/testing-docker/.env
1717
/config/
1818
Build/node_modules/
19-
vendor
19+
/vendor
20+
/tailor-version-artefact/
21+
/tailor-version-upload/

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,61 @@ DeepL Translate Extension for TYPO3.
4242
* [Hochschule für Musik Würzburg](https://www.hfm-wuerzburg.de)
4343
* [Carl von Ossietzky Universität Oldenburg](https://uol.de/)
4444
* [Friedrich-Ebert-Stiftung](https://www.fes.de)
45+
46+
## Create a release (maintainers only)
47+
48+
Prerequisites:
49+
50+
* git binary
51+
* ssh key allowed to push new branches to the repository
52+
* GitHub command line tool `gh` installed and configured with user having permission to create pull requests.
53+
54+
**Prepare release locally**
55+
56+
> Set `RELEASE_BRANCH` to branch release should happen, for example: 'main'.
57+
> Set `RELEASE_VERSION` to release version working on, for example: '5.0.0'.
58+
59+
```shell
60+
echo '>> Prepare release pull-request' ; \
61+
RELEASE_BRANCH='main' ; \
62+
RELEASE_VERSION='5.0.1' ; \
63+
git checkout main && \
64+
git fetch --all && \
65+
git pull --rebase && \
66+
git checkout ${RELEASE_BRANCH} && \
67+
git pull --rebase && \
68+
git checkout -b prepare-release-${RELEASE_VERSION} && \
69+
composer require --dev "typo3/tailor" && \
70+
./.Build/bin/tailor set-version ${RELEASE_VERSION} && \
71+
composer remove --dev "typo3/tailor" && \
72+
git add . && \
73+
git commit -m "[TASK] Prepare release ${RELEASE_VERSION}" && \
74+
git push --set-upstream origin prepare-release-${RELEASE_VERSION} && \
75+
gh pr create --fill-verbose --base ${RELEASE_BRANCH} --title "[TASK] Prepare release for ${RELEASE_VERSION} on ${RELEASE_BRANCH}" && \
76+
git checkout main && \
77+
git branch -D prepare-release-${RELEASE_VERSION}
78+
```
79+
80+
Check pull-request and the pipeline run.
81+
82+
**Merge approved pull-request and push version tag**
83+
84+
> Set `RELEASE_PR_NUMBER` with the pull-request number of the preparation pull-request.
85+
> Set `RELEASE_BRANCH` to branch release should happen, for example: 'main' (same as in previous step).
86+
> Set `RELEASE_VERSION` to release version working on, for example: `0.1.4` (same as in previous step).
87+
88+
```shell
89+
RELEASE_BRANCH='main' ; \
90+
RELEASE_VERSION='5.0.1' ; \
91+
RELEASE_PR_NUMBER='123' ; \
92+
git checkout main && \
93+
git fetch --all && \
94+
git pull --rebase && \
95+
gh pr checkout ${RELEASE_PR_NUMBER} && \
96+
gh pr merge -rd ${RELEASE_PR_NUMBER} && \
97+
git tag ${RELEASE_VERSION} && \
98+
git push --tags
99+
```
100+
101+
This triggers the `on push tags` workflow (`publish.yml`) which creates the upload package,
102+
creates the GitHub release and also uploads the release to the TYPO3 Extension Repository.

0 commit comments

Comments
 (0)