diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ac872e5..b3cd23c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,11 +1,14 @@ name: Release on: - push: - branches: [master] + workflow_run: + workflows: [test] + types: + - completed jobs: release: + if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'master' }} runs-on: ubuntu-latest steps: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..8adbd42 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,74 @@ +name: Test + +on: + push: + branches: [master] + +jobs: + release: + runs-on: ubuntu-latest + steps: + + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it. + - name: Checkout Repo + id: checkout_repo + uses: actions/checkout@v4 + + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it. + - name: Enter Theme Directory + id: enter_theme_directory + run: cd package + + # Gets the name from package.json and sets it as an environment variable. + - name: Set Theme Name + id: set_theme_name + run: echo "THEME_NAME=$(jq -r '.name' package.json)" >> $GITHUB_ENV + + # Gets the version from package.json and sets it as an environment variable. + - name: Set Theme Version + id: set_theme_version + run: echo "THEME_VERSION=$(jq -r '.version' package.json)" >> $GITHUB_ENV + + # Gets the PHP version from composer.json and sets it as an environment variable. + - name: Set PHP Version + id: set_php_version + run: echo "PHP_VERSION=$(jq -r '.require.php' composer.json) >> $GITHUB_ENV + + # Gets the Node version from .nvmrc and sets it as an environment variable. + - name: Set Node Version + id: set_node_version + run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_ENV + + # Setup PHP. + - name: Setup PHP + id: setup_php + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ env.PHP_VERSION }} + + # Setup Node. + - name: Setup Node + id: setup_node + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + + # Installs npm and composer dependencies. + - name: Install + id: install + run: npm ci + + # Lint all files. + - name: Lint + id: lint + run: npm run lint + + # Runs a build. + - name: Build + id: build + run: npm run build + + # Return to root. + - name: Return to Root Directory + id: return_to_root_directory + run: cd .. diff --git a/package.json b/package.json index 4402424..dd575eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wp-theme-assets", - "version": "4.2.1", + "version": "4.2.2", "description": "WP Theme Assets", "repository": { "type": "git", diff --git a/package/.github/workflows/release.yml b/package/.github/workflows/release.yml index d406ba1..7d13c05 100644 --- a/package/.github/workflows/release.yml +++ b/package/.github/workflows/release.yml @@ -26,7 +26,7 @@ jobs: # Gets the PHP version from composer.json and sets it as an environment variable. - name: Set PHP Version id: set_php_version - run: echo "PHP_VERSION=$(jq -r '.require["php"]' composer.json) >> $GITHUB_ENV + run: echo "PHP_VERSION=$(jq -r '.require.php' composer.json) >> $GITHUB_ENV # Gets the Node version from .nvmrc and sets it as an environment variable. - name: Set Node Version