Skip to content

Commit 2ebb573

Browse files
authored
Merge pull request #1 from BeAPI/release/1.0.1
feat: sets up automated release workflow
2 parents 2299755 + c810507 commit 2ebb573

15 files changed

+7063
-13
lines changed

.distignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/.git
2+
/.github
3+
/.wordpress-org
4+
/node_modules
5+
/src
6+
7+
.distignore
8+
.editorconfig
9+
.gitattributes
10+
.gitignore
11+
.plugin-data
12+
.wp-env.json
13+
CHANGELOG.md
14+
composer.json
15+
composer.lock
16+
grumphp.yml
17+
LICENSE.md
18+
package.json
19+
package-lock.json
20+
phpcs.xml.dist
21+
phpunit.xml.dist
22+
psalm.xml.dist
23+
README.md
24+
webpack.config.js
25+
yarn.lock

.gitattributes

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/.git export-ignore
2+
/.github export-ignore
3+
/vendor/ export-ignore -diff
4+
/node_modules export-ignore
5+
6+
/.distignore export-ignore
7+
/.editorconfig export-ignore
8+
/.gitattributes export-ignore
9+
/.gitignore export-ignore
10+
/.plugin-data export-ignore
11+
/.wp-env.json export-ignore
12+
/composer.json export-ignore
13+
/composer.lock export-ignore -diff
14+
/grumphp.yml export-ignore
15+
/LICENSE.md export-ignore
16+
/package.json export-ignore
17+
/package-lock.json export-ignore -diff
18+
/phpcs.xml.dist export-ignore
19+
/psalm.xml.dist export-ignore
20+
/README.md export-ignore
21+
/webpack.config.js export-ignore
22+
/yarn.lock export-ignore
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: "Check plugin version and tags"
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
7+
jobs:
8+
version-check:
9+
name: "Check version doesn't not already exists."
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v3
14+
with:
15+
fetch-depth: 0
16+
17+
- id: set-vars
18+
name: "Set variables from .plugin-data file"
19+
run: |
20+
# Get all data from .plugin-data file
21+
content=`cat ./.plugin-data`
22+
# the following lines are only required for multi line json
23+
content="${content//'%'/'%25'}"
24+
content="${content//$'\n'/'%0A'}"
25+
content="${content//$'\r'/'%0D'}"
26+
# end of optional handling for multi line json
27+
echo "::set-output name=pluginData::$content"
28+
29+
- id: version-check
30+
name: "Check version in .plugin-data is not existing"
31+
run: |
32+
# Check version from .plugin-data
33+
VERSION=${{fromJson(steps.set-vars.outputs.pluginData).version}}
34+
35+
if git rev-parse "$VERSION" >/dev/null 2>&1; then
36+
echo "Tag aleady exists please update the .plugin-data file to good version";
37+
exit 1;
38+
fi

.github/workflows/quality-js.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Javascript Quality Checks
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
# Cancels all previous workflow runs for pull requests that have not completed.
10+
concurrency:
11+
# The concurrency group contains the workflow name and the branch name for pull requests
12+
# or the commit hash for any other events.
13+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
checks:
18+
name: Lint JS
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout project
23+
uses: actions/checkout@v3
24+
25+
- name: Setup NodeJS
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version-file: 'package.json'
29+
30+
- name: Install npm dependencies
31+
run: yarn install --frozen-lockfile
32+
33+
- name: Run wp-script lint:js on src folder
34+
run: yarn run lint:js src

.github/workflows/quality-php.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: PHP Quality Checks
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
# Cancels all previous workflow runs for pull requests that have not completed.
10+
concurrency:
11+
# The concurrency group contains the workflow name and the branch name for pull requests
12+
# or the commit hash for any other events.
13+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
checks:
18+
name: Lint PHP
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout project
23+
uses: actions/checkout@v3
24+
25+
- name: Setup PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: 7.4
29+
extensions: mbstring, intl
30+
31+
- name: Validate composer file
32+
run: composer validate
33+
34+
- name: Install composer dependencies
35+
run: composer install
36+
37+
- name: Run codesniffer
38+
run: composer cs

.github/workflows/release.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: "Release new TAG"
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
build-and-release:
9+
name: "Release new TAG"
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v3
14+
with:
15+
fetch-depth: 0
16+
17+
- id: set-vars
18+
name: "Set variable from .plugin-data file"
19+
run: |
20+
# Get all data from .plugin-data file
21+
content=`cat ./.plugin-data`
22+
# the following lines are only required for multi line json
23+
content="${content//'%'/'%25'}"
24+
content="${content//$'\n'/'%0A'}"
25+
content="${content//$'\r'/'%0D'}"
26+
# end of optional handling for multi line json
27+
echo "::set-output name=pluginData::$content"
28+
29+
- id: check-version
30+
name: "Check version does not exists"
31+
run: |
32+
# Get the version from .plugin-data file.
33+
VERSION=${{fromJson(steps.set-vars.outputs.pluginData).version}}
34+
35+
echo "Get Branch tag"
36+
if git rev-parse "$VERSION" >/dev/null 2>&1; then
37+
echo "Tag already exists, stop now";
38+
exit 1;
39+
fi
40+
41+
- id: build-node
42+
name: "Build project CSS and JS"
43+
uses: actions/setup-node@v3
44+
with:
45+
node-version: 16
46+
cache: 'npm'
47+
- run: npm install
48+
- run: npm run build
49+
50+
- id: build-php
51+
name: "Build project PHP"
52+
uses: shivammathur/setup-php@v2
53+
with:
54+
php-version: 7.2
55+
- run: composer install --prefer-dist --no-dev -o --ignore-platform-reqs
56+
57+
- id: commit-and-push
58+
name: "Commit and push new TAG"
59+
run: |
60+
# Get the version from .plugin-data file.
61+
VERSION=${{fromJson(steps.set-vars.outputs.pluginData).version}}
62+
63+
echo "Copy .distignore to .gitignore"
64+
cp .distignore .gitignore
65+
66+
echo "Configure git"
67+
git config --local user.email "$(git log --format='%ae' HEAD^!)"
68+
git config --local user.name "$(git log --format='%an' HEAD^!)"
69+
70+
echo "Creating branch"
71+
git checkout -b release/${VERSION}
72+
73+
echo "Creating tag ${VERSION}"
74+
git add .
75+
git add -u
76+
git commit -m "Release version ${VERSION}"
77+
git tag ${VERSION}
78+
git push --tags
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: "Publish New Release on WordPress.org"
2+
on:
3+
release:
4+
types: [ published ]
5+
6+
jobs:
7+
wordpress-release:
8+
name: "New release on WordPress.org"
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v3
13+
14+
- id: set-vars
15+
name: "Set variables from .plugin-data file"
16+
run: |
17+
# Get all data from .plugin-data file
18+
content=`cat ./.plugin-data`
19+
# the following lines are only required for multi line json
20+
content="${content//'%'/'%25'}"
21+
content="${content//$'\n'/'%0A'}"
22+
content="${content//$'\r'/'%0D'}"
23+
# end of optional handling for multi line json
24+
echo "::set-output name=pluginData::$content"
25+
26+
- id: deploy
27+
name: "WordPress.org Plugin Deploy"
28+
if: "! github.event.release.prerelease"
29+
uses: 10up/action-wordpress-plugin-deploy@stable
30+
env:
31+
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
32+
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
33+
SLUG: ${{fromJson(steps.set-vars.outputs.pluginData).slug}}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/vendor/
2+
/node_modules/
3+
/assets/build/

.plugin-data

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"version": "1.0.1",
3+
"slug": "acf-palette"
4+
}

beapi-acf-palette.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/*
33
Plugin Name: Be API - ACF Color Palette
4-
Version: 1.0.0
4+
Version: 1.0.1
55
Version Boilerplate: 3.5.0
66
Plugin URI: https://beapi.fr
77
Description: Add a new theme color palette selector field for Advanced Custom Fields.
@@ -35,7 +35,7 @@
3535
}
3636

3737
// Plugin constants
38-
define( 'BEAPI_ACF_PALETTE_VERSION', '1.0.0' );
38+
define( 'BEAPI_ACF_PALETTE_VERSION', '1.0.1' );
3939
define( 'BEAPI_ACF_PALETTE_VIEWS_FOLDER_NAME', 'beapi-acf-palette' );
4040
define( 'BEAPI_ACF_PALETTE_CPT_NAME', 'custom_post_type' );
4141
define( 'BEAPI_ACF_PALETTE_TAXO_NAME', 'custom_taxonomy' );

0 commit comments

Comments
 (0)