Merge pull request #25 from cvette/release-please--branches--main #45
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: Build | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
release: | |
types: [ created ] | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.2' | |
- uses: actions/checkout@v3 | |
- name: Validate composer.json and composer.lock | |
run: composer validate --strict | |
- name: Cache Composer packages | |
id: composer-cache | |
uses: actions/cache@v3 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-php- | |
- name: Install dependencies | |
run: composer install --prefer-dist --no-progress | |
- name: Run test suite | |
run: composer run-script test | |
- name: Cache tools installed with PHIVE | |
uses: actions/cache@v2.1.2 | |
with: | |
path: ${{ runner.temp }}/.phive | |
key: php-phive-${{ hashFiles('.phive/phars.xml') }} | |
restore-keys: php-phive- | |
- name: Install PHIVE | |
uses: szepeviktor/phive@v1 | |
with: | |
home: ${{ runner.temp }}/.phive | |
binPath: ${{ github.workspace }}/tools/phive | |
- name: Install box | |
run: ${{ github.workspace }}/tools/phive install humbug/box --trust-gpg-keys 2DF45277AEF09A2F | |
- name: Build Phar | |
run: ${{ github.workspace }}/tools/box compile | |
- name: Upload Phar | |
uses: actions/upload-artifact@v3.1.0 | |
with: | |
name: neoscs-phar | |
# A file, directory or wildcard pattern that describes what to upload | |
path: ${{ github.workspace }}/bin/neoscs.phar | |
- name: Log in to the Container registry | |
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 | |
with: | |
file: ${{ github.workspace }}/.docker/Dockerfile | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
publish-phar: | |
runs-on: ubuntu-latest | |
name: Publish the PHAR | |
needs: | |
- 'build' | |
if: github.event_name == 'release' | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: neoscs-phar | |
path: . | |
- name: Upload neoscs.phar | |
uses: softprops/action-gh-release@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
files: neoscs.phar |