Skip to content

Commit

Permalink
Merge pull request #119 from woocommerce/update/108-nodejs-v20-github…
Browse files Browse the repository at this point in the history
…-actions-get-plugin-releases

Upgrade the `get-plugin-releases` action to use Node.js v20
  • Loading branch information
eason9487 authored Apr 26, 2024
2 parents 03d3867 + 223f04a commit 87914e7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
10 changes: 5 additions & 5 deletions packages/github-actions/actions/get-plugin-releases/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,33 @@ jobs:
steps:
- name: Get Release versions from WooCommerce
id: wc-versions
uses: woocommerce/grow/get-plugin-releases@actions-v1
uses: woocommerce/grow/get-plugin-releases@actions-v2
with:
slug: woocommerce

- name: Get Release versions from WordPress
id: wp-versions
uses: woocommerce/grow/get-plugin-releases@actions-v1
uses: woocommerce/grow/get-plugin-releases@actions-v2
with:
slug: wordpress

- name: Get Release versions from GLA
id: gla-versions
uses: woocommerce/grow/get-plugin-releases@actions-v1
uses: woocommerce/grow/get-plugin-releases@actions-v2
with:
slug: google-listings-and-ads

- name: Get L-3 Release versions from WC including RC
id: wc-versions-l3-rc
uses: woocommerce/grow/get-plugin-releases@actions-v1
uses: woocommerce/grow/get-plugin-releases@actions-v2
with:
slug: woocommerce
releases: 4
includeRC: true

- name: Get L-2 Release versions from WC including patches
id: wc-versions-patches
uses: woocommerce/grow/get-plugin-releases@actions-v1
uses: woocommerce/grow/get-plugin-releases@actions-v2
with:
slug: woocommerce
includePatches: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ outputs:
description: The versions array in the format ["7.4","7.5","7.6"]

runs:
using: node16
using: node20
main: get-plugin-releases.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import core from '@actions/core';
/**
* Internal dependencies
*/
import handleActionErrors from '../../../utils/handle-action-errors';
import handleActionErrors from '../../../utils/handle-action-errors.js';

async function getPluginReleases() {
const slug = getInput( 'slug' );
const apiEndpoint = getAPIEndpoint( slug );
async function getPluginReleases( inputs ) {
const apiEndpoint = getAPIEndpoint( inputs.slug );

return fetch( apiEndpoint )
.then( ( res ) => res.json() )
.then( parsePluginVersions );
.then( ( data ) => parsePluginVersions( data, inputs ) );
}

function getAPIEndpoint( slug ) {
Expand Down Expand Up @@ -43,12 +42,8 @@ function setOutput( key, value ) {
core.setOutput( key, value );
}

function parsePluginVersions( releases = {} ) {
const slug = getInput( 'slug' );
const numberOfReleases = parseInt( getInput( 'releases' ), 10 );
const includeRC = getInput( 'includeRC' );
const includePatches = getInput( 'includePatches' );

function parsePluginVersions( releases = {}, inputs ) {
const { slug, numberOfReleases, includeRC, includePatches } = inputs;
const output = [];

if ( slug !== 'wordpress' ) {
Expand Down Expand Up @@ -135,6 +130,16 @@ function semverCompare( a, b ) {
);
}

getPluginReleases()
.then( () => core.info( 'Finish getting the release versions.' ) )
.catch( handleActionErrors );
// Directly perform this action if it's running in GitHub Actions.
if ( process.env.GITHUB_ACTIONS ) {
const inputs = {
slug: getInput( 'slug' ),
numberOfReleases: parseInt( getInput( 'releases' ), 10 ),
includeRC: getInput( 'includeRC' ),
includePatches: getInput( 'includePatches' ),
};

getPluginReleases( inputs )
.then( () => core.info( 'Finish getting the release versions.' ) )
.catch( handleActionErrors );
}

0 comments on commit 87914e7

Please sign in to comment.