eliashaeussler/typo3-solver

View on GitHub
.github/workflows/release.yaml

Summary

Maintainability
Test Coverage
name: Release
on:
  push:
    tags:
      - '*'

jobs:
  # Job: Create release
  release:
    if: startsWith(github.ref, 'refs/tags/')
    runs-on: ubuntu-latest
    outputs:
      release-notes-url: ${{ steps.create-release.outputs.html_url }}
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      # Check if tag is valid
      - 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

      # Create release
      - name: Create release
        id: create-release
        uses: ncipollo/release-action@v1
        with:
          generateReleaseNotes: true

  # Job: Publish on TER
  ter-publish:
    if: startsWith(github.ref, 'refs/tags/')
    needs: [release]
    runs-on: ubuntu-latest
    env:
      TYPO3_EXTENSION_KEY: solver
      TYPO3_API_TOKEN: ${{ secrets.TYPO3_API_TOKEN }}
      TYPO3_EXCLUDE_FROM_PACKAGING: packaging_exclude.php
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      # Check if tag is valid
      - 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

      # Prepare version
      - id: get-version
        run: echo "version=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
      - id: get-comment
        run: echo "comment=See release notes at ${{ needs.release.outputs.release-notes-url }}" >> $GITHUB_OUTPUT

      # Prepare environment
      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: 8.1
          extensions: intl, mbstring, json, zip, curl
          tools: composer:v2
          coverage: none

      # Build dependencies
      - name: Build dependencies
        env:
          BUILD_PATH: Resources/Private/Libs/Build
          LIB_PATH: Resources/Private/Libs
        run: |
          git reset --hard HEAD && git clean -dfx
          curl -L https://clue.engineering/phar-composer-latest.phar -o phar-composer.phar
          composer install -d $(pwd)/$BUILD_PATH
          php phar-composer.phar build $(pwd)/$BUILD_PATH $(pwd)/$LIB_PATH/vendors.phar
          rm phar-composer.phar

      # Install tailor
      - name: Install tailor
        run: composer global require typo3/tailor --prefer-dist --no-progress --no-suggest

      - name: Publish to TER
        run: |
          php ~/.composer/vendor/bin/tailor set-version "${{ steps.get-version.outputs.version }}" --no-docs
          php ~/.composer/vendor/bin/tailor ter:publish --comment "${{ steps.get-comment.outputs.comment }}" "${{ steps.get-version.outputs.version }}"