82 lines
2.9 KiB
YAML
82 lines
2.9 KiB
YAML
name: Pre build step - Compile changelog file
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: 'Version override. Default version is fetched from the base branch name, you can override the version but make sure the that the branch release/{version} exists on remote. Format: X.Y (Major.Minor)'
|
|
required: false
|
|
default: ''
|
|
|
|
env:
|
|
GIT_COMMITTER_NAME: 'WooCommerce Bot'
|
|
GIT_COMMITTER_EMAIL: 'no-reply@woocommerce.com'
|
|
GIT_AUTHOR_NAME: 'WooCommerce Bot'
|
|
GIT_AUTHOR_EMAIL: 'no-reply@woocommerce.com'
|
|
|
|
jobs:
|
|
build-prep:
|
|
name: Create changelog PR
|
|
runs-on: ubuntu-20.04
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
steps:
|
|
- name: Get version from the branch name workflow is running on
|
|
if: ${{ github.event.inputs.version == '' }}
|
|
uses: actions/github-script@v7
|
|
id: extract-version
|
|
with:
|
|
script: |
|
|
const refName = process.env.GITHUB_REF_NAME;
|
|
const versionMatch = refName.match(/^release\/(\d+\.\d+)$/);
|
|
if (versionMatch) {
|
|
const version = versionMatch[1];
|
|
console.log(`Extracted version: ${version}`);
|
|
core.setOutput('version', version);
|
|
} else {
|
|
core.setFailed(`Branch name ${refName} does not match the expected pattern 'release/x.y'`);
|
|
process.exit(1);
|
|
}
|
|
|
|
- name: Validate version input override
|
|
if: ${{ github.event.inputs.version != '' }}
|
|
uses: actions/github-script@v7
|
|
env:
|
|
VERSION: ${{ github.event.inputs.version }}
|
|
with:
|
|
script: |
|
|
const version = process.env.VERSION;
|
|
if (!/^\d+\.\d+$/.test(version)) {
|
|
core.setFailed('Invalid version format. The version must be in the format X.Y');
|
|
core.info(`Version you entered: ${version}`);
|
|
process.exit(1);
|
|
}
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup PNPM
|
|
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
|
|
with:
|
|
node-version-file: .nvmrc
|
|
cache: pnpm
|
|
registry-url: 'https://registry.npmjs.org'
|
|
|
|
- name: Install prerequisites
|
|
run: |
|
|
pnpm install --filter monorepo-utils --ignore-scripts
|
|
# ignore scripts speeds up setup signficantly, but we still need to build monorepo utils
|
|
pnpm build
|
|
working-directory: tools/monorepo-utils
|
|
|
|
- name: Generate changelog changes and create PR
|
|
id: changelog
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: pnpm utils code-freeze changelog -o ${{ github.repository_owner }} -v ${{ github.event.inputs.version || steps.extract-version.outputs.version }}
|