Skip to content

Merge pull request #2764 from gocodebox/dev #39

Merge pull request #2764 from gocodebox/dev

Merge pull request #2764 from gocodebox/dev #39

Workflow file for this run

name: Release Publication and Distribution
on:
workflow_dispatch:
push:
branches:
- trunk
paths:
- 'CHANGELOG.md'
jobs:
check-secrets:
name: "Check for required secrets"
runs-on: ubuntu-latest
outputs:
has-secrets: ${{ steps.check-secrets.outputs.has-secrets }}
steps:
- name: Test secrets
id: check-secrets
run: |
if [ ! -z "${{ secrets.LLMS_COM_API_URL }}" ] && [ ! -z "${{ secrets.LLMS_COM_API_KEY }}" ]; then
echo "::set-output name=has-secrets::true"
fi
update-metadata:
name: "Update product metadata at LifterLMS.com"
runs-on: ubuntu-latest
needs: check-secrets
if: ${{ 'true' == needs.check-secrets.outputs.has-secrets }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '16'
cache: 'npm'
- name: Install Node dependencies
run: npm i @lifterlms/dev
- name: Get metadata
run: |
__LLMS_METADATA=$( ./node_modules/.bin/llms-dev meta parse -f json )
echo __LLMS_PKG_VERSION=$( echo $__LLMS_METADATA | jq --raw-output '.["Version"]' ) >> $GITHUB_ENV
echo __LLMS_WP_VERSION=$( echo $__LLMS_METADATA | jq --raw-output '.["Requires at least"]' ) >> $GITHUB_ENV
echo __LLMS_PHP_VERSION=$( echo $__LLMS_METADATA | jq --raw-output '.["Requires PHP"]' ) >> $GITHUB_ENV
echo __LLMS_LLMS_VERSION=$( echo $__LLMS_METADATA | jq --raw-output '.["LLMS Requires at least"]' ) >> $GITHUB_ENV
- name: Test metadata
run: |
echo "Package version: $__LLMS_PKG_VERSION"
echo "Min WP Version: $__LLMS_WP_VERSION"
echo "Min PHP Version: $__LLMS_PHP_VERSION"
echo "Min LLMS Version: $__LLMS_LLMS_VERSION"
- name: Update metadata
run: |
curl --location --request PATCH "${{ secrets.LLMS_COM_API_URL }}v3/products/${{ github.event.repository.name }}" \
--header "X-API-KEY: ${{ secrets.LLMS_COM_API_KEY }}" \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode "version=$__LLMS_PKG_VERSION" \
--data-urlencode "wp_version=$__LLMS_WP_VERSION" \
--data-urlencode "php_version=$__LLMS_PHP_VERSION" \
--data-urlencode "llms_version=$__LLMS_LLMS_VERSION"