Initial commit: PHP CLI dev image, Alpine-based, 8.2/8.3/8.4/8.5 matr… #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*.*.*' | |
| env: | |
| IMAGE: ghcr.io/scalecommerce/docker-php-cli | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Derive versions from tag | |
| id: v | |
| run: | | |
| FULL="${GITHUB_REF_NAME#v}" | |
| if ! [[ "$FULL" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "::error::tag must be vX.Y.Z (got $GITHUB_REF_NAME)" | |
| exit 1 | |
| fi | |
| MAJOR="${FULL%.*}" | |
| # PHP major -> Alpine branch. Keep in sync with build-local.sh. | |
| case "$MAJOR" in | |
| 8.2) ALPINE=3.22 ;; | |
| 8.3|8.4|8.5) ALPINE=3.23 ;; | |
| *) echo "::error::unsupported PHP version $MAJOR"; exit 1 ;; | |
| esac | |
| { | |
| echo "full=$FULL" | |
| echo "major=$MAJOR" | |
| echo "alpine=$ALPINE" | |
| } >> "$GITHUB_OUTPUT" | |
| - uses: docker/setup-qemu-action@v3 | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push (multi-arch) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| build-args: | | |
| ALPINE_VERSION=${{ steps.v.outputs.alpine }} | |
| PHP_VERSION=${{ steps.v.outputs.major }} | |
| tags: | | |
| ${{ env.IMAGE }}:${{ steps.v.outputs.full }} | |
| ${{ env.IMAGE }}:${{ steps.v.outputs.major }} | |
| labels: | | |
| org.opencontainers.image.version=${{ steps.v.outputs.full }} | |
| org.opencontainers.image.source=https://github.com/${{ github.repository }} | |
| - name: Verify published image contains the tagged PHP version | |
| run: | | |
| docker pull "$IMAGE:${{ steps.v.outputs.full }}" | |
| ACTUAL=$(docker run --rm "$IMAGE:${{ steps.v.outputs.full }}" php -r 'echo PHP_VERSION;') | |
| if [[ "$ACTUAL" != "${{ steps.v.outputs.full }}" ]]; then | |
| echo "::error::tag is ${{ steps.v.outputs.full }} but image contains PHP $ACTUAL — Alpine bumped the patch between your local build and CI. Delete this tag and re-release with the new version." | |
| exit 1 | |
| fi | |
| - name: Extract versions.txt and extensions.txt | |
| id: info | |
| run: | | |
| { | |
| echo 'versions<<VERSIONS_EOF' | |
| docker run --rm "$IMAGE:${{ steps.v.outputs.full }}" cat /opt/versions.txt | |
| echo 'VERSIONS_EOF' | |
| } >> "$GITHUB_OUTPUT" | |
| { | |
| echo 'extensions<<EXTENSIONS_EOF' | |
| docker run --rm "$IMAGE:${{ steps.v.outputs.full }}" cat /opt/extensions.txt | |
| echo 'EXTENSIONS_EOF' | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Build release body | |
| env: | |
| VERSION: ${{ steps.v.outputs.full }} | |
| MAJOR: ${{ steps.v.outputs.major }} | |
| VERSIONS_TXT: ${{ steps.info.outputs.versions }} | |
| EXTENSIONS_TXT: ${{ steps.info.outputs.extensions }} | |
| run: | | |
| { | |
| echo '## Pull this version' | |
| echo '' | |
| echo '```' | |
| echo "docker pull $IMAGE:$VERSION" | |
| echo "docker pull $IMAGE:$MAJOR" | |
| echo '```' | |
| echo '' | |
| echo '## Versions' | |
| echo '' | |
| echo '```' | |
| echo "$VERSIONS_TXT" | |
| echo '```' | |
| echo '' | |
| echo '## PHP extensions' | |
| echo '' | |
| echo '```' | |
| echo "$EXTENSIONS_TXT" | |
| echo '```' | |
| } > release-body.md | |
| cat release-body.md | |
| - name: Create GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| body_path: release-body.md |