Extract into a separate workflow

This commit is contained in:
Alex P 2024-09-02 16:26:32 +03:00
parent 1a0d4975df
commit 62224fecb8
No known key found for this signature in database
GPG key ID: 54487A734A204D71
2 changed files with 77 additions and 21 deletions

36
.github/workflows/package-new.yml vendored Normal file
View file

@ -0,0 +1,36 @@
name: Build package (New)
on:
workflow_dispatch:
inputs:
packageVersion:
description: 'Package version'
required: false
type: string
jobs:
check_version:
runs-on: ubuntu-latest
env:
PACKAGE_VERSION: ${{ github.event.inputs.packageVersion }}
outputs:
version: ${{ env.PACKAGE_VERSION }}
name: Check version
steps:
- uses: actions/checkout@v4
- name: Fix plugin version input # Add the version number if only suffix entered
run: echo "PACKAGE_VERSION=$(sed -nE '/Version:/s/.* ([0-9.]+).*/\1/p' woocommerce-paypal-payments.php)-$PACKAGE_VERSION" >> $GITHUB_ENV
if: env.PACKAGE_VERSION && !contains(env.PACKAGE_VERSION, '.')
- name: Fill plugin version # If the version number was not set, retrieve it from the file
run: echo "PACKAGE_VERSION=$(sed -nE '/Version:/s/.* ([0-9.]+).*/\1/p' woocommerce-paypal-payments.php)" >> $GITHUB_ENV
if: "!env.PACKAGE_VERSION"
create_archive:
needs: check_version
uses: inpsyde/reusable-workflows/.github/workflows/build-plugin-archive.yml@feature/PROD-171-rector-archive
with:
PHP_VERSION: 7.2
PLUGIN_MAIN_FILE: ./woocommerce-paypal-payments.php
PLUGIN_VERSION: ${{ needs.check_version.outputs.version }}
ARCHIVE_NAME: woocommerce-paypal-payments-${{ needs.check_version.outputs.version }}
COMPILE_ASSETS_ARGS: '-vv --env=root'

View file

@ -7,30 +7,50 @@ on:
description: 'Package version'
required: false
type: string
filePrefix:
description: 'File prefix'
required: false
type: string
jobs:
check_version:
package:
runs-on: ubuntu-latest
env:
PACKAGE_VERSION: ${{ github.event.inputs.packageVersion }}
outputs:
version: ${{ env.PACKAGE_VERSION }}
name: Check version
steps:
- uses: actions/checkout@v4
- name: Fix plugin version input # Add the version number if only suffix entered
run: echo "PACKAGE_VERSION=$(sed -nE '/Version:/s/.* ([0-9.]+).*/\1/p' woocommerce-paypal-payments.php)-$PACKAGE_VERSION" >> $GITHUB_ENV
if: env.PACKAGE_VERSION && !contains(env.PACKAGE_VERSION, '.')
- name: Fill plugin version # If the version number was not set, retrieve it from the file
run: echo "PACKAGE_VERSION=$(sed -nE '/Version:/s/.* ([0-9.]+).*/\1/p' woocommerce-paypal-payments.php)" >> $GITHUB_ENV
if: "!env.PACKAGE_VERSION"
FILENAME: woocommerce-paypal-payments
create_archive:
needs: check_version
uses: inpsyde/reusable-workflows/.github/workflows/build-plugin-archive.yml@feature/PROD-171-rector-archive
with:
PHP_VERSION: 7.2
PLUGIN_MAIN_FILE: ./woocommerce-paypal-payments.php
PLUGIN_VERSION: ${{ needs.check_version.outputs.version }}
ARCHIVE_NAME: woocommerce-paypal-payments-${{ needs.check_version.outputs.version }}
COMPILE_ASSETS_ARGS: '-vv --env=root'
name: Build package
steps:
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.2
- name: Fix plugin version input # Add the version number if only suffix entered
run: echo "PACKAGE_VERSION=$(sed -nE '/Version:/s/.* ([0-9.]+).*/\1/p' woocommerce-paypal-payments.php)-$PACKAGE_VERSION" >> $GITHUB_ENV
if: env.PACKAGE_VERSION && !contains(env.PACKAGE_VERSION, '.')
- name: Set plugin version header
run: 'sed -Ei "s/Version: .*/Version: ${PACKAGE_VERSION}/g" woocommerce-paypal-payments.php'
if: env.PACKAGE_VERSION
- name: Build
run: yarn build
- name: Unzip # GH currently always zips, so if we upload a zip we get a zip inside a zip
run: unzip woocommerce-paypal-payments.zip -d dist
- name: Set file name
env:
FILE_PREFIX: ${{ github.event.inputs.filePrefix }}
run: echo "FILENAME=$FILE_PREFIX-$FILENAME" >> $GITHUB_ENV
if: github.event.inputs.filePrefix
- name: Upload
uses: actions/upload-artifact@v3
with:
name: ${{ env.FILENAME }}
path: dist/