Skip to content

1.1.16

1.1.16 #86

Workflow file for this run

name: 'release'
on:
push:
tags: [ '*' ]
jobs:
tests:
runs-on: ubuntu-latest
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
- uses: actions/checkout@v2
id: code-checkout
- name: Validate composer.json and composer.lock
id: composer-validate
run: composer validate
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
id: install-dependencies
uses: php-actions/composer@v5
with:
php_version: 8.0
args: --prefer-dist --no-progress --no-suggest
- name: PHP Unit Test
id: php-unit-test
uses: php-actions/phpunit@v3
with:
php_version: 8.0.27
version: 9.5.21
- uses: act10ns/slack@v1
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#wordpress-bmlt-workflow'
if: failure()
deploy-bmlt-workflow-latest:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
env:
WORDPRESS_USERNAME: ${{ secrets.BMLTWF_WORDPRESS_USERNAME }}
WORDPRESS_PASSWORD: ${{ secrets.BMLTWF_WORDPRESS_PASSWORD }}
BUILD_DIR: build
DIST_DIR_S3: dist/s3
DIST_DIR_GITHUB: dist/github
GITHUB_RELEASE_FILENAME: bmlt-workflow.zip
S3_KEY: bmlt-workflow
PLUGIN: bmlt-workflow
MAINFILE: bmlt-workflow.php
steps:
- uses: actions/checkout@v2
id: code-checkout
- name: Validate composer.json and composer.lock
id: composer-validate
run: composer validate
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
id: install-dependencies
run: composer install --no-dev --prefer-dist --no-progress --no-suggest
- name: Prepare zip file
run: |
export ZIP_FILENAME=${S3_KEY}-build${GITHUB_RUN_NUMBER}-${GITHUB_SHA}.zip
echo "ZIP_FILENAME=${ZIP_FILENAME}" >> $GITHUB_ENV
echo "GITHUB_RELEASE_FILENAME=${GITHUB_RELEASE_FILENAME}" >> $GITHUB_ENV
echo "GITHUB_RELEASE_PATH=${DIST_DIR_GITHUB}/${GITHUB_RELEASE_FILENAME}" >> $GITHUB_ENV
zip -r $ZIP_FILENAME ./ -x "/.git*" -x "*.editorconfig*" -x "/vendor*" -x "/mockoon/*" -x "composer.*" -x "*.github*" -x "/assets*" -x "*.gitattributes" -x "/node_modules/*" -x "/tests/*" -x ".userdetails.sh" -x ".phpunit.result.cache" -x "*.DS_Store*" -x "Dockerfile" -x "patchwork.json" -x "/.phpunit.cache*" -x "/docker/*" -x "/.vscode*" -x "phpunit.xml" -x ".testcaferc.js" -x "docker-compose.yml" -x "package.json" -x "package-lock.json" -x "phpunit.xml.orig" -x "config_phpunit.php"
mkdir $BUILD_DIR && mv $ZIP_FILENAME $BUILD_DIR/
mkdir -p $DIST_DIR_S3 && cp $BUILD_DIR/$ZIP_FILENAME $DIST_DIR_S3/$ZIP_FILENAME
mkdir -p $DIST_DIR_GITHUB && cp $BUILD_DIR/$ZIP_FILENAME $DIST_DIR_GITHUB/$GITHUB_RELEASE_FILENAME
curl -LO https://raw.githubusercontent.com/bmlt-enabled/bmlt-wordpress-deploy/master/deploy-wordpress.sh
chmod +x deploy-wordpress.sh
curl -sLO https://raw.githubusercontent.com/bmlt-enabled/release-notes-tool/master/gh-release-notes.sh
chmod +x gh-release-notes.sh
./gh-release-notes.sh CHANGELOG.md "##"
- name: Prepare artifact metadata
id: prepare_artifact_metadata
run: |
echo ::set-output name=ARTIFACT_PATH::./${GITHUB_RELEASE_PATH}
echo ::set-output name=ARTIFACT_NAME::${GITHUB_RELEASE_FILENAME}
- name: Release beta
if: contains(github.ref, 'beta')
id: beta_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
prerelease: true
draft: false
- name: Upload Beta Asset
if: contains(github.ref, 'beta')
id: beta-release-asset-wp
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.beta_release.outputs.upload_url }}
asset_path: ${{ steps.prepare_artifact_metadata.outputs.ARTIFACT_PATH }}
asset_name: ${{ steps.prepare_artifact_metadata.outputs.ARTIFACT_NAME }}
asset_content_type: application/zip
- name: Release stable
if: "!contains(github.ref, 'beta')"
id: stable_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body_path: "changelog.txt"
prerelease: false
draft: false
- name: Upload Stable Asset WP
if: "!contains(github.ref, 'beta')"
id: stable-release-asset-wp
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.stable_release.outputs.upload_url }}
asset_path: ${{ steps.prepare_artifact_metadata.outputs.ARTIFACT_PATH }}
asset_name: ${{ steps.prepare_artifact_metadata.outputs.ARTIFACT_NAME }}
asset_content_type: application/zip
- name: Publish Release to WP
if: "!contains(github.ref, 'beta')"
id: publish-release-wp
run: |
./deploy-wordpress.sh
- uses: act10ns/slack@v1
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#wordpress-bmlt-workflow'
if: failure()