Skip to content

Commit

Permalink
add release workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
petitphp committed Aug 12, 2024
1 parent 1a9c952 commit 51ace27
Show file tree
Hide file tree
Showing 10 changed files with 19,102 additions and 794 deletions.
58 changes: 58 additions & 0 deletions .distignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Project
/.git
/.github
/.wordpress-org
/node_modules
/src

.distignore
.editorconfig
.gitattributes
.gitignore
.version-data.json
.wp-env.json
CHANGELOG.md
composer.json
composer.lock
grumphp.yml
LICENSE.md
package.json
package-lock.json
phpcs.xml.dist
phpunit.xml.dist
psalm.xml.dist
README.EN.md
README.md
webpack.config.js
yarn.lock

# WP DSFR Blocks
/wp-dsfr-blocks/.wordpress-org
/wp-dsfr-blocks/node_modules
/wp-dsfr-blocks/src
/wp-dsfr-blocks/.editorconfig
/wp-dsfr-blocks/.gitattributes
/wp-dsfr-blocks/.gitignore
/wp-dsfr-blocks/.version-data.json
/wp-dsfr-blocks/CHANGELOG.md
/wp-dsfr-blocks/composer.json
/wp-dsfr-blocks/composer.lock
/wp-dsfr-blocks/package.json
/wp-dsfr-blocks/package-lock.json
/wp-dsfr-blocks/README.EN.md
/wp-dsfr-blocks/README.md

# WP DSFR Theme
/wp-dsfr-theme/.wordpress-org
/wp-dsfr-theme/config
/wp-dsfr-theme/node_modules
/wp-dsfr-theme/src
/wp-dsfr-theme/.editorconfig
/wp-dsfr-theme/.gitattributes
/wp-dsfr-theme/.gitignore
/wp-dsfr-theme/.version-data.json
/wp-dsfr-theme/CHANGELOG.md
/wp-dsfr-theme/package.json
/wp-dsfr-theme/package-lock.json
/wp-dsfr-theme/README.EN.md
/wp-dsfr-theme/README.md
97 changes: 97 additions & 0 deletions .github/workflows/build-release-assets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: "Build release assets"
on:
release:
types:
- published

jobs:
build-archives:
name: "Build archives"
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout@v4

- id: extract-plugin-version
name: "Extract plugin version number from .version-data.json file."
run: |
# Path to the version data file
DSFR_BLOCKS_VERSION_FILE="$GITHUB_WORKSPACE/wp-dsfr-blocks/.version-data.json"
# Parse the file and extract the version
DSFR_BLOCKS_VERSION=$(cat DSFR_BLOCKS_VERSION_FILE | jq .version)
# Send the version to the output
echo "dsfr-blocks-version=$DSFR_BLOCKS_VERSION" >> "$GITHUB_OUTPUT"
- id: extract-theme-version
name: "Extract theme version number from .version-data.json file."
run: |
# Path to the version data file
DSFR_THEME_VERSION_FILE="$GITHUB_WORKSPACE/wp-dsfr-theme/.version-data.json"
# Parse the file and extract the version
DSFR_THEME_VERSION=$(cat DSFR_THEME_VERSION_FILE | jq .version)
# Send the version to the output
echo "dsfr-theme-version=$DSFR_THEME_VERSION" >> "$GITHUB_OUTPUT"
- id: dsfr-blocks-build-node
name: "WP DSFR Blocks : Build project CSS and JS"
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
- run: npm ci
- run: npm run build
working-directory: ./wp-dsfr-blocks

- id: dsfr-theme-build-node
name: "WP DSFR Theme : Build project CSS and JS"
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
- run: npm ci
- run: npm run build
working-directory: ./wp-dsfr-theme

- id: build-wp-dsfr-blocks-archive
name: "Build WP DSFR Blocks archive"
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
run: |
npm ci
npm run plugin-zip
working-directory: "./wp-dsfr-blocks"

- id: build-wp-dsfr-theme-archive
name: "Build WP DSFR Theme archive"
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
run: |
npm ci
npm run plugin-zip
working-directory: "./wp-dsfr-theme"

- id: upload-wp-dsfr-blocks-asset
name: "Upload WP DSFR Blocks archive to the release"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./wp-dsfr-blocks/wp-dsfr-blocks.zip
asset_name: wp-dsfr-blocks-${{ steps.extract-plugin-version.outputs.dsfr-blocks-version }}.zip
asset_content_type: application/zip

- id: upload-wp-dsfr-theme-asset
name: "Upload WP DSFR Theme archive to the release"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./wp-dsfr-theme/wp-dsfr-theme.zip
asset_name: wp-dsfr-theme-${{ steps.extract-theme-version.outputs.dsfr-theme-version }}.zip
asset_content_type: application/zip
79 changes: 79 additions & 0 deletions .github/workflows/release-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: "Release new TAG"
on:
push:
branches:
- main

jobs:
build-and-release:
name: "Release new TAG"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- id: parse
name: "Extract version number from .version-data.json file."
run: |
# Path to the version data file
DSFR_VERSION_FILE="$GITHUB_WORKSPACE/.version-data.json"
# Parse the file and extract the version
DSFR_VERSION=$(cat DSFR_VERSION_FILE | jq .version)
# Send the version to the output
echo "dsfr-project-version=$DSFR_VERSION" >> "$GITHUB_OUTPUT"
- id: version-check
name: "Check if a tag matching the version doesn't already exists."
run: |
# Get the version from the previous step
VERSION=${{ steps.parse.outputs.dsfr-project-version }}
if git rev-parse "$VERSION" >/dev/null 2>&1; then
echo "A tag aleady exists for this version, please update the .version-data.json file to a new version.";
exit 1;
fi
- id: dsfr-blocks-build-node
name: "WP DSFR Blocks : Build project CSS and JS"
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
- run: npm ci
- run: npm run build
working-directory: ./wp-dsfr-blocks

- id: dsfr-theme-build-node
name: "WP DSFR Theme : Build project CSS and JS"
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
- run: npm ci
- run: npm run build
working-directory: ./wp-dsfr-theme

- id: commit-and-push
name: "Commit and push new TAG"
run: |
# Get the version.
VERSION=${{ steps.parse.outputs.dsfr-project-version }}
echo "Copy .distignore to .gitignore"
cp .distignore .gitignore
echo "Configure git"
git config --local user.email "$(git log --format='%ae' HEAD^!)"
git config --local user.name "$(git log --format='%an' HEAD^!)"
echo "Creating branch"
git checkout -b release/${VERSION}
echo "Creating tag ${VERSION}"
git add .
git add -u
git commit -m "Release version ${VERSION}"
git tag ${VERSION}
git push --tags
38 changes: 38 additions & 0 deletions .github/workflows/validate-project-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "Check project version"
on:
pull_request:
branches:
- main

jobs:
version-check:
name: "Check project version doesn't already exists."
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- id: parse
name: "Extract version number from .version-data.json file."
run: |
# Path to the version data file
DSFR_VERSION_FILE="$GITHUB_WORKSPACE/.version-data.json"
# Parse the file and extract the version
DSFR_VERSION=$(cat DSFR_VERSION_FILE | jq .version)
# Send the version to the output
echo "dsfr-project-version=$DSFR_VERSION" >> $GITHUB_OUTPUT
- id: version-check
name: "Check if a tag matching the version doesn't already exists."
run: |
# Get the version from the previous step
VERSION=${{ steps.parse.outputs.dsfr-project-version }}
if git rev-parse "$VERSION" >/dev/null 2>&1; then
echo "A tag aleady exists for this version, please update the .version-data.json file to a new version.";
exit 1;
fi
3 changes: 3 additions & 0 deletions .version-data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": "2024.1"
}
Loading

0 comments on commit 51ace27

Please sign in to comment.