Update main.yml #13
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 and Release | |
on: | |
push: | |
branches: | |
- cicd | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build: | |
name: Build π | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 7.4 | |
- name: Build Vendor | |
run: | | |
composer install --no-interaction --optimize-autoloader | |
- name: Compress Vendor | |
uses: vimtor/[email protected] | |
with: | |
files: vendor/ | |
recursive: false | |
dest: vendor.zip | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: vendor | |
path: vendor.zip | |
- name: Get version from composer.json | |
id: get_version | |
run: | | |
VERSION=$(jq -r .version composer.json) | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
outputs: | |
version: ${{ steps.get_version.outputs.version }} | |
release: | |
name: Create Release π | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Download Artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: vendor | |
path: . | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ needs.build.outputs.version }} | |
release_name: ${{ needs.build.outputs.version }} | |
draft: false | |
prerelease: false | |
- name: Upload Release Asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./vendor.zip | |
asset_name: vendor.zip | |
asset_content_type: application/zip |