Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.

Commit

Permalink
feat: add last update info (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
technote-space committed Jul 13, 2019
1 parent 46940df commit dd0c48b
Show file tree
Hide file tree
Showing 6 changed files with 236 additions and 2 deletions.
10 changes: 10 additions & 0 deletions bin/commit/get-diff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -e

current=$(cd $(dirname $0);
pwd)
source ${current}/../variables.sh

git -C ${2} checkout master
git -C ${2} status --short ${DATA_DIR}
10 changes: 10 additions & 0 deletions bin/commit/git-add.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -e

current=$(cd $(dirname $0);
pwd)
source ${current}/../variables.sh

git -C ${2} add ${DATA_DIR}
git -C ${2} add ${TRAVIS_BUILD_DIR}/README.md
4 changes: 3 additions & 1 deletion bin/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ bash ${current}/update/processing.sh ${GUTENBERG_VARIABLE_PREFIX}&
bash ${current}/update/processing.sh ${WP_VARIABLE_PREFIX}&
wait

bash ${SCRIPT_DIR}/update/commit.sh ${DATA_DIR}
bash ${current}/update/readme.sh

bash ${SCRIPT_DIR}/update/commit.sh
189 changes: 189 additions & 0 deletions bin/update/README.template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
# Gutenberg Package Versions

[![Build Status](https://travis-ci.com/technote-space/gutenberg-package-versions.svg?branch=master)](https://travis-ci.com/technote-space/gutenberg-package-versions)
[![Coverage Status](https://coveralls.io/repos/github/technote-space/gutenberg-package-versions/badge.svg?branch=master)](https://coveralls.io/github/technote-space/gutenberg-package-versions?branch=master)
[![CodeFactor](https://www.codefactor.io/repository/github/technote-space/gutenberg-package-versions/badge)](https://www.codefactor.io/repository/github/technote-space/gutenberg-package-versions)
[![License: GPL v2+](https://img.shields.io/badge/License-GPL%20v2%2B-blue.svg)](http://www.gnu.org/licenses/gpl-2.0.html)
[![PHP: >=5.6](https://img.shields.io/badge/PHP-%3E%3D5.6-orange.svg)](http://php.net/)
[![WordPress: >=5.0](https://img.shields.io/badge/WordPress-%3E%3D5.0-brightgreen.svg)](https://wordpress.org/)

This repository fetches the versions of Gutenberg automatically every day.
The version data is provided by `API` and `composer`.
You can also use these data by [Wrapper](https://github.com/technote-space/gutenberg-packages).

## Last updated
|Gutenberg tag|WordPress tag|Last updated at|
|:---:|:---:|:---:|
|[v${gutenberg_tag}](${gutenberg_tag_url})|[v${wordpress_tag}](${wordpress_tag_url})|[${last_updated_at}](${last_updated_at_url})|

## Data
### Versions of all tags
* `data/gutenberg-versions.json` (for Gutenberg Plugin)
* `data/wp-versions.json` (for WP Core)
#### Detail
- array of (`tag` => `packages`)
- `packages`
- array of (`wp-<package>` => `version`)
#### Example
```
{
"v3.3.0": {
"wp-a11y": "1.1.1",
"wp-api-fetch": "1.0.1",
"wp-autop": "1.1.1",
...
"wp-url": "1.2.1",
"wp-viewport": "1.0.1",
"wp-wordcount": "1.1.1"
},
...
"v5.9.1": {
"wp-a11y": "2.3.0",
"wp-annotations": "1.3.0",
"wp-api-fetch": "3.2.0",
...
"wp-url": "2.6.0",
"wp-viewport": "2.4.0",
"wp-wordcount": "2.3.0"
},
"v5.9.2": {
"wp-a11y": "2.3.0",
"wp-annotations": "1.3.0",
"wp-api-fetch": "3.2.0",
...
"wp-url": "2.6.0",
"wp-viewport": "2.4.0",
"wp-wordcount": "2.3.0"
}
...
}
```
### Versions of each bag
* `data/gutenberg/<TAG>.json` (for Gutenberg Plugin)
* `data/wordpress/<TAG>.json` (for WP Core)
#### Contents
- `packages`
- `wp-<package>` => `version`
#### Example
```json
{
"wp-a11y": "2.0.0",
"wp-api-fetch": "2.0.0",
"wp-autop": "2.0.0",
"wp-blob": "2.0.0",
"wp-block-library": "2.0.0",
"wp-block-serialization-default-parser": "1.0.0-rc.0",
"wp-block-serialization-spec-parser": "1.0.1",
"wp-blocks": "3.0.0",
"wp-components": "3.0.0",
"wp-compose": "2.0.0",
"wp-core-data": "2.0.0",
"wp-data": "2.0.0",
"wp-date": "2.0.0",
"wp-deprecated": "2.0.0",
"wp-dom-ready": "2.0.0",
"wp-dom": "2.0.0",
"wp-editor": "3.0.0",
"wp-element": "2.0.0",
"wp-hooks": "2.0.0",
"wp-html-entities": "2.0.0",
"wp-i18n": "2.0.0",
"wp-is-shallow-equal": "1.1.4",
"wp-keycodes": "2.0.0",
"wp-nux": "2.0.0",
"wp-plugins": "2.0.0",
"wp-redux-routine": "2.0.0",
"wp-shortcode": "2.0.0",
"wp-token-list": "1.0.0",
"wp-url": "2.0.0",
"wp-viewport": "2.0.0",
"wp-wordcount": "2.0.0"
}
```

## Usage
### API
#### Endpoints
- for Gutenberg
- Tags
- https://api.wp-framework.dev/api/v1/gutenberg/tags.json
- Versions
- https://api.wp-framework.dev/api/v1/gutenberg/versions.json
- Each tag
- https://api.wp-framework.dev/api/v1/gutenberg/tags/${tag}.json
- e.g.
- https://api.wp-framework.dev/api/v1/gutenberg/tags/3.3.0.json
- https://api.wp-framework.dev/api/v1/gutenberg/tags/5.1.1.json
- https://api.wp-framework.dev/api/v1/gutenberg/tags/5.2.0.json
- for WP Core
- Tags
- https://api.wp-framework.dev/api/v1/wp-core/tags.json
- Versions
- https://api.wp-framework.dev/api/v1/wp-core/versions.json
- Each tag
- https://api.wp-framework.dev/api/v1/wp-core/tags/${tag}.json
- e.g.
- https://api.wp-framework.dev/api/v1/wp-core/tags/5.0.0.json
- https://api.wp-framework.dev/api/v1/wp-core/tags/5.1.1.json
- https://api.wp-framework.dev/api/v1/wp-core/tags/5.2.0.json
### composer
```bash
composer require technote/gutenberg-package-versions
```
#### Helper
```php
<?php

use Technote\GutenbergPackageVersionProvider;

// for Gutenberg
$provider = new GutenbergPackageVersionProvider();

$provider->get_tags(); // tags

$provider->get_versions(); // array of (tag => packages)
$provider->get_versions( '5.2.0' ); // array of (package => version)

$provider->get_package_version( '5.1.0', 'wp-block-editor' ); // false
$provider->get_package_version( '5.2.0', 'wp-block-editor' ); // 1.0.0-alpha.0

$provider->package_exists( '5.1', 'wp-block-editor' ); // false
$provider->package_exists( '5.2.0', 'wp-block-editor' ); // true
$provider->package_exists( 'v5.2', 'wp-block-editor' ); // true

// for WP Core
$provider = new GutenbergPackageVersionProvider( 'wp' );

$provider->get_tags(); // tags

$provider->get_versions(); // array of (tag => packages)
$provider->get_versions( '5.2.0' ); // array of (package => version)

$provider->get_package_version( '5.1.0', 'wp-block-editor' ); // false
$provider->get_package_version( '5.2.0', 'wp-block-editor' ); // 2.0.1

$provider->package_exists( '5.1', 'wp-block-editor' ); // false
$provider->package_exists( '5.2.0', 'wp-block-editor' ); // true
$provider->package_exists( 'v5.2', 'wp-block-editor' ); // true
```
#### Addition
- Tag format
- 1 (= 1.0.0)
- 1.2 (= 1.2.0)
- 1.2.3
- v1.2.3 (= 1.2.3)
- v.1.2.3 (= 1.2.3)

## Author
[GitHub (Technote)](https://github.com/technote-space)
[Blog](https://technote.space)
23 changes: 23 additions & 0 deletions bin/update/readme.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

set -e

current=$(cd $(dirname $0);
pwd)
source ${current}/../variables.sh ${1}

gutenberg_tag=$(< ${DATA_DIR}/gutenberg/tags.json jq -r '.[]' | sed '/-/!{s/$/_/}' | sort -V | sed 's/_$//' | tail -n 1)
gutenberg_tag_url=https://${GH_PAGES_CNAME}/${GH_PAGES_API_ROOT}/${GH_PAGES_API_VERSION}/gutenberg/tags/${gutenberg_tag}.json
wordpress_tag=$(< ${DATA_DIR}/wp-core/tags.json jq -r '.[]' | sed '/-/!{s/$/_/}' | sort -V | sed 's/_$//' | tail -n 1)
wordpress_tag_url=https://${GH_PAGES_CNAME}/${GH_PAGES_API_ROOT}/${GH_PAGES_API_VERSION}/wp-core/tags/${wordpress_tag}.json
last_updated_at=$(LANG="C" TZ=":UTC" date '+%e %B %Y %T UTC')
last_updated_at_url=${TRAVIS_BUILD_WEB_URL:-'/'}

rm -f ${TRAVIS_BUILD_DIR}/README.md
cp ${current}/README.template.md ${TRAVIS_BUILD_DIR}/README.md
sed -i -e "s/\${gutenberg_tag}/${gutenberg_tag//\//\\/}/" ${TRAVIS_BUILD_DIR}/README.md
sed -i -e "s/\${gutenberg_tag_url}/${gutenberg_tag_url//\//\\/}/" ${TRAVIS_BUILD_DIR}/README.md
sed -i -e "s/\${wordpress_tag}/${wordpress_tag//\//\\/}/" ${TRAVIS_BUILD_DIR}/README.md
sed -i -e "s/\${wordpress_tag_url}/${wordpress_tag_url//\//\\/}/" ${TRAVIS_BUILD_DIR}/README.md
sed -i -e "s/\${last_updated_at}/${last_updated_at//\//\\/}/" ${TRAVIS_BUILD_DIR}/README.md
sed -i -e "s/\${last_updated_at_url}/${last_updated_at_url//\//\\/}/" ${TRAVIS_BUILD_DIR}/README.md
2 changes: 1 addition & 1 deletion bin/variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ GH_PAGES_API_ROOT=api
GH_PAGES_API_VERSION=v1

TAG_MESSAGE="Auto tag by Travis CI"
if [[ -n "${TRAVIS_BUILD_NUMBER}" ]]; then
if [[ -n "${TRAVIS_BUILD_WEB_URL}" ]]; then
COMMIT_MESSAGE="feat: Update version data (Travis build: ${TRAVIS_BUILD_WEB_URL})"
else
COMMIT_MESSAGE="feat: Update version data"
Expand Down

0 comments on commit dd0c48b

Please sign in to comment.