diff --git a/.github/rename_project.sh b/.github/rename_project.sh new file mode 100755 index 0000000..39c6bb7 --- /dev/null +++ b/.github/rename_project.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +while getopts a:n:u:d: flag +do + case "${flag}" in + a) author=${OPTARG};; + n) name=${OPTARG};; + u) urlname=${OPTARG};; + d) description=${OPTARG};; + esac +done + +echo "Author: $author"; +echo "Project Name: $name"; +echo "Project URL name: $urlname"; +echo "Description: $description"; + +echo "Renaming project..." + +original_author="author_name" +original_name="project_name" +original_urlname="project_urlname" +original_description="project_description" +# for filename in $(find . -name "*.*") +for filename in $(git ls-files) +do + sed -i "s/$original_author/$author/g" $filename + sed -i "s/$original_name/$name/g" $filename + sed -i "s/$original_urlname/$urlname/g" $filename + sed -i "s/$original_description/$description/g" $filename + echo "Renamed $filename" +done + +mv project_name $name + +# This command runs only once on GHA! +rm -rf .github/template.yml +rm -rf .github/workflows/rename_project.yml +rm -rf copy/workflows/rename_project.yml +rm -rf .github/rename_project.sh + +rm -rf README.md +mv README.tmpl.md README.md + + diff --git a/.github/template.yml b/.github/template.yml new file mode 100755 index 0000000..229d974 --- /dev/null +++ b/.github/template.yml @@ -0,0 +1 @@ +author: GatherPress diff --git a/.github/workflows/rename_project.yml b/.github/workflows/rename_project.yml new file mode 100644 index 0000000..8e91cf0 --- /dev/null +++ b/.github/workflows/rename_project.yml @@ -0,0 +1,41 @@ +name: Rename the project from template + +on: [push] + +permissions: write-all + +jobs: + rename-project: + if: ${{ !contains (github.repository, '/gatherpress-awesome') }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + # by default, it uses a depth of 1 + # this fetches all history so that we can read each commit + fetch-depth: 0 + ref: ${{ github.head_ref }} + + - run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}' | tr '-' '_' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + shell: bash + + - run: echo "REPOSITORY_URLNAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV + shell: bash + + - run: echo "REPOSITORY_OWNER=$(echo '${{ github.repository }}' | awk -F '/' '{print $1}')" >> $GITHUB_ENV + shell: bash + + - name: Is this still a template + id: is_template + run: echo "::set-output name=is_template::$(ls .github/template.yml &> /dev/null && echo true || echo false)" + + - name: Rename the project + if: steps.is_template.outputs.is_template == 'true' + run: | + echo "Renaming the project with -a(author) ${{ env.REPOSITORY_OWNER }} -n(name) ${{ env.REPOSITORY_NAME }} -u(urlname) ${{ env.REPOSITORY_URLNAME }}" + .github/rename_project.sh -a ${{ env.REPOSITORY_OWNER }} -n ${{ env.REPOSITORY_NAME }} -u ${{ env.REPOSITORY_URLNAME }} -d "${{ env.REPOSITORY_NAME }} is Awesome for GatherPress." + + - uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "✅ Ready to get Awesome." + push_options: --force diff --git a/.wordpress-org/blueprints/blueprint.json b/.wordpress-org/blueprints/blueprint.json index 94b0c53..4a2eb89 100644 --- a/.wordpress-org/blueprints/blueprint.json +++ b/.wordpress-org/blueprints/blueprint.json @@ -15,7 +15,7 @@ { "step": "setSiteOptions", "options": { - "blogname": "GatherPress Awesome", + "blogname": "GatherPress project_name", "blogdescription": "Powering Communities with WordPress.", "users_can_register": 1, "permalink_structure": "/%year%/%monthnum%/%postname%/" @@ -31,6 +31,13 @@ "step": "runPHP", "code": "set_role('editor');" }, + { + "step": "updateUserMeta", + "meta": { + "admin_color": "modern" + }, + "userId": 1 + }, { "step": "login", "username": "admin", @@ -50,7 +57,7 @@ "step": "installPlugin", "pluginZipFile": { "resource": "url", - "url": "https://github-proxy.com/proxy/?repo=GatherPress/gatherpress-awesome" + "url": "https://github-proxy.com/proxy/?repo=author_name/project_urlname" }, "options": { "activate": true diff --git a/README.md b/README.md index fbd79d7..e70f4c9 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,27 @@ A starter plugin for GatherPress companion plugin development. - [x] Test [GatherPress Awesome in Playground](https://playground.wordpress.net/builder/builder.html?blueprint-url=https://raw.githubusercontent.com/GatherPress/gatherpress-awesome/main/.wordpress-org/blueprints/blueprint.json), with GatherPress installed & demo-data already in place. -## Up to you +### Up to you - [ ] [Create your own GatherPress Awesome demo-data](https://github.com/carstingaxion/crud-the-docs-playground), and add it to your [`blueprint.json`](/.wordpress-org/blueprints/blueprint.json). + + +## You should create a new repository from [this template](https://github.com/new?template_name=gatherpress-awesome&template_owner=GatherPress) for yourself, if you'd like to ... + +- **collaboratively work** on a compagnion-plugin for GatherPress + +- extend GatherPress' standard **scenarios using your plugin or theme** + +- see how GatherPress works & test its extendebility. + +### Ready in 10 seconds + +Creating a new repository from [this template](https://github.com/new?template_name=gatherpress-awesome&template_owner=GatherPress) lets you start immediately, because all paths, folder names etc. will be replaced to match the URLs of your new created repo. *Enjoy!* + +This happens within an automated first commit directly after the repo gets initialised. So, please calm for 10 seconds and finally refresh the page. + + +## Acknowledgments + +- [python-project-template](https://github.com/rochacbruno/python-project-template) for their nice template->repo renaming workflow + diff --git a/README.tmpl.md b/README.tmpl.md new file mode 100644 index 0000000..86ee2fa --- /dev/null +++ b/README.tmpl.md @@ -0,0 +1,22 @@ +# GatherPress project_name + +A starter plugin for GatherPress companion plugin development. + +## Already prepared for your GatherPress project_name plugin + +- [x] Test [GatherPress project_name in Playground](https://playground.wordpress.net/builder/builder.html?blueprint-url=https://raw.githubusercontent.com/author_name/project_urlname/main/.wordpress-org/blueprints/blueprint.json), with GatherPress installed & project_name already in place. + +### Up to you + +- [ ] [Create your own GatherPress project_name demo-data](https://github.com/carstingaxion/crud-the-docs-playground), and add it to your [`blueprint.json`](/.wordpress-org/blueprints/blueprint.json). + + +## You should create a new repository from [the original template](https://github.com/new?template_name=gatherpress-awesome&template_owner=GatherPress) for yourself, too, if you'd like to ... + +- **collaboratively work** on a compagnion-plugin for GatherPress + +- extend GatherPress' standard **scenarios using your plugin or theme** + +- see how GatherPress works & test its extendebility. + + diff --git a/gatherpress-awesome.php b/gatherpress-awesome.php index 5023dc2..e069d31 100644 --- a/gatherpress-awesome.php +++ b/gatherpress-awesome.php @@ -1,16 +1,16 @@ __( 'Awesome', 'gatherpress-awesome' ), + $sub_pages['project_urlname'] = array( + 'name' => __( 'project_name', 'gatherpress-project_urlname' ), 'priority' => 10, 'sections' => array( - 'awesome_it_works' => array( - 'name' => __( 'Awesome', 'gatherpress-awesome' ), - 'description' => __( 'GatherPress Awesome works!', 'gatherpress-awesome' ), + 'project_urlname_it_works' => array( + 'name' => __( 'project_name', 'gatherpress-project_urlname' ), + 'description' => __( 'GatherPress project_name works!', 'gatherpress-project_urlname' ), ), ), );