Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update release workflow #543

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 24 additions & 61 deletions .github/workflows/deploy-to-dotorg.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
name: Deploy to WordPress.org

# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
workflow_dispatch:
inputs:
Expand All @@ -13,82 +11,47 @@ on:
- major
- minor
- patch
jobs:
update-google-fonts-json:
if: github.repository_owner == 'WordPress'
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18

# Runs a single command using the runners shell
# This script fetchs the Goolgle Fonts API data and creates a PR if new data is available
- name: Update Google Fonts JSON file
env:
GOOGLE_FONTS_API_KEY: ${{ secrets.GOOGLE_FONTS_API_KEY }}
run: |
echo "Updating Google fonts JSON file"
node ./update-google-fonts-json-file.js
- name: Commit Changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git config --global --add --bool push.autoSetupRemote true
pull_request:
types: [closed]
branches:
- trunk

git diff-index --quiet HEAD -- || \
( git add assets/google-fonts/fallback-fonts-list.json && \
git checkout trunk && \
git commit -m "Automation: update Google Fonts data file" --no-verify && \
git push
)
tag:
name: Checkout repo
jobs:
deploy-to-wordpress:
if: >
github.event_name == 'pull_request' &&
github.event.pull_request.merged == true &&
startsWith(github.event.pull_request.head.ref, 'release/') &&
contains(github.event.pull_request.head.ref, '/major') || contains(github.event.pull_request.head.ref, '/minor') || contains(github.event.pull_request.head.ref, '/patch') &&
(github.event.pull_request.user.login == 'github-actions[bot]')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-node@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install node dependencies
run: npm install

- name: Compile Javascript App
run: npm run build

- name: Update version and changelog
id: update-version
env:
RELEASE_TYPE: ${{ github.event.inputs.release_type }}
run: npm run update-version
- name: Get New Version
id: get-version
run: echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT

- name: Create Release
- name: Create Tag and Release on GitHub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name github-actions
git config user.email [email protected]
git config --global --add --bool push.autoSetupRemote true
git pull
git diff-index --quiet HEAD -- || ( git add package.json package-lock.json readme.txt create-block-theme.php && git commit -m "Version bump & changelog update" --no-verify && git push )
gh release create ${{steps.update-version.outputs.NEW_TAG }} --generate-notes
VERSION=v${{ steps.get-version.outputs.VERSION }}
git tag $VERSION
git push origin $VERSION
gh release create $VERSION --generate-notes

- name: Create Block Theme Plugin Deploy to WordPress.org
- name: Deploy Plugin to WordPress Plugin Directory
uses: 10up/action-wordpress-plugin-deploy@stable
env:
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
VERSION: ${{ steps.update-version.outputs.NEW_VERSION }}
VERSION: ${{ steps.get-version.outputs.VERSION }}

- name: WordPress.org plugin asset/readme update
uses: 10up/action-wordpress-plugin-asset-update@stable
Expand Down
72 changes: 72 additions & 0 deletions .github/workflows/release-new-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Create new release PR

on:
workflow_dispatch:
inputs:
release_type:
description: 'Release type'
required: true
type: choice
options:
- major
- minor
- patch

jobs:
prepare-release:
if: github.event_name == 'workflow_dispatch'
name: Prepare Release PR
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-node@v3
with:
node-version: 18

- name: Install node dependencies
run: npm install

- name: Compile Javascript App
run: npm run build

- name: Create version update branch
id: create-branch
run: |
BRANCH_NAME="release/$(date +%Y-%m-%d)/${{ github.event.inputs.release_type }}-release"
git checkout -b $BRANCH_NAME
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_OUTPUT

- name: Update version and changelog
id: update-version
run: |
npm run update-version
echo "NEW_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
env:
RELEASE_TYPE: ${{ github.event.inputs.release_type }}

- name: Commit changes
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "Version bump & changelog update" --no-verify
git push --set-upstream origin ${{ steps.create-branch.outputs.BRANCH_NAME }}

- name: Create Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create \
--title "[Automation] New ${{ github.event.inputs.release_type }} Release: ${{ steps.update-version.outputs.NEW_VERSION }}" \
--base trunk \
--head ${{ steps.create-branch.outputs.BRANCH_NAME }} \
--label "Release: ${{ github.event.inputs.release_type }}" \
--reviewer "WordPress/block-themers"
--body "
### Release PR 🤖
This is a release PR for version **${{ steps.update-version.outputs.NEW_VERSION }}**, run by **@${{ github.actor }}**.
It updates the version of the Plugin and adds changes since the last tag to the Changelog file.
Merging this PR will trigger a new release and update the Plugin in the WordPress Plugin Directory."
Loading
Loading