Publish new composer packages and phar files #2
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: Publish new composer packages and phar files | |
on: | |
workflow_dispatch: | |
inputs: | |
bump: | |
description: 'Version bump type (patch, minor, major)' | |
required: true | |
default: 'patch' | |
type: choice | |
options: | |
- patch | |
- minor | |
- major | |
jobs: | |
release-composer-packages: | |
runs-on: ubuntu-latest | |
environment: composer_deploy | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.2' | |
- name: Install Composer dependencies | |
run: composer install --no-interaction --prefer-dist | |
- name: Install Monorepo Builder | |
run: composer global require symplify/monorepo-builder:^12.2 | |
- name: Configure Git user | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '22' | |
- name: Determine next version | |
id: semver | |
run: | | |
last="$(git tag --list 'v[0-9]*' --sort=-version:refname | head -n 1 || echo 'v0.1.0')" | |
bump="${{ github.event.inputs.bump }}" | |
case "$bump" in | |
patch|minor|major) inc="$bump" ;; | |
*) echo "Invalid bump: $bump" ; exit 1 ;; | |
esac | |
new="$(npx -y semver -i "$inc" "$last")" | |
new="${new#v}" | |
echo "new_version=$new" >> "$GITHUB_OUTPUT" | |
- name: Prepare VERSION file | |
run: | | |
echo "${{ steps.semver.outputs.new_version }}" > VERSION | |
git add VERSION | |
git commit -m "chore(release): record version v${{ steps.semver.outputs.new_version }}" | |
- name: Run MonorepoBuilder release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
$(composer global config bin-dir --absolute)/monorepo-builder release v${{ steps.semver.outputs.new_version }} | |
- name: Ensure GitHub CLI and jq are installed | |
run: | | |
if ! command -v gh >/dev/null 2>&1; then | |
sudo apt-get update | |
sudo apt-get install -y gh jq | |
else | |
gh --version | |
jq --version || (sudo apt-get update && sudo apt-get install -y jq) | |
fi | |
- name: Install git-filter-repo | |
run: | | |
python3 -m pip install --user git-filter-repo | |
echo "$HOME/.local/bin" >> $GITHUB_PATH | |
- name: Split code into component repositories | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PACKAGIST_USERNAME: ${{ secrets.PACKAGIST_USERNAME }} | |
PACKAGIST_TOKEN: ${{ secrets.PACKAGIST_TOKEN }} | |
GH_CODESPLIT_EMAIL: ${{ secrets.GH_CODESPLIT_EMAIL }} | |
GH_ORG: ${{ secrets.GH_ORG }} | |
DEFAULT_BRANCH: trunk | |
run: | | |
git config --global user.email ${{ secrets.GH_CODESPLIT_EMAIL }} | |
git config --global user.name "github-actions[bot]" | |
bash bin/split-code.sh | |
build-phar-files: | |
needs: release-composer-packages | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Set up PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.0' # Specify the PHP version you need | |
- name: Install Composer dependencies | |
run: composer install --no-dev --prefer-dist | |
- name: Install Box | |
run: composer global require humbug/box | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '22' | |
- name: Install npm dependencies for static-files-editor | |
run: | | |
cd plugins/static-files-editor | |
npm install | |
- name: Build all components | |
run: bash bin/build-all.sh | |
- name: Fetch tags | |
run: | | |
git fetch --tags --prune --quiet || true | |
- name: Determine latest tag | |
id: tag | |
run: | | |
latest="$(git tag --list 'v[0-9]*' --sort=-version:refname | head -n 1)" | |
if [ -z "$latest" ]; then echo "No version tags found"; exit 1; fi | |
echo "tag=$latest" >> "$GITHUB_OUTPUT" | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.tag.outputs.tag }} | |
release_name: Release ${{ steps.tag.outputs.tag }} | |
draft: false | |
prerelease: false | |
- name: Upload Data Liberation Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./dist/plugins/data-liberation.zip | |
asset_name: data-liberation.zip | |
asset_content_type: application/zip | |
- name: Upload URL Updater Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./dist/plugins/url-updater.zip | |
asset_name: url-updater.zip | |
asset_content_type: application/zip | |
- name: Upload Static Files Editor Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./dist/plugins/static-files-editor.zip | |
asset_name: static-files-editor.zip | |
asset_content_type: application/zip | |
- name: Upload Import Static Files Example Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./dist/examples/create-wp-site.tar.gz | |
asset_name: create-wp-site.tar.gz | |
asset_content_type: application/gzip | |
- name: Upload Blueprints Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./dist/blueprints.phar | |
asset_name: blueprints.phar | |
asset_content_type: application/phar | |
- name: Upload PHP toolkit .phar Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./dist/php-toolkit.phar | |
asset_name: php-toolkit.phar | |
asset_content_type: application/phar | |