Release JS Packages: Execute script from GH Action (#33614)

This commit is contained in:
Paul Sealock 2022-06-29 13:41:43 +12:00 committed by GitHub
parent 00f4e9fa73
commit f20d109164
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 20 deletions

View File

@ -3,13 +3,60 @@ on:
workflow_dispatch:
inputs:
packages:
description: 'Enter a specific package to release, or releases separated by commas, ie @woocommerce/components,@woocommerce/number. Leaving this input blank will prepare to release all eligible packages.'
description: 'Enter a specific package to release, or packages separated by commas, ie @woocommerce/components,@woocommerce/number. Leaving this input to the default "-a" will prepare to release all eligible packages.'
required: false
default: '-a'
jobs:
prepare:
name: Run the prepare script
name: Run prepare script
runs-on: ubuntu-20.04
steps:
- name: Run
run: echo "hello world"
- uses: actions/checkout@v3
- uses: ./.github/actions/cache-deps
with:
workflow_name: prepare-package-release
workflow_cache: ${{ secrets.WORKFLOW_CACHE }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
- name: Install PNPM
run: npm install -g pnpm@^6.24.2
- name: Install dependencies
run: pnpm install
- name: Execute script
run: ./tools/package-release/bin/dev prepare ${{ github.event.inputs.packages }}
- name: Print git status
run: git status
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Set all package string
id: all_description
if: ${{ github.event.inputs.packages == '-a'}}
run: echo "::set-output name=str::all packages"
- name: Set Specific packages string
id: specific_description
if: ${{ github.event.inputs.packages != '-a'}}
run: echo "::set-output name=str::${{ github.event.inputs.packages }}"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'Automated change: Prep ${{ steps.all_description.outputs.str || steps.specific_description.outputs.str }} for release.'
branch: release/packages-${{ steps.date.outputs.date }}
delete-branch: true
title: Prepare Packages for Release
reviewers: ${{ github.actor }}
body: |
# Prepare ${{ steps.all_description.outputs.str || steps.specific_description.outputs.str }} for release.
This PR has been autogenerated by [Prepare Package Release workflow](https://github.com/woocommerce/woocommerce/actions/workflows/prepare-package-release.yml) in run [${{ github.run_id }}](https://github.com/woocommerce/woocommerce/actions/runs/${{ github.run_id }})

View File

@ -81,8 +81,7 @@ class Formatter extends KeepAChangelogParser {
}
$release_url = '';
if ( 0 === stripos( $path[1], 'packages/js/' ) ) {
if ( strpos( $path[1], 'packages/js/' ) !== false ) {
$package = substr( $path[1], 12 );
$release_url ='https://www.npmjs.com/package/@woocommerce/' . $package . '/v/';
} else if ( 'plugins/woocommerce' === $path[1] ) {

View File

@ -24,10 +24,9 @@ export const getNextVersion = ( name: string ) => {
encoding: 'utf-8',
} ).trim();
} catch ( e ) {
let message = '';
if ( e instanceof Error ) {
message = e.message;
throw new Error( message );
console.log( e );
throw e;
}
}
};
@ -46,10 +45,9 @@ export const validateChangelogEntries = ( name: string ) => {
encoding: 'utf-8',
} );
} catch ( e ) {
let message = '';
if ( e instanceof Error ) {
message = e.message;
throw new Error( message );
console.log( e );
throw e;
}
}
};
@ -67,12 +65,9 @@ export const writeChangelog = ( name: string ) => {
encoding: 'utf-8',
} );
} catch ( e ) {
let message = '';
if ( e instanceof Error ) {
message = e.message;
throw new Error(
message + ' - Package may not have changelog entries.'
);
console.log( e );
throw e;
}
}
};
@ -98,10 +93,9 @@ export const hasChangelogs = ( name: string ): boolean | void => {
.length > 0
);
} catch ( e ) {
let message = '';
if ( e instanceof Error ) {
message = e.message;
throw new Error( message );
console.log( e );
throw e;
}
}
};