164 lines
7.2 KiB
YAML
164 lines
7.2 KiB
YAML
name: "Enforce release code freeze"
|
|
on:
|
|
schedule:
|
|
- cron: '0 16 * * 4' # Run at 1600 UTC on Thursdays.
|
|
workflow_dispatch:
|
|
inputs:
|
|
timeOverride:
|
|
description: "Time Override: The time to use in checking whether the action should run (default: 'now')."
|
|
default: 'now'
|
|
skipSlackPing:
|
|
description: "Skip Slack Ping: If true, the Slack ping will be skipped (useful for testing)"
|
|
type: boolean
|
|
slackChannelOverride:
|
|
description: "Slack Channel Override: The channel ID to send the Slack ping about the freeze"
|
|
|
|
env:
|
|
TIME_OVERRIDE: ${{ inputs.timeOverride }}
|
|
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:
|
|
maybe-create-next-milestone-and-release-branch:
|
|
name: "Maybe create next milestone and release branch"
|
|
runs-on: ubuntu-20.04
|
|
outputs:
|
|
branch: ${{ steps.freeze.outputs.branch }}
|
|
release_version: ${{ steps.freeze.outputs.release_version }}
|
|
next_version: ${{ steps.freeze.outputs.next_version }}
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 100
|
|
|
|
- uses: ./.github/actions/cache-deps
|
|
with:
|
|
workflow_name: release-code-freeze
|
|
workflow_cache: ${{ secrets.WORKFLOW_CACHE }}
|
|
|
|
- name: Install PNPM
|
|
run: npm install -g pnpm@^6.24.2
|
|
|
|
- name: "Install PHP"
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: '7.4'
|
|
tools: composer
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install
|
|
|
|
- name: "Run the script to enforce the code freeze"
|
|
id: freeze
|
|
run: php .github/workflows/scripts/release-code-freeze.php
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
GITHUB_OUTPUTS: 1
|
|
|
|
- name: "Git fetch the newly created release branch"
|
|
run: git fetch origin ${{ steps.freeze.outputs.branch }}
|
|
|
|
- name: "Checkout the release branch"
|
|
run: git checkout ${{ steps.freeze.outputs.branch }}
|
|
|
|
- name: "Create a new branch for the changelog update PR"
|
|
run: git checkout -b ${{ format( 'update/{0}-changelog', steps.freeze.outputs.release_version ) }}
|
|
|
|
- name: "Normalize line-endings in changelog files"
|
|
run: for file in plugins/woocommerce/changelog/*; do echo "$(tr -d '\r' < $file)" > $file; done
|
|
|
|
- name: "Generate the changelog file"
|
|
run: pnpm changelog --filter=woocommerce -- write --add-pr-num -n -vvv --use-version ${{ steps.freeze.outputs.release_version }}
|
|
|
|
- name: "git rm deleted files"
|
|
run: git rm $(git ls-files --deleted)
|
|
|
|
- name: "Commit deletion"
|
|
run: git commit -m "Delete changelog files from ${{ steps.freeze.outputs.release_version }} release"
|
|
|
|
- name: "Remember the deletion commit hash"
|
|
id: rev-parse
|
|
run: echo "::set-output name=hash::$(git rev-parse HEAD)"
|
|
|
|
- name: "Insert NEXT_CHANGELOG contents into changelog and readme"
|
|
run: php .github/workflows/scripts/release-changelog.php
|
|
|
|
- name: "git add changelog and readme files"
|
|
run: git add changelog.txt plugins/woocommerce/readme.txt
|
|
|
|
- name: "Commit changelog and readme files"
|
|
run: git commit -m "Update the changelog and readme files for the ${{ steps.freeeze.outputs.release_version }} release"
|
|
|
|
- name: "Push update branch to origin"
|
|
run: git push origin ${{ format( 'update/{0}-changelog', steps.freeze.outputs.release_version ) }}
|
|
|
|
- name: "Stash any other undesired changes"
|
|
run: git stash
|
|
|
|
- name: "Checkout trunk"
|
|
run: git checkout trunk
|
|
|
|
- name: "Create a branch for the changelog files deletion"
|
|
run: git checkout -b ${{ format( 'delete/{0}-changelog', steps.freeze.outputs.release_version ) }}
|
|
|
|
- name: "Cherry-pick the deletion commit"
|
|
run: git cherry-pick ${{ steps.rev-parse.outputs.hash }}
|
|
|
|
- name: "Push deletion branch to origin"
|
|
run: git push origin ${{ format( 'delete/{0}-changelog', steps.freeze.outputs.release_version ) }}
|
|
|
|
- name: "Create release branch PR"
|
|
id: release-pr
|
|
uses: actions/github-script@v6
|
|
with:
|
|
script: |
|
|
const result = await github.rest.pulls.create( {
|
|
owner: "${{ github.repository_owner }}",
|
|
repo: "${{ github.event.repository.name }}",
|
|
head: "${{ format( 'update/{0}-changelog', steps.freeze.outputs.release_version ) }}",
|
|
base: "${{ steps.freeze.outputs.branch }}",
|
|
title: "${{ format( 'Release: Prepare the changelog for {0}', steps.freeze.outputs.release_version ) }}",
|
|
body: "${{ format( 'This pull request was automatically generated during the code freeze to prepare the changelog for {0}', steps.freeze.outputs.release_version ) }}"
|
|
} );
|
|
|
|
return result.data.number;
|
|
|
|
- run: echo '${{ steps.release-pr.outputs.result }}'
|
|
|
|
- name: "Create trunk PR"
|
|
id: trunk-pr
|
|
uses: actions/github-script@v6
|
|
with:
|
|
script: |
|
|
const result = await github.rest.pulls.create( {
|
|
owner: "${{ github.repository_owner }}",
|
|
repo: "${{ github.event.repository.name }}",
|
|
head: "${{ format( 'delete/{0}-changelog', steps.freeze.outputs.release_version ) }}",
|
|
base: "trunk",
|
|
title: "${{ format( 'Release: Remove {0} change files', steps.freeze.outputs.release_version ) }}",
|
|
body: "${{ format( 'This pull request was automatically generated during the code freeze to remove the changefiles from {0} that are compiled into the `{1}` branch via #{2}', steps.freeze.outputs.release_version, steps.freeze.outputs.branch, steps.release-pr.outputs.result ) }}"
|
|
} );
|
|
|
|
return result.data.number;
|
|
|
|
|
|
notify-slack:
|
|
name: "Sends code freeze notification to Slack"
|
|
if: ${{ inputs.skipSlackPing != true }}
|
|
runs-on: ubuntu-20.04
|
|
needs: maybe-create-next-milestone-and-release-branch
|
|
steps:
|
|
- name: Slack
|
|
uses: archive/github-actions-slack@v2.0.0
|
|
id: notify
|
|
with:
|
|
slack-bot-user-oauth-access-token: ${{ secrets.CODE_FREEZE_BOT_TOKEN }}
|
|
slack-channel: ${{ inputs.slackChannelOverride || secrets.WOO_RELEASE_SLACK_CHANNEL }}
|
|
slack-text: |
|
|
:warning-8c: ${{ needs.maybe-create-next-milestone-and-release-branch.outputs.release_version }} Code Freeze :ice_cube:
|
|
|
|
The automation to cut the release branch for ${{ needs.maybe-create-next-milestone-and-release-branch.outputs.release_version }} has run. Any PRs that were not already merged will be a part of ${{ needs.maybe-create-next-milestone-and-release-branch.outputs.next_version }} by default. If you have something that needs to make ${{ needs.maybe-create-next-milestone-and-release-branch.outputs.release_version }} that hasn't yet been merged, please see the <${{ secrets.FG_LINK }}/code-freeze-for-woocommerce-core-release/|fieldguide page for the code freeze>.
|