chore: add deprecation warnings #3
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: [DEPRECATED] Create plugin archive | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| NODE_OPTIONS: | ||
| description: Space-separated list of command-line Node options. | ||
| type: string | ||
| default: '' | ||
| required: false | ||
| NODE_VERSION: | ||
| description: Node version with which the assets will be compiled. | ||
| default: 18 | ||
| required: false | ||
| type: string | ||
| NPM_REGISTRY_DOMAIN: | ||
| description: Domain of the private npm registry. | ||
| default: https://npm.pkg.github.com/ | ||
| required: false | ||
| type: string | ||
| PACKAGE_MANAGER: | ||
| description: Package manager with which the dependencies should be installed (`npm` or `yarn`). | ||
| default: 'npm' | ||
| required: false | ||
| type: string | ||
| COMPOSER_ARGS: | ||
| description: Set of arguments passed to Composer when gathering production dependencies. | ||
| default: '--no-dev --prefer-dist --optimize-autoloader' | ||
| required: false | ||
| type: string | ||
| PHP_VERSION: | ||
| description: PHP version to use when gathering production dependencies. | ||
| default: '8.2' | ||
| required: false | ||
| type: string | ||
| PHP_VERSION_BUILD: | ||
| description: PHP version to use when executing build tools. | ||
| default: '8.2' | ||
| required: false | ||
| type: string | ||
| ARCHIVE_NAME: | ||
| description: The name of the zip archive (falls back to the repository name). | ||
| default: '' | ||
| required: false | ||
| type: string | ||
| PLUGIN_MAIN_FILE: | ||
| description: The name of the main plugin file. | ||
| required: false | ||
| default: 'index.php' | ||
| type: string | ||
| PLUGIN_FOLDER_NAME: | ||
| description: The name of the plugin folder (falls back to the archive name, if set, or the repository name). | ||
| required: false | ||
| default: '' | ||
| type: string | ||
| PLUGIN_VERSION: | ||
| description: The new plugin version. | ||
| required: true | ||
| type: string | ||
| PRE_SCRIPT: | ||
| description: Run custom shell code before creating the release archive. | ||
| default: '' | ||
| required: false | ||
| type: string | ||
| COMPILE_ASSETS_ARGS: | ||
| description: Set of arguments passed to Composer Asset Compiler. | ||
| default: '-v --env=root' | ||
| required: false | ||
| type: string | ||
| secrets: | ||
| COMPOSER_AUTH_JSON: | ||
| description: Authentication for privately hosted packages and repositories as a JSON formatted object. | ||
| required: false | ||
| NPM_REGISTRY_TOKEN: | ||
| description: Authentication for the private npm registry. | ||
| required: false | ||
| ENV_VARS: | ||
| description: Additional environment variables as a JSON formatted object. | ||
| required: false | ||
| outputs: | ||
| artifact: | ||
| description: The name of the generated release artifact | ||
| value: ${{ jobs.create-plugin-archive.outputs.artifact }} | ||
| jobs: | ||
| checkout-dependencies: | ||
| name: Install production dependencies | ||
| timeout-minutes: 5 | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| artifact: ${{ steps.set-artifact-name.outputs.artifact }} | ||
| env: | ||
| ENV_VARS: ${{ secrets.ENV_VARS }} | ||
| # Disables symlinking of local path repositories. | ||
| # During development, symlinking is preferable. | ||
| # In resulting builds, you will likely want to ship the actual install location and remove the source directory. | ||
| COMPOSER_MIRROR_PATH_REPOS: 1 | ||
| steps: | ||
| - name: Deprecation warning | ||
| run: echo "::warning::This workflow is deprecated and will be removed soon. Use .github/workflows/build-push.yml instead." | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Set up custom environment variables | ||
| if: ${{ env.ENV_VARS }} | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| JSON | ||
| .parse(process.env.ENV_VARS) | ||
| .forEach(envVar => core.exportVariable(envVar.name, envVar.value)); | ||
| - name: Set up PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: ${{ inputs.PHP_VERSION }} | ||
| tools: wp-cli | ||
| - name: Install Composer dependencies without dev dependencies | ||
| uses: ramsey/composer-install@v3 | ||
| env: | ||
| COMPOSER_AUTH: '${{ secrets.COMPOSER_AUTH_JSON }}' | ||
| with: | ||
| composer-options: ${{ inputs.COMPOSER_ARGS }} | ||
| - name: Set artifact name | ||
| id: set-artifact-name | ||
| run: echo "artifact=interim-deps" >> $GITHUB_OUTPUT | ||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ steps.set-artifact-name.outputs.artifact }} | ||
| path: | | ||
| ./* | ||
| !./.git | ||
| !./.ddev | ||
| !./.github | ||
| include-hidden-files: true | ||
| run-build-tools: | ||
| name: Process build steps | ||
| timeout-minutes: 10 | ||
| runs-on: ubuntu-latest | ||
| needs: checkout-dependencies | ||
| env: | ||
| NODE_CACHE_MODE: '' | ||
| outputs: | ||
| artifact: ${{ steps.set-artifact-name.outputs.artifact }} | ||
| steps: | ||
| - name: PACKAGE_MANAGER deprecation warning | ||
| if: ${{ inputs.PACKAGE_MANAGER != '' }} | ||
| run: | | ||
| if [ "${{ inputs.PACKAGE_MANAGER }}" == 'npm' ]; then | ||
| echo "::warning::The PACKAGE_MANAGER input is deprecated and will be removed soon. Please remove it. The workflow already uses npm by default." | ||
| else | ||
| echo "::warning::The PACKAGE_MANAGER input is deprecated and will be removed soon. Please update your workflow to use npm." | ||
| fi | ||
| - name: Download Artifact | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: ${{ needs.checkout-dependencies.outputs.artifact }} | ||
| - name: Set up PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: ${{ inputs.PHP_VERSION_BUILD }} | ||
| tools: rector, php-scoper, sniccowp/php-scoper-wordpress-excludes, composer/installers, inpsyde/composer-assets-compiler, inpsyde/wp-translation-downloader | ||
| - name: Set up node cache mode | ||
| run: | | ||
| if [ "${{ inputs.PACKAGE_MANAGER }}" == 'npm' ] && { [ -f "${GITHUB_WORKSPACE}/package-lock.json" ] || [ -f "${GITHUB_WORKSPACE}/npm-shrinkwrap.json" ]; }; then | ||
| echo "NODE_CACHE_MODE=npm" >> $GITHUB_ENV | ||
| elif [ "${{ inputs.PACKAGE_MANAGER }}" == 'yarn' ] && [ -f "${GITHUB_WORKSPACE}/yarn.lock" ]; then | ||
| echo "NODE_CACHE_MODE=yarn" >> $GITHUB_ENV | ||
| else | ||
| echo "No lock files found or unknown package manager" | ||
| fi | ||
| - name: Set up node | ||
| uses: actions/setup-node@v4 | ||
| env: | ||
| NODE_OPTIONS: ${{ inputs.NODE_OPTIONS }} | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} | ||
| with: | ||
| node-version: ${{ inputs.NODE_VERSION }} | ||
| registry-url: ${{ inputs.NPM_REGISTRY_DOMAIN }} | ||
| cache: ${{ env.NODE_CACHE_MODE }} | ||
| - name: Run Composer Asset Compiler | ||
| run: | | ||
| composer compile-assets ${{ inputs.COMPILE_ASSETS_ARGS }} | ||
| - name: Run WordPress Translation Downloader | ||
| run: | | ||
| composer wp-translation-downloader:download | ||
| - name: Run Rector | ||
| if: ${{ hashFiles('rector.php') != '' }} | ||
| run: | | ||
| rector | ||
| - name: Run PHP-Scoper ensuring isolated file autoloading | ||
| if: ${{ hashFiles('scoper.inc.php') != '' }} | ||
| run: | | ||
| php-scoper add-prefix --force --output-dir=build | ||
| composer --working-dir=build dump-autoload -o | ||
| # Appends the Git commit SHA to the Composer autoload cache key to ensure unique identification for prefixed files. | ||
| # Prevents Composer from skipping autoloaded files due to hash collisions based on relative paths. | ||
| sed -i "s/'__composer_autoload_files'/\'__composer_autoload_files_${{ github.sha }}'/g" "build/vendor/composer/autoload_real.php" | ||
| - name: Move code to the `build/` directory | ||
| if: ${{ hashFiles('scoper.inc.php') == '' }} | ||
| run: | | ||
| shopt -s extglob dotglob | ||
| mkdir build | ||
| mv !(build) build | ||
| - name: Set artifact name | ||
| id: set-artifact-name | ||
| run: echo "artifact=interim-built" >> $GITHUB_OUTPUT | ||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ steps.set-artifact-name.outputs.artifact }} | ||
| path: | | ||
| build/ | ||
| !build/**/node_modules | ||
| include-hidden-files: true | ||
| create-plugin-archive: | ||
| name: Create build archive | ||
| timeout-minutes: 5 | ||
| runs-on: ubuntu-latest | ||
| needs: run-build-tools | ||
| env: | ||
| ARCHIVE_NAME: ${{ inputs.ARCHIVE_NAME }} | ||
| PLUGIN_FOLDER_NAME: ${{ inputs.PLUGIN_FOLDER_NAME }} | ||
| GIT_SHA: ${{ github.sha }} | ||
| PLUGIN_VERSION: ${{ inputs.PLUGIN_VERSION }} | ||
| outputs: | ||
| artifact: ${{ steps.set-artifact-name.outputs.artifact }} | ||
| steps: | ||
| - name: Download Artifact | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: ${{ needs.run-build-tools.outputs.artifact }} | ||
| - name: Set up plugin folder name | ||
| id: plugin-folder-name | ||
| run: echo "plugin-folder-name=${PLUGIN_FOLDER_NAME:-${ARCHIVE_NAME:-${{ github.event.repository.name }}}}" >> $GITHUB_OUTPUT | ||
| - name: Set up archive name | ||
| id: plugin-data | ||
| run: echo "archive-name=${ARCHIVE_NAME:-${{ github.event.repository.name }}}" >> $GITHUB_OUTPUT | ||
| - name: Add commit hash to plugin header | ||
| run: 'sed -Ei "s/SHA: .*/SHA: ${GIT_SHA}/g" ${{ inputs.PLUGIN_MAIN_FILE }}' | ||
| - name: Set plugin version header | ||
| run: 'sed -Ei "s/Version: .*/Version: ${PLUGIN_VERSION}/g" ${{ inputs.PLUGIN_MAIN_FILE }}' | ||
| - name: Set up PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: ${{ inputs.PHP_VERSION_BUILD }} | ||
| tools: wp-cli | ||
| - name: Install dist-archive command | ||
| run: wp package install wp-cli/dist-archive-command | ||
| - name: Execute custom code before archive creation | ||
| run: | | ||
| ${{ inputs.PRE_SCRIPT }} | ||
| - name: Run WP-CLI command | ||
| run: | | ||
| wp dist-archive . ./archive.zip --plugin-dirname=${{ steps.plugin-folder-name.outputs.plugin-folder-name }} | ||
| # GitHub Action artifacts would otherwise produce a zip within a zip | ||
| - name: Unzip archive to dist/ | ||
| run: unzip archive.zip -d dist | ||
| - name: Set artifact name | ||
| id: set-artifact-name | ||
| run: echo "artifact=${{ steps.plugin-data.outputs.archive-name }}" >> $GITHUB_OUTPUT | ||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ steps.set-artifact-name.outputs.artifact }} | ||
| path: ./dist/* | ||
| include-hidden-files: true | ||