From 3de39b5713adeef45c536fa97ba7d06ed1bdb0c4 Mon Sep 17 00:00:00 2001 From: Nikita Vasilev Date: Sat, 13 Jan 2024 20:40:09 +0100 Subject: [PATCH 1/2] Add `DocC` deployment template --- cookiecutter.json | 4 ++ hooks/post_gen_project.py | 15 +++++++ .../.github/workflows/deploy_docc.yml | 44 +++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 hooks/post_gen_project.py create mode 100644 {{ cookiecutter.name | lower }}/.github/workflows/deploy_docc.yml diff --git a/cookiecutter.json b/cookiecutter.json index b89ee64..bb29a76 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -23,5 +23,9 @@ "additional_badges": [ "Yes", "No" + ], + "deploy_docc": [ + "Yes", + "No" ] } \ No newline at end of file diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py new file mode 100644 index 0000000..9891db6 --- /dev/null +++ b/hooks/post_gen_project.py @@ -0,0 +1,15 @@ +import os +import shutil + +print(os.getcwd()) + +def remove(filepath): + if os.path.isfile(filepath): + os.remove(filepath) + elif os.path.isdir(filepath): + shutil.rmtree(filepath) + +create_docc = '{{ cookiecutter.deploy_docc }}' == 'yes' + +if not create_docc: + remove(os.path.join(os.getcwd(), '.github/workflows', 'deploy_docc.yml')) \ No newline at end of file diff --git a/{{ cookiecutter.name | lower }}/.github/workflows/deploy_docc.yml b/{{ cookiecutter.name | lower }}/.github/workflows/deploy_docc.yml new file mode 100644 index 0000000..125feba --- /dev/null +++ b/{{ cookiecutter.name | lower }}/.github/workflows/deploy_docc.yml @@ -0,0 +1,44 @@ +name: Deploy DocC + +on: + push: + branches: + - main + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + deploy: + environment: + name: github-pages + {% raw %} + url: ${{ steps.deployment.outputs.page_url }} + {% endraw %} + runs-on: macos-12 + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v3 + - name: Build DocC + run: | + swift build; + swift package \ + --allow-writing-to-directory ./docs \ + generate-documentation \ + --target {{ cookiecutter.name }} \ + --output-path ./docs \ + --transform-for-static-hosting \ + --hosting-base-path {{ cookiecutter.name | lower }}; + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 + with: + path: 'docs' + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1 \ No newline at end of file From 4fc7c8b0614c3e7f7c2c25df7cd0533928a96c1d Mon Sep 17 00:00:00 2001 From: Nikita Vasilev Date: Sat, 13 Jan 2024 20:41:08 +0100 Subject: [PATCH 2/2] Add `CHANGELOG.md` --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d8bab2..05a99fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. ## [Unreleased] ## Added +- Add `DocC` deployment template + - Added in Pull Request[#13](https://github.com/space-code/package-template/pull/13). - Add additional badges to `README.md` - Added in Pull Request [#12](https://github.com/space-code/package-template/pull/12). - Add files to comply with community standards