|
| 1 | +# yaml-language-server: $schema=https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json |
| 2 | +name: Upgrade |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - chore/release-workflow |
| 8 | + workflow_dispatch: ~ |
| 9 | + |
| 10 | +jobs: |
| 11 | + upgrade: |
| 12 | + name: Upgrade |
| 13 | + if: ${{ github.repository == 'api-platform/demo' }} |
| 14 | + runs-on: ubuntu-latest |
| 15 | + permissions: |
| 16 | + contents: write |
| 17 | + pull-requests: write |
| 18 | + steps: |
| 19 | + - |
| 20 | + name: Checkout |
| 21 | + uses: actions/checkout@v4 |
| 22 | + - |
| 23 | + name: Setup PHP with Composer |
| 24 | + uses: shivammathur/setup-php@v2 |
| 25 | + with: |
| 26 | + tools: composer |
| 27 | + - |
| 28 | + name: Get Composer Cache Directory |
| 29 | + id: composer-cache |
| 30 | + working-directory: api |
| 31 | + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT |
| 32 | + - |
| 33 | + name: Cache Dependencies |
| 34 | + uses: actions/cache@v4 |
| 35 | + with: |
| 36 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 37 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 38 | + restore-keys: ${{ runner.os }}-composer- |
| 39 | + - |
| 40 | + name: Install Dependencies |
| 41 | + working-directory: api |
| 42 | + run: composer install --prefer-dist |
| 43 | + - |
| 44 | + name: Update API Platform Dependencies |
| 45 | + working-directory: api |
| 46 | + run: composer update "api-platform/*" |
| 47 | + - |
| 48 | + name: Calculate Diff |
| 49 | + working-directory: api |
| 50 | + id: diff |
| 51 | + run: | |
| 52 | + echo "from-version=$(git diff composer.lock | grep -m 1 "api-platform/*" -A 2 | grep -oP '^-\s*"version": "v(.*)",' | sed -e 's/^-\s*"version": "v\(.*\)",$/\1/')" >> $GITHUB_OUTPUT |
| 53 | + echo "to-version=$(git diff composer.lock | grep -m 1 "api-platform/*" -A 2 | grep -oP '^\+\s*"version": "v(.*)",' | sed -e 's/^\+\s*"version": "v\(.*\)",$/\1/')" >> $GITHUB_OUTPUT |
| 54 | + - |
| 55 | + name: Update API version |
| 56 | + if: steps.diff.outputs.to-version != '' |
| 57 | + run: | |
| 58 | + sed -i "s/version: .*/version: ${{ steps.diff.outputs.to-version }}/g" api/config/packages/api_platform.yaml |
| 59 | + sed -i "s/^version: .*/version: ${{ steps.diff.outputs.to-version }}/g" helm/api-platform/Chart.yaml |
| 60 | + sed -i "s/^appVersion: .*/appVersion: ${{ steps.diff.outputs.to-version }}/g" helm/api-platform/Chart.yaml |
| 61 | + - |
| 62 | + name: Create Pull Request |
| 63 | + uses: peter-evans/create-pull-request@v7 |
| 64 | + if: steps.diff.outputs.to-version != '' |
| 65 | + with: |
| 66 | + branch: release/api-platform-$toVersion |
| 67 | + commit-message: "chore: upgrade API Platform to $toVersion" |
| 68 | + title: "chore: upgrade API Platform to $toVersion" |
| 69 | + assignees: vincentchalamon |
| 70 | + add-paths: | |
| 71 | + api/composer.* |
| 72 | + api/config/packages/api_platform.yaml |
| 73 | + helm/api-platform/Chart.yaml |
0 commit comments