|
| 1 | +name: build v4 legacy |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + test: |
| 8 | + strategy: |
| 9 | + fail-fast: false |
| 10 | + matrix: |
| 11 | + php_version: ['8.4', '8.3','8.2','8.1','8.0','7.4'] |
| 12 | + variant: ['apache','cli','fpm'] |
| 13 | +# builder: [ {arch: "amd64", os: "ubuntu-latest"}, {arch: "arm64", os: "macos-latest"}] |
| 14 | + builder: [ {arch: "amd64", os: "ubuntu-latest"}, {arch: "arm64", os: "ubuntu-latest"}] |
| 15 | + runs-on: ${{ matrix.builder.os }} |
| 16 | + name: Test ${{ matrix.php_version }}-${{ matrix.variant }} ${{ matrix.builder.arch }} only |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + ref: v4 |
| 22 | + - name: Set up Docker |
| 23 | + # /!\ this action is marked as experimental |
| 24 | + # It's required only for macos |
| 25 | + if: ${{ matrix.builder.os == 'macos-latest' }} |
| 26 | + uses: docker-practice/actions-setup-docker@master |
| 27 | + - name: Set up QEMU |
| 28 | + uses: docker/setup-qemu-action@v3 |
| 29 | + - name: Set up Docker Buildx |
| 30 | + uses: docker/setup-buildx-action@v3 |
| 31 | + - name: Build |
| 32 | + run: | |
| 33 | + PHP_VERSION="${{ matrix.php_version }}" |
| 34 | + TAG_PREFIX="rc${GITHUB_RUN_ID}-" \ |
| 35 | + docker buildx bake \ |
| 36 | + --set "*.platform=linux/${{ matrix.builder.arch }}" \ |
| 37 | + --set "*.output=type=docker" \ |
| 38 | + --load \ |
| 39 | + php${PHP_VERSION//.}-${{ matrix.variant }}-all |
| 40 | + - name: Display tags built |
| 41 | + run: | |
| 42 | + docker image ls --filter="reference=thecodingmachine/php" --format "{{.CreatedAt}}\t{{.Size}}\t{{.Repository}}:{{.Tag}}" |
| 43 | + - name: Test |
| 44 | + run: | |
| 45 | + TAG_PREFIX="rc${GITHUB_RUN_ID}-" \ |
| 46 | + PHP_VERSION="${{ matrix.php_version }}" \ |
| 47 | + BRANCH="v4" \ |
| 48 | + VARIANT="${{ matrix.variant }}" \ |
| 49 | + PLATFORM="linux/${{ matrix.builder.arch }}" \ |
| 50 | + ./tests-suite/bash_unit -f tap ./tests-suite/*.sh |
| 51 | +
|
| 52 | + publish: |
| 53 | + # push ~ schedule |
| 54 | + if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }} |
| 55 | + needs: |
| 56 | + - test |
| 57 | + runs-on: ubuntu-latest |
| 58 | + name: Publish ${{ matrix.php_version }}-${{ matrix.variant }} multi-arch to dockerhub |
| 59 | + strategy: |
| 60 | + fail-fast: false |
| 61 | + matrix: |
| 62 | + php_version: ['8.4', '8.3','8.2','8.1','8.0','7.4'] |
| 63 | + variant: ['apache','cli','fpm'] |
| 64 | + steps: |
| 65 | + - name: Checkout |
| 66 | + uses: actions/checkout@v4 |
| 67 | + - name: Set up QEMU |
| 68 | + uses: docker/setup-qemu-action@v3 |
| 69 | + - name: Set up Docker Buildx |
| 70 | + uses: docker/setup-buildx-action@v3 |
| 71 | + - name: Login to DockerHub |
| 72 | + uses: docker/login-action@v3 |
| 73 | + with: |
| 74 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 75 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 76 | + - name: Fetch minor version of php |
| 77 | + run: | |
| 78 | + # Build slim one |
| 79 | + PHP_VERSION="${{ matrix.php_version }}" |
| 80 | + TAG_PREFIX="rc${GITHUB_RUN_ID}-" \ |
| 81 | + docker buildx bake \ |
| 82 | + --set "*.platform=linux/amd64" \ |
| 83 | + --set "*.output=type=docker" \ |
| 84 | + --load \ |
| 85 | + php${PHP_VERSION//.}-slim-${{ matrix.variant }} |
| 86 | + # Retrieve minor |
| 87 | + PHP_PATCH_MINOR=`docker run --rm thecodingmachine/php:rc${GITHUB_RUN_ID}-${{ matrix.php_version }}-v4-slim-${{ matrix.variant }} php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1` |
| 88 | + echo "PHP_PATCH_MINOR=${PHP_PATCH_MINOR}" >> $GITHUB_ENV |
| 89 | + - name: Display tags to build |
| 90 | + run: | |
| 91 | + PHP_VERSION="${{ matrix.php_version }}" |
| 92 | + PHP_PATCH_MINOR="${{ env.PHP_PATCH_MINOR }}" \ |
| 93 | + TAG_PREFIX="rc${GITHUB_RUN_ID}-" \ |
| 94 | + IS_RELEASE="1" \ |
| 95 | + docker buildx bake php${PHP_VERSION//.}-${{ matrix.variant }}-all --print --progress plain | jq ".target[].tags | join(\" \")" -r > "/tmp/tags.log" |
| 96 | + cat "/tmp/tags.log" |
| 97 | + - name: Build and push ${{ matrix.php_version }}-${{ matrix.variant }} |
| 98 | + run: | |
| 99 | + PHP_VERSION="${{ matrix.php_version }}" |
| 100 | + PHP_PATCH_MINOR="${{ env.PHP_PATCH_MINOR }}" \ |
| 101 | + TAG_PREFIX="rc${GITHUB_RUN_ID}-" \ |
| 102 | + IS_RELEASE="1" \ |
| 103 | + docker buildx bake \ |
| 104 | + --set "*.platform=linux/amd64,linux/arm64" \ |
| 105 | + --set "*.output=type=registry" \ |
| 106 | + php${PHP_VERSION//.}-${{ matrix.variant }}-all |
| 107 | + - name: Push artifacts |
| 108 | + uses: actions/upload-artifact@v3 |
| 109 | + with: |
| 110 | + name: ${{ matrix.php_version }}-${{ matrix.variant }} |
| 111 | + path: /tmp/tags.log |
| 112 | + retention-days: 60 |
0 commit comments