Skip to content

Commit 51ace27

Browse files
committed
add release workflows
1 parent 1a9c952 commit 51ace27

File tree

10 files changed

+19102
-794
lines changed

10 files changed

+19102
-794
lines changed

.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: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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+
# Path to the version data file
19+
DSFR_BLOCKS_VERSION_FILE="$GITHUB_WORKSPACE/wp-dsfr-blocks/.version-data.json"
20+
21+
# Parse the file and extract the version
22+
DSFR_BLOCKS_VERSION=$(cat DSFR_BLOCKS_VERSION_FILE | jq .version)
23+
24+
# Send the version to the output
25+
echo "dsfr-blocks-version=$DSFR_BLOCKS_VERSION" >> "$GITHUB_OUTPUT"
26+
27+
- id: extract-theme-version
28+
name: "Extract theme version number from .version-data.json file."
29+
run: |
30+
# Path to the version data file
31+
DSFR_THEME_VERSION_FILE="$GITHUB_WORKSPACE/wp-dsfr-theme/.version-data.json"
32+
33+
# Parse the file and extract the version
34+
DSFR_THEME_VERSION=$(cat DSFR_THEME_VERSION_FILE | jq .version)
35+
36+
# Send the version to the output
37+
echo "dsfr-theme-version=$DSFR_THEME_VERSION" >> "$GITHUB_OUTPUT"
38+
39+
- id: dsfr-blocks-build-node
40+
name: "WP DSFR Blocks : Build project CSS and JS"
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version-file: 'package.json'
44+
- run: npm ci
45+
- run: npm run build
46+
working-directory: ./wp-dsfr-blocks
47+
48+
- id: dsfr-theme-build-node
49+
name: "WP DSFR Theme : Build project CSS and JS"
50+
uses: actions/setup-node@v4
51+
with:
52+
node-version-file: 'package.json'
53+
- run: npm ci
54+
- run: npm run build
55+
working-directory: ./wp-dsfr-theme
56+
57+
- id: build-wp-dsfr-blocks-archive
58+
name: "Build WP DSFR Blocks archive"
59+
uses: actions/setup-node@v4
60+
with:
61+
node-version-file: 'package.json'
62+
run: |
63+
npm ci
64+
npm run plugin-zip
65+
working-directory: "./wp-dsfr-blocks"
66+
67+
- id: build-wp-dsfr-theme-archive
68+
name: "Build WP DSFR Theme archive"
69+
uses: actions/setup-node@v4
70+
with:
71+
node-version-file: 'package.json'
72+
run: |
73+
npm ci
74+
npm run plugin-zip
75+
working-directory: "./wp-dsfr-theme"
76+
77+
- id: upload-wp-dsfr-blocks-asset
78+
name: "Upload WP DSFR Blocks archive to the release"
79+
uses: actions/upload-release-asset@v1
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
with:
83+
upload_url: ${{ github.event.release.upload_url }}
84+
asset_path: ./wp-dsfr-blocks/wp-dsfr-blocks.zip
85+
asset_name: wp-dsfr-blocks-${{ steps.extract-plugin-version.outputs.dsfr-blocks-version }}.zip
86+
asset_content_type: application/zip
87+
88+
- id: upload-wp-dsfr-theme-asset
89+
name: "Upload WP DSFR Theme archive to the release"
90+
uses: actions/upload-release-asset@v1
91+
env:
92+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93+
with:
94+
upload_url: ${{ github.event.release.upload_url }}
95+
asset_path: ./wp-dsfr-theme/wp-dsfr-theme.zip
96+
asset_name: wp-dsfr-theme-${{ steps.extract-theme-version.outputs.dsfr-theme-version }}.zip
97+
asset_content_type: application/zip
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
# Path to the version data file
21+
DSFR_VERSION_FILE="$GITHUB_WORKSPACE/.version-data.json"
22+
23+
# Parse the file and extract the version
24+
DSFR_VERSION=$(cat DSFR_VERSION_FILE | jq .version)
25+
26+
# Send the version to the output
27+
echo "dsfr-project-version=$DSFR_VERSION" >> "$GITHUB_OUTPUT"
28+
29+
- id: version-check
30+
name: "Check if a tag matching the version doesn't already exists."
31+
run: |
32+
# Get the version from the previous step
33+
VERSION=${{ steps.parse.outputs.dsfr-project-version }}
34+
35+
if git rev-parse "$VERSION" >/dev/null 2>&1; then
36+
echo "A tag aleady exists for this version, please update the .version-data.json file to a new version.";
37+
exit 1;
38+
fi
39+
40+
- id: dsfr-blocks-build-node
41+
name: "WP DSFR Blocks : Build project CSS and JS"
42+
uses: actions/setup-node@v4
43+
with:
44+
node-version-file: 'package.json'
45+
- run: npm ci
46+
- run: npm run build
47+
working-directory: ./wp-dsfr-blocks
48+
49+
- id: dsfr-theme-build-node
50+
name: "WP DSFR Theme : Build project CSS and JS"
51+
uses: actions/setup-node@v4
52+
with:
53+
node-version-file: 'package.json'
54+
- run: npm ci
55+
- run: npm run build
56+
working-directory: ./wp-dsfr-theme
57+
58+
- id: commit-and-push
59+
name: "Commit and push new TAG"
60+
run: |
61+
# Get the version.
62+
VERSION=${{ steps.parse.outputs.dsfr-project-version }}
63+
64+
echo "Copy .distignore to .gitignore"
65+
cp .distignore .gitignore
66+
67+
echo "Configure git"
68+
git config --local user.email "$(git log --format='%ae' HEAD^!)"
69+
git config --local user.name "$(git log --format='%an' HEAD^!)"
70+
71+
echo "Creating branch"
72+
git checkout -b release/${VERSION}
73+
74+
echo "Creating tag ${VERSION}"
75+
git add .
76+
git add -u
77+
git commit -m "Release version ${VERSION}"
78+
git tag ${VERSION}
79+
git push --tags
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
# Path to the version data file
21+
DSFR_VERSION_FILE="$GITHUB_WORKSPACE/.version-data.json"
22+
23+
# Parse the file and extract the version
24+
DSFR_VERSION=$(cat DSFR_VERSION_FILE | jq .version)
25+
26+
# Send the version to the output
27+
echo "dsfr-project-version=$DSFR_VERSION" >> $GITHUB_OUTPUT
28+
29+
- id: version-check
30+
name: "Check if a tag matching the version doesn't already exists."
31+
run: |
32+
# Get the version from the previous step
33+
VERSION=${{ steps.parse.outputs.dsfr-project-version }}
34+
35+
if git rev-parse "$VERSION" >/dev/null 2>&1; then
36+
echo "A tag aleady exists for this version, please update the .version-data.json file to a new version.";
37+
exit 1;
38+
fi

.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)