Fix actions runner not having latest PHP version #25
Workflow file for this run
This file contains 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: | |
- '*.*.*' | |
permissions: | |
contents: write | |
env: | |
PHAR_NAME: desniff.phar | |
REGISTRY: docker.io | |
IMAGE_NAME: backdevs/desniff | |
jobs: | |
test: | |
uses: ./.github/workflows/test.yml | |
phar-build-and-upload: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup PHP | |
id: setup-php | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.3' | |
- uses: actions/checkout@v4 | |
- name: Cache Composer packages | |
id: composer-cache | |
uses: actions/cache@v4 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-composer- | |
- name: Install dependencies | |
if: steps.composer-cache.outputs.cache-hit != 'true' | |
run: composer install --prefer-dist --no-progress --no-dev | |
- name: Cache PHAR | |
uses: actions/cache@v4 | |
with: | |
path: dist/${{ env.PHAR_NAME }} | |
key: ${{ runner.os }}-phar-${{ hashFiles('src/*.php') }} | |
- name: Build PHAR | |
uses: addnab/docker-run-action@v3 | |
with: | |
image: backdevs/box:latest | |
options: -v ${{ github.workspace }}:/app | |
run: box compile | |
- name: Upload PHAR to release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
file: dist/${{ env.PHAR_NAME }} | |
asset_name: ${{ env.PHAR_NAME }} | |
tag: ${{ github.ref }} | |
overwrite: true | |
docker-build-and-push: | |
needs: phar-build-and-upload | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache PHAR | |
uses: actions/cache@v4 | |
with: | |
path: dist/${{ env.PHAR_NAME }} | |
key: ${{ runner.os }}-phar-${{ hashFiles('src/*.php') }} | |
- name: Setup Docker buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log into registry ${{ env.REGISTRY }} | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ secrets.DOCKER_REGISTRY_USER }} | |
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
- name: Build and push Docker image | |
id: build-and-push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
build-args: | | |
BOX_VERSION=${{ steps.meta.outputs.version }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-to: type=gha,mode=max | |
cache-from: type=gha |