bump versions #180
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "bump versions" | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
jobs: | |
bump-versions: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: "Checkout v4" | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.FIREGHOST_PAT }} | |
- name: "Update Wordpress version" | |
run: | | |
wordpress_version=`curl "https://api.github.com/repos/WordPress/WordPress/tags?per_page=1" | jq -r .[0].name` | |
if [[ $wordpress_version == *"-"* ]]; then | |
echo "The latest tag of Wordpress is not a final release: ${wordpress_version}" | |
else | |
# Add multiple ".0" if the version has less than three digits. | |
wordpress_version_dots=${wordpress_version//[^\.]} | |
nbr_dots=${#wordpress_version_dots} | |
nbr_dots_to_add=$((2 - ${nbr_dots})) | |
for ((i = 0 ; i < $nbr_dots_to_add ; i++)); do | |
wordpress_version=${wordpress_version}.0 | |
done | |
echo $(jq -c --arg wordpress_version "${wordpress_version}" '.wordpress_version = $wordpress_version' versions.json) > versions.json | |
fi | |
- name: "Update Sqlite plugin version" | |
run: | | |
sqlite_database_integration_version=`curl "https://api.github.com/repos/WordPress/sqlite-database-integration/releases?per_page=1" | jq -r .[0].name | tail -c +2` | |
if [[ $sqlite_database_integration_version == *"-"* ]]; then | |
echo "The latest tag of the Sqlite plugin integration is not a final release: ${sqlite_database_integration_version}" | |
else | |
echo $(jq -c --arg sqlite_database_integration_version "${sqlite_database_integration_version}" '.sqlite_database_integration_version = $sqlite_database_integration_version' versions.json) > versions.json | |
fi | |
- name: "Continue if updated" | |
id: check_if_update | |
run: | | |
echo "sqlite_database_integration_version=$(jq -r .sqlite_database_integration_version versions.json)" >> "$GITHUB_OUTPUT" | |
echo "wordpress_version=$(jq -r .wordpress_version versions.json)" >> "$GITHUB_OUTPUT" | |
echo "needs_update=`git status --porcelain`" >> "$GITHUB_OUTPUT" | |
echo "Diff: $(git diff)" | |
- name: "Push changes to branch main" | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
if: ${{ steps.check_if_update.outputs.needs_update != '' }} | |
with: | |
commit_message: "Auto bump versions" | |
file_pattern: 'versions.json' | |
tagging_message: "${{ steps.check_if_update.outputs.wordpress_version }}-${{ steps.check_if_update.outputs.sqlite_database_integration_version }}" |