From 85b2b25c3122462e63e6756922cad8a08e5a997c Mon Sep 17 00:00:00 2001 From: Noah Mason Date: Tue, 4 Jun 2024 17:51:44 -0400 Subject: [PATCH 1/5] Adds a test workflow. --- .github/workflows/test.yml | 74 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .github/workflows/test.yml 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 .. From f32e2b631f23443e76543f8c8be307a2a0ac2a0b Mon Sep 17 00:00:00 2001 From: Noah Mason Date: Tue, 4 Jun 2024 17:52:09 -0400 Subject: [PATCH 2/5] Fixes PHP_VERSION env in package release action. --- package/.github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 2348cad3b92450c269e6d00bf07503724cc1a5fb Mon Sep 17 00:00:00 2001 From: Noah Mason Date: Tue, 4 Jun 2024 17:52:48 -0400 Subject: [PATCH 3/5] Triggers release when on branch master and successful test run is detected. --- .github/workflows/release.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ac872e5..3dc860c 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: From db47c4c18ea57d2d15f4730503e240528cdd2e07 Mon Sep 17 00:00:00 2001 From: Noah Mason Date: Tue, 4 Jun 2024 17:53:06 -0400 Subject: [PATCH 4/5] 4.2.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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", From b54f010e1bf8ace5b049b2f5df88b11cffcd950e Mon Sep 17 00:00:00 2001 From: Noah Mason Date: Tue, 4 Jun 2024 17:55:37 -0400 Subject: [PATCH 5/5] Removes unnecessary quotes from test workflow name. --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3dc860c..b3cd23c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: Release on: workflow_run: - workflows: ["test"] + workflows: [test] types: - completed