Skip to content

Commit 71628af

Browse files
authored
Add new workflow for post-release updates (#5003)
1 parent 74abe7f commit 71628af

File tree

16 files changed

+502
-273
lines changed

16 files changed

+502
-273
lines changed

.github/actions/build/action.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
name: Build WooCommerce Payments
2-
description: Build WooCommerce Payments
3-
inputs:
1+
name: "Build WooCommerce Payments"
2+
description: "Build WooCommerce Payments"
3+
4+
outputs:
45
release-filename:
56
description: "The name of the release filename"
6-
default: 'woocommerce-payments.zip'
7+
value: ${{ steps.build_plugin.outputs.RELEASE_FILENAME }}
78

89
runs:
910
using: composite
1011
steps:
11-
- name: Build the plugin
12+
- name: "Build the plugin"
13+
id: build_plugin
1214
shell: bash
1315
env:
14-
RELEASE_FILENAME: ${{ inputs.release-filename }}
16+
RELEASE_FILENAME: "woocommerce-payments.zip"
1517
run: |
1618
npm ci
1719
npm run build
@@ -20,3 +22,5 @@ runs:
2022
echo "::error::Failed to create release archive $RELEASE_FILENAME."
2123
exit 1
2224
fi
25+
26+
echo "RELEASE_FILENAME=$RELEASE_FILENAME" >> $GITHUB_OUTPUT

.github/actions/create-branch-tag/action.yml

Lines changed: 0 additions & 74 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: "Create a branch"
2+
description: "Create a branch if the format is correct"
3+
4+
inputs:
5+
version:
6+
description: "The version that the action should use to create the branch (e.g. 4.5.0 or 4.5.0-test-2)"
7+
required: true
8+
is-pre-release:
9+
description: "Whether the action runs in the context of a pre-release (default: true)"
10+
required: true
11+
default: "true"
12+
13+
outputs:
14+
trimmed-version:
15+
description: "The trimmed version"
16+
value: ${{ steps.version_format_check.outputs.trimmed-version }}
17+
branch-name:
18+
description: "The name of the branch created"
19+
value: ${{ steps.create_branch.outputs.BRANCH_NAME }}
20+
21+
runs:
22+
using: composite
23+
steps:
24+
- name: "Check the format of the version provide"
25+
id: version_format_check
26+
uses: ./.github/actions/version-check
27+
with:
28+
version: ${{ inputs.version }}
29+
is-pre-release: ${{ inputs.is-pre-release }}
30+
31+
- name: "Create a branch"
32+
id: create_branch
33+
shell: bash
34+
env:
35+
IS_PRERELEASE: ${{ inputs.is-pre-release }}
36+
VERSION: ${{ steps.version_format_check.outputs.trimmed-version }}
37+
run: |
38+
if ${{ env.IS_PRERELEASE == 'true' }}; then
39+
BRANCH_NAME="testing/$VERSION"
40+
echo "Created branch $BRANCH_NAME." >> $GITHUB_STEP_SUMMARY
41+
else
42+
BRANCH_NAME="release/$VERSION"
43+
echo ":rocket: Created branch $BRANCH_NAME. :rocket:" >> $GITHUB_STEP_SUMMARY
44+
fi
45+
46+
git checkout -b $BRANCH_NAME
47+
git push origin $BRANCH_NAME
48+
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_OUTPUT

.github/actions/create-tag/action.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: "Create a tag"
2+
description: "Create a tag if the format is correct"
3+
4+
inputs:
5+
version:
6+
description: "The version that the action should use to create the tag (e.g. 4.5.0 or 4.5.0-test-2)"
7+
required: true
8+
is-pre-release:
9+
description: "Whether the action runs in the context of a pre-release (default: true)"
10+
required: true
11+
default: "true"
12+
13+
outputs:
14+
trimmed-version:
15+
description: "The trimmed version"
16+
value: ${{ steps.version_format_check.outputs.trimmed-version }}
17+
tag-message:
18+
description: "The tagging message"
19+
value: ${{ steps.create_tag.outputs.TAG_MESSAGE }}
20+
21+
runs:
22+
using: composite
23+
steps:
24+
- name: "Check the format of the version"
25+
id: version_format_check
26+
uses: ./.github/actions/version-check
27+
with:
28+
version: ${{ inputs.version }}
29+
is-pre-release: ${{ inputs.is-pre-release }}
30+
31+
- name: "Create a tag"
32+
id: create_tag
33+
shell: bash
34+
env:
35+
IS_PRERELEASE: ${{ inputs.is-pre-release }}
36+
VERSION: ${{ steps.version_format_check.outputs.trimmed-version }}
37+
run: |
38+
if ${{ env.IS_PRERELEASE == 'true' }}; then
39+
TAG_MESSAGE="Version for testing $VERSION. Not for Production"
40+
echo "Created tag $VERSION." >> $GITHUB_STEP_SUMMARY
41+
else
42+
TAG_MESSAGE="Version $VERSION"
43+
echo ":rocket: Created tag $VERSION. :rocket:" >> $GITHUB_STEP_SUMMARY
44+
fi
45+
46+
git config user.name "${{ github.actor }}"
47+
git config user.email "${{ github.actor }}@users.noreply.github.com"
48+
git tag -a -m "$TAG_MESSAGE" $VERSION
49+
git push origin $VERSION
50+
echo "TAG_MESSAGE=$TAG_MESSAGE" >> $GITHUB_OUTPUT

.github/actions/generate-changelog/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: Generate the changelog for WooCommerce Payments
2-
description: Generate the changelog from the version provided
1+
name: "Generate the changelog for WooCommerce Payments"
2+
description: "Generate the changelog from the version provided"
33

44
inputs:
55
release-version:
@@ -18,7 +18,7 @@ outputs:
1818
runs:
1919
using: composite
2020
steps:
21-
- name: Generate changelog
21+
- name: "Generate changelog"
2222
id: get_changelog
2323
shell: bash
2424
env:

.github/actions/setup-repo/action.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
name: Setup WooCommerce Payments repository
2-
description: Handles the installation, building, and caching of the projects within the repository.
1+
name: "Setup WooCommerce Payments repository"
2+
description: "Handles the installation, building, and caching of the projects within the repository."
33

44
inputs:
55
php-version:
6-
description: The version of PHP that the action should set up.
6+
description: "The version of PHP that the action should set up."
77
default: "7.4"
88

99
runs:
1010
using: composite
1111
steps:
12-
- name: Enable composer dependencies caching
13-
uses: actions/cache@v3
14-
with:
15-
path: ~/.cache/composer/
16-
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
17-
18-
- name: Setup Node
12+
- name: "Setup Node"
1913
uses: actions/setup-node@v3
2014
with:
2115
node-version-file: '.nvmrc'
2216
cache: 'npm'
2317

24-
- name: Setup PHP
18+
- name: "Enable composer dependencies caching"
19+
uses: actions/cache@v3
20+
with:
21+
path: ~/.cache/composer/
22+
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
23+
24+
- name: "Setup PHP"
2525
uses: shivammathur/setup-php@v2
2626
with:
2727
php-version: ${{ inputs.php-version }}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: "Trigger translations"
2+
description: "Triggers translations update on GlotPress."
3+
4+
inputs:
5+
release-version:
6+
description: "The release version (e.g. 4.5.0)."
7+
required: true
8+
glotpress-url:
9+
description: "The GlotPress import URL to use."
10+
required: true
11+
12+
runs:
13+
using: composite
14+
steps:
15+
- name: "Request the translations update"
16+
env:
17+
GLOTPRESS_IMPORT_URL: ${{ inputs.glotpress-url }}
18+
VERSION: ${{ inputs.release-version }}
19+
shell: bash
20+
run: |
21+
CURL_RESPONSE=$(curl --request POST \
22+
--url "$GLOTPRESS_IMPORT_URL/$VERSION" \
23+
--silent \
24+
--write-out "\n%{http_code}\n" )
25+
HTTP_CODE=$(echo "$CURL_RESPONSE" | tail -n 1)
26+
CURL_RESPONSE=$(echo "$CURL_RESPONSE" | head -n -1)
27+
28+
if [[ ${HTTP_CODE} -lt 200 || ${HTTP_CODE} -gt 299 ]]; then
29+
echo "$CURL_RESPONSE"
30+
echo "::error::Couldn't trigger translations."
31+
exit 1
32+
fi
33+
echo "Translations update triggered."
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: "Check the format of a version"
2+
description: "Checks the format of a version, whether that is a pre-release or release context"
3+
4+
inputs:
5+
version:
6+
description: "The version that the action should check (e.g. 4.5.0 or 4.5.0-test-2)"
7+
required: true
8+
is-pre-release:
9+
description: "Whether the action runs in the context of a pre-release (default: true)"
10+
required: true
11+
default: "true"
12+
13+
outputs:
14+
trimmed-version:
15+
description: "The trimmed version"
16+
value: ${{ steps.version_format_check.outputs.VERSION }}
17+
18+
runs:
19+
using: composite
20+
steps:
21+
- name: "Check the format of the version"
22+
id: version_format_check
23+
shell: bash
24+
env:
25+
IS_PRERELEASE: ${{ inputs.is-pre-release }}
26+
VERSION: ${{ inputs.version }}
27+
run: |
28+
# Trim leading and ending whitespaces
29+
TRIMMED_VERSION=$(echo "$VERSION" | xargs)
30+
31+
if ${{ env.IS_PRERELEASE == 'true' }}; then
32+
VERSION_FORMAT="^[0-9]\.[0-9]\.[0-9]-test-[1-9]$"
33+
else
34+
VERSION_FORMAT="^[0-9]\.[0-9]\.[0-9]$"
35+
fi
36+
37+
if [[ $TRIMMED_VERSION =~ $VERSION_FORMAT ]]; then
38+
echo "VERSION=$TRIMMED_VERSION" >> $GITHUB_OUTPUT
39+
else
40+
echo "::error::The version provided doesn't respect the format expected (version: $TRIMMED_VERSION; format: $VERSION_FORMAT)."
41+
exit 1
42+
fi

.github/workflows/build-zip-file.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
11
name: "Build zip file"
22

3-
# This action will run when it is triggered manually
3+
# This action will run when a pull request targeting `trunk` is closed/merged or when it is triggered manually.
44
on:
5+
pull_request_target:
6+
branches:
7+
- 'trunk'
8+
types:
9+
- closed
510
workflow_dispatch:
611

712
jobs:
13+
# The job runs only if the workflow was triggered manually or if it was triggered by a PR targeting trunk which was merged
814
build-zip:
9-
name: Build the zip file
15+
name: "Build the zip file"
16+
if: ${{ github.event_name != 'pull_request_target' || startsWith(github.head_ref, 'release/') && github.event.pull_request.merged == true }}
1017
runs-on: ubuntu-20.04
1118
steps:
12-
- name: Checkout repository
19+
- name: "Checkout repository"
1320
uses: actions/checkout@v3
1421

15-
- name: Setup Node and PHP with cache
22+
- name: "Set up repository"
1623
uses: ./.github/actions/setup-repo
1724

18-
- name: Build the plugin
25+
- name: "Build the plugin"
26+
id: build_plugin
1927
uses: ./.github/actions/build
2028

21-
- name: Upload the zip file as an artifact
29+
- name: "Upload the zip file as an artifact"
2230
uses: actions/upload-artifact@v3
2331
env:
2432
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2533
with:
26-
name: woocommerce-payments
27-
path: 'woocommerce-payments.zip'
34+
name: "woocommerce-payments"
35+
path: ${{ steps.build_plugin.outputs.release-filename }}
2836
retention-days: 7

0 commit comments

Comments
 (0)