Skip to content

Commit 4b8ffa1

Browse files
authored
Merge pull request #11 from BeAPI/feat/github-workflows
add release workflows
2 parents 1a8cdc2 + c48cb6a commit 4b8ffa1

13 files changed

Lines changed: 293 additions & 33979 deletions

.distignore

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Project
2+
/.git
3+
/.github
4+
/.wordpress-org
5+
/node_modules
6+
/src
7+
8+
.distignore
9+
.editorconfig
10+
.gitattributes
11+
.gitignore
12+
.version-data.json
13+
.wp-env.json
14+
CHANGELOG.md
15+
composer.json
16+
composer.lock
17+
grumphp.yml
18+
LICENSE.md
19+
package.json
20+
package-lock.json
21+
phpcs.xml.dist
22+
phpunit.xml.dist
23+
psalm.xml.dist
24+
README.EN.md
25+
README.md
26+
webpack.config.js
27+
yarn.lock
28+
29+
# WP DSFR Blocks
30+
/wp-dsfr-blocks/.wordpress-org
31+
/wp-dsfr-blocks/node_modules
32+
/wp-dsfr-blocks/src
33+
/wp-dsfr-blocks/.editorconfig
34+
/wp-dsfr-blocks/.gitattributes
35+
/wp-dsfr-blocks/.gitignore
36+
/wp-dsfr-blocks/.version-data.json
37+
/wp-dsfr-blocks/CHANGELOG.md
38+
/wp-dsfr-blocks/composer.json
39+
/wp-dsfr-blocks/composer.lock
40+
/wp-dsfr-blocks/package.json
41+
/wp-dsfr-blocks/package-lock.json
42+
/wp-dsfr-blocks/README.EN.md
43+
/wp-dsfr-blocks/README.md
44+
45+
# WP DSFR Theme
46+
/wp-dsfr-theme/.wordpress-org
47+
/wp-dsfr-theme/config
48+
/wp-dsfr-theme/node_modules
49+
/wp-dsfr-theme/src
50+
/wp-dsfr-theme/.editorconfig
51+
/wp-dsfr-theme/.gitattributes
52+
/wp-dsfr-theme/.gitignore
53+
/wp-dsfr-theme/.version-data.json
54+
/wp-dsfr-theme/CHANGELOG.md
55+
/wp-dsfr-theme/package.json
56+
/wp-dsfr-theme/package-lock.json
57+
/wp-dsfr-theme/README.EN.md
58+
/wp-dsfr-theme/README.md
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: "Build release assets"
2+
on:
3+
release:
4+
types:
5+
- published
6+
7+
jobs:
8+
build-archives:
9+
name: "Build archives"
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: "Checkout code"
13+
uses: actions/checkout@v4
14+
15+
- id: extract-plugin-version
16+
name: "Extract plugin version number from .version-data.json file."
17+
run: |
18+
# Parse .version-data.json file and extract the version
19+
DSFR_BLOCKS_VERSION=$(cat ./wp-dsfr-blocks/.version-data.json | jq .version)
20+
21+
# Send the version to the output
22+
echo "dsfr-blocks-version=$DSFR_BLOCKS_VERSION" >> "$GITHUB_OUTPUT"
23+
24+
- id: extract-theme-version
25+
name: "Extract theme version number from .version-data.json file."
26+
run: |
27+
# Parse .version-data.json file and extract the version
28+
DSFR_THEME_VERSION=$(cat ./wp-dsfr-theme/.version-data.json | jq .version)
29+
30+
# Send the version to the output
31+
echo "dsfr-theme-version=$DSFR_THEME_VERSION" >> "$GITHUB_OUTPUT"
32+
33+
- id: dsfr-blocks-build-node
34+
name: "WP DSFR Blocks : Build project CSS and JS. Zip wp-dsfr-blocks folder."
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version-file: './wp-dsfr-blocks/package.json'
38+
- run: cd ./wp-dsfr-blocks/ && npm install && npm run build && npm run plugin-zip && cd ../
39+
40+
- id: dsfr-theme-build-node
41+
name: "WP DSFR Theme : Build project CSS and JS. Zip wp-dsfr-theme folder."
42+
uses: actions/setup-node@v4
43+
with:
44+
node-version-file: './wp-dsfr-theme/package.json'
45+
- run: cd ./wp-dsfr-theme/ && npm install && npm run build && npm run plugin-zip && cd ../
46+
47+
- id: upload-wp-dsfr-blocks-asset
48+
name: "Upload WP DSFR Blocks archive to the release"
49+
uses: actions/upload-release-asset@v1
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
with:
53+
upload_url: ${{ github.event.release.upload_url }}
54+
asset_path: ./wp-dsfr-blocks/wp-dsfr-blocks.zip
55+
asset_name: wp-dsfr-blocks-${{ steps.extract-plugin-version.outputs.dsfr-blocks-version }}.zip
56+
asset_content_type: application/zip
57+
58+
- id: upload-wp-dsfr-theme-asset
59+
name: "Upload WP DSFR Theme archive to the release"
60+
uses: actions/upload-release-asset@v1
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
with:
64+
upload_url: ${{ github.event.release.upload_url }}
65+
asset_path: ./wp-dsfr-theme/wp-dsfr-theme.zip
66+
asset_name: wp-dsfr-theme-${{ steps.extract-theme-version.outputs.dsfr-theme-version }}.zip
67+
asset_content_type: application/zip
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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@v4
14+
with:
15+
fetch-depth: 0
16+
17+
- id: parse
18+
name: "Extract version number from .version-data.json file."
19+
run: |
20+
# Parse .version-data.json file and extract the version
21+
DSFR_VERSION=$(cat ./.version-data.json | jq .version)
22+
23+
# Send the version to the output
24+
echo "dsfr-project-version=$DSFR_VERSION" >> "$GITHUB_OUTPUT"
25+
26+
- id: version-check
27+
name: "Check if a tag matching the version doesn't already exists."
28+
run: |
29+
# Get the version from the previous step
30+
VERSION=${{ steps.parse.outputs.dsfr-project-version }}
31+
32+
if git rev-parse "$VERSION" >/dev/null 2>&1; then
33+
echo "A tag aleady exists for this version, please update the .version-data.json file to a new version.";
34+
exit 1;
35+
fi
36+
37+
- id: dsfr-blocks-build-node
38+
name: "WP DSFR Blocks : Build project CSS and JS"
39+
uses: actions/setup-node@v4
40+
with:
41+
node-version-file: './wp-dsfr-blocks/package.json'
42+
- run: cd ./wp-dsfr-blocks/ && npm install && npm run build && cd ../
43+
44+
- id: dsfr-theme-build-node
45+
name: "WP DSFR Theme : Build project CSS and JS"
46+
uses: actions/setup-node@v4
47+
with:
48+
node-version-file: './wp-dsfr-theme/package.json'
49+
- run: cd ./wp-dsfr-theme/ && npm install && npm run build && cd ../
50+
51+
- id: commit-and-push
52+
name: "Commit and push new TAG"
53+
run: |
54+
# Get the version.
55+
VERSION=${{ steps.parse.outputs.dsfr-project-version }}
56+
57+
echo "Copy .distignore to .gitignore"
58+
cp .distignore .gitignore
59+
60+
echo "Configure git"
61+
git config --local user.email "$(git log --format='%ae' HEAD^!)"
62+
git config --local user.name "$(git log --format='%an' HEAD^!)"
63+
64+
echo "Creating branch"
65+
git checkout -b release/${VERSION}
66+
67+
echo "Creating tag ${VERSION}"
68+
git add .
69+
git add -u
70+
git commit -m "Release version ${VERSION}"
71+
git tag ${VERSION}
72+
git push --tags
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: "Check project version"
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
7+
jobs:
8+
version-check:
9+
name: "Check project version doesn't already exists."
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
17+
- id: parse
18+
name: "Extract version number from .version-data.json file."
19+
run: |
20+
# Parse .version-data.json file and extract the version
21+
DSFR_VERSION=$(cat ./.version-data.json | jq .version)
22+
23+
# Send the version to the output
24+
echo "dsfr-project-version=$DSFR_VERSION" >> $GITHUB_OUTPUT
25+
26+
- id: version-check
27+
name: "Check if a tag matching the version doesn't already exists."
28+
run: |
29+
# Get the version from the previous step
30+
VERSION=${{ steps.parse.outputs.dsfr-project-version }}
31+
32+
if git rev-parse "$VERSION" >/dev/null 2>&1; then
33+
echo "A tag aleady exists for this version, please update the .version-data.json file to a new version.";
34+
exit 1;
35+
fi

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
# Repository
88
/node_modules
9+
package-lock.json
910

1011
# DSFR Theme
1112
/wp-dsfr-theme/node_modules

.version-data.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"version": "2024.1"
3+
}

0 commit comments

Comments
 (0)