diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..0fcdea7 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,72 @@ +name: publish +on: + push: + tags: + - '*' + +jobs: + publish: + name: Ensure GitHub Release with extension TER artifact and publishing to TER + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + env: + TYPO3_EXTENSION_KEY: ${{ secrets.TYPO3_EXTENSION_KEY }} + TYPO3_API_TOKEN: ${{ secrets.TYPO3_API_TOKEN }} + permissions: + contents: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Verify tag + run: | + if ! [[ ${{ github.ref }} =~ ^refs/tags/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ ]]; then + echo "ERR: Invalid publish version tag: ${{ github.ref }}" + exit 1 + fi + + - name: Get version + id: get-version + run: echo "version=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + + - name: Get comment + id: get-comment + run: | + { + echo 'terReleaseNotes<> "$GITHUB_ENV" + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.0 + extensions: intl, mbstring, json, zip, curl + tools: composer:v2 + + - name: Install tailor + run: composer global require typo3/tailor --prefer-dist --no-progress --no-suggest + + # Note that step will fail when `env.version` does not match the `ext_emconf.php` version. + - name: Create local TER package upload artifact + run: | + php ~/.composer/vendor/bin/tailor create-artefact ${{ env.version }} + + # Note that when release already exists for tag, only files will be uploaded and lets this acting as a + # fallback to ensure that a real GitHub release is created for the tag along with extension artifacts. + - name: Create release and upload artifacts in the same step + uses: softprops/action-gh-release@v2 + if: ${{startsWith(github.ref, 'refs/tags/') }} + with: + name: "[RELEASE] ${{ env.version }}" + generate_release_notes: true + files: | + tailor-version-artefact/${{ env.TYPO3_EXTENSION_KEY }}_${{ env.version }}.zip + LICENSE + fail_on_unmatched_files: true + + - name: Publish to TER + run: | + php ~/.composer/vendor/bin/tailor ter:publish --comment "${{ env.terReleaseNotes }}" ${{ env.version }} \ + --artefact=tailor-version-artefact/${{ env.TYPO3_EXTENSION_KEY }}_${{ env.version }}.zip diff --git a/.github/workflows/publish.yml.disabled b/.github/workflows/publish.yml.disabled deleted file mode 100644 index 275c2c4..0000000 --- a/.github/workflows/publish.yml.disabled +++ /dev/null @@ -1,53 +0,0 @@ -# -# Automatic publishing to the TER is not currently working -# or the token may have expired. -# In addition, the EAP should not be pushed into the TER by mistake -# therefore this job is deactivated -# -#name: publish -# push: -# tags: -# - "**" -# -#jobs: -# publish: -# name: Publish new version to TER -# if: startsWith(github.ref, 'refs/tags/') -# runs-on: ubuntu-20.04 -# env: -# TYPO3_API_TOKEN: ${{ secrets.TYPO3_API_TOKEN }} -# -# steps: -# - name: Checkout repository -# uses: actions/checkout@v4 -# -# - name: Check tag -# run: | -# if ! [[ ${{ github.ref }} =~ ^refs/tags/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ ]]; then -# exit 1 -# fi -# - name: Get version -# id: get-version -# run: echo "version=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV -# -# - name: Get comment -# id: get-comment -# run: | -# readonly local comment=$(git tag -n10 -l ${{ env.version }} | sed "s/^[0-9.]*[ ]*//g") -# if [[ -z "${comment// }" ]]; then -# echo "comment=Released version ${{ env.version }} of ${{ env.TYPO3_EXTENSION_KEY }}" >> $GITHUB_ENV -# else -# echo "comment=$comment" >> $GITHUB_ENV -# fi -# - name: Setup PHP -# uses: shivammathur/setup-php@v2 -# with: -# php-version: 7.4 -# extensions: intl, mbstring, json, zip, curl -# tools: composer:v2 -# -# - name: Install tailor -# run: composer global require typo3/tailor --prefer-dist --no-progress -# -# - name: Publish to TER -# run: php ~/.composer/vendor/bin/tailor ter:publish --comment "${{ env.comment }}" ${{ env.version }} diff --git a/.gitignore b/.gitignore index 61d04bf..763f837 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,9 @@ var /*.http http-client.env.json /.test-results -Build/testing-docker/.env +/Build/testing-docker/.env /config/ Build/node_modules/ -vendor +/vendor +/tailor-version-artefact/ +/tailor-version-upload/ diff --git a/README.md b/README.md index 96c7196..20bf79b 100644 --- a/README.md +++ b/README.md @@ -42,3 +42,61 @@ DeepL Translate Extension for TYPO3. * [Hochschule für Musik Würzburg](https://www.hfm-wuerzburg.de) * [Carl von Ossietzky Universität Oldenburg](https://uol.de/) * [Friedrich-Ebert-Stiftung](https://www.fes.de) + +## Create a release (maintainers only) + +Prerequisites: + +* git binary +* ssh key allowed to push new branches to the repository +* GitHub command line tool `gh` installed and configured with user having permission to create pull requests. + +**Prepare release locally** + +> Set `RELEASE_BRANCH` to branch release should happen, for example: 'main'. +> Set `RELEASE_VERSION` to release version working on, for example: '5.0.0'. + +```shell +echo '>> Prepare release pull-request' ; \ + RELEASE_BRANCH='main' ; \ + RELEASE_VERSION='5.0.1' ; \ + git checkout main && \ + git fetch --all && \ + git pull --rebase && \ + git checkout ${RELEASE_BRANCH} && \ + git pull --rebase && \ + git checkout -b prepare-release-${RELEASE_VERSION} && \ + composer require --dev "typo3/tailor" && \ + ./.Build/bin/tailor set-version ${RELEASE_VERSION} && \ + composer remove --dev "typo3/tailor" && \ + git add . && \ + git commit -m "[TASK] Prepare release ${RELEASE_VERSION}" && \ + git push --set-upstream origin prepare-release-${RELEASE_VERSION} && \ + gh pr create --fill-verbose --base ${RELEASE_BRANCH} --title "[TASK] Prepare release for ${RELEASE_VERSION} on ${RELEASE_BRANCH}" && \ + git checkout main && \ + git branch -D prepare-release-${RELEASE_VERSION} +``` + +Check pull-request and the pipeline run. + +**Merge approved pull-request and push version tag** + +> Set `RELEASE_PR_NUMBER` with the pull-request number of the preparation pull-request. +> Set `RELEASE_BRANCH` to branch release should happen, for example: 'main' (same as in previous step). +> Set `RELEASE_VERSION` to release version working on, for example: `0.1.4` (same as in previous step). + +```shell +RELEASE_BRANCH='main' ; \ +RELEASE_VERSION='5.0.1' ; \ +RELEASE_PR_NUMBER='123' ; \ + git checkout main && \ + git fetch --all && \ + git pull --rebase && \ + gh pr checkout ${RELEASE_PR_NUMBER} && \ + gh pr merge -rd ${RELEASE_PR_NUMBER} && \ + git tag ${RELEASE_VERSION} && \ + git push --tags +``` + +This triggers the `on push tags` workflow (`publish.yml`) which creates the upload package, +creates the GitHub release and also uploads the release to the TYPO3 Extension Repository.