Skip to content

Update PHP version in GitHub Workflow #21

Update PHP version in GitHub Workflow

Update PHP version in GitHub Workflow #21

Workflow file for this run

name: CI
on:
push:
tags:
- '*'
jobs:
call-install-deps:
if: github.repository != 'JUVOJustin/wordpress-plugin-boilerplate' # This line is save to be deleted. It's only here to prevent the workflow from running on the boilerplate repository.
uses: ./.github/workflows/install-deps.yml
with:
mode: 'prod'
secrets: inherit
build:
if: github.repository != 'JUVOJustin/wordpress-plugin-boilerplate' # This line is save to be deleted. It's only here to prevent the workflow from running on the boilerplate repository.
runs-on: ubuntu-latest
needs: call-install-deps
permissions:
contents: write
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- uses: actions/setup-node@v2.1.4
- name: Restore Cache
uses: actions/cache/restore@v4
with:
path: |
vendor
node_modules
dist
key: deps-prod-${{ hashFiles('composer.lock') }}-${{ hashFiles('package-lock.json') }}
fail-on-cache-miss: true
id: cache
- name: Clean up development files (Prod)
run: |
find . -name "composer.json" -type f -delete && find . -name "composer.lock" -type f -delete
find . -name "package.json" -type f -delete && find . -name "package-lock.json" -type f -delete
find . -name "constants.php" && find . -name "README.md"
rm -rf phpunit.xml.dist
rm -rf .git && find . -name ".gitignore" -type f -delete
rm -rf .github
rm -rf tests
rm -rf bin
shell: bash
# Update Version
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Update Version in WordPress files
run: |
sed -i -E "s/(const PLUGIN_VERSION = ')[^']*(';)/\1${{ env.RELEASE_VERSION }}\2/" src/Demo_Plugin.php
sed -i -E 's/([[:blank:]]*\*[[:blank:]]*Version:[[:blank:]]*).*/\1${{ env.RELEASE_VERSION }}/' demo-plugin.php
sed -i -E 's/Stable tag: .*/Stable tag: ${{ env.RELEASE_VERSION }}/' README.txt
- name: Update resources
uses: test-room-7/action-update-file@v1
with:
file-path: |
src/Demo_Plugin.php
demo-plugin.php
README.txt
commit-msg: Update Version in WordPress specific files
github-token: ${{ secrets.GITHUB_TOKEN }}
# Zip everything
- shell: bash
run: |
cd ..
sudo apt-get install zip
zip -r demo-plugin-${{ env.RELEASE_VERSION }}.zip ./*
- name: Release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
omitBodyDuringUpdate: true
artifacts: "../demo-plugin-${{ env.RELEASE_VERSION }}.zip"