From 94fd1597390dc0fb1c8cb75ac1c50bb7130edcca Mon Sep 17 00:00:00 2001 From: Felix Herrmann Date: Sun, 3 Apr 2022 21:34:41 +0200 Subject: [PATCH 1/6] added docc plugin --- Package.resolved | 16 ++++++++++++++++ Package.swift | 9 +++++++++ 2 files changed, 25 insertions(+) create mode 100644 Package.resolved diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 0000000..3b6d58b --- /dev/null +++ b/Package.resolved @@ -0,0 +1,16 @@ +{ + "object": { + "pins": [ + { + "package": "SwiftDocCPlugin", + "repositoryURL": "https://github.com/apple/swift-docc-plugin", + "state": { + "branch": null, + "revision": "3303b164430d9a7055ba484c8ead67a52f7b74f6", + "version": "1.0.0" + } + } + ] + }, + "version": 1 +} diff --git a/Package.swift b/Package.swift index c8fe957..63249a0 100644 --- a/Package.swift +++ b/Package.swift @@ -3,6 +3,14 @@ import PackageDescription +#if swift(>=5.6) && os(macOS) +let dependencies: [Package.Dependency] = [ + .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"), +] +#else +let dependencies: [Package.Dependency] = [] +#endif + let package = Package( name: "swift-multipart-formdata", products: [ @@ -10,6 +18,7 @@ let package = Package( name: "MultipartFormData", targets: ["MultipartFormData"]), ], + dependencies: dependencies, targets: [ .target( name: "MultipartFormData", From 391e2d77366ad677e389971af718a237eef40fd8 Mon Sep 17 00:00:00 2001 From: Felix Herrmann Date: Sun, 3 Apr 2022 21:35:40 +0200 Subject: [PATCH 2/6] added Makefile --- Makefile | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..cbe1524 --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +DOCUMENTATION_PATH=./docs +TARGET=MultipartFormData +HOSTING_PATH=swift-mulipart-formdata + +all: generate-documentation + +generate-documentation: + swift package --allow-writing-to-directory $(DOCUMENTATION_PATH) \ + generate-documentation --target $(TARGET) \ + --disable-indexing \ + --transform-for-static-hosting \ + --hosting-base-path $(HOSTING_PATH) \ + --output-path $(DOCUMENTATION_PATH) From 093b77b25005aa37447160dae4980e8ff710b251 Mon Sep 17 00:00:00 2001 From: Felix Herrmann Date: Tue, 5 Apr 2022 12:16:29 +0200 Subject: [PATCH 3/6] improved command readability and made DOCUMENTATION_PATH assignment optional --- Makefile | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index cbe1524..f678dc8 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,15 @@ -DOCUMENTATION_PATH=./docs +DOCUMENTATION_PATH?=./docs TARGET=MultipartFormData HOSTING_PATH=swift-mulipart-formdata all: generate-documentation generate-documentation: - swift package --allow-writing-to-directory $(DOCUMENTATION_PATH) \ - generate-documentation --target $(TARGET) \ - --disable-indexing \ - --transform-for-static-hosting \ - --hosting-base-path $(HOSTING_PATH) \ - --output-path $(DOCUMENTATION_PATH) + swift package \ + --allow-writing-to-directory $(DOCUMENTATION_PATH) \ + generate-documentation \ + --target $(TARGET) \ + --disable-indexing \ + --transform-for-static-hosting \ + --hosting-base-path $(HOSTING_PATH) \ + --output-path $(DOCUMENTATION_PATH) From c67b2a89ad4f2582084eebad63860865578ca7bb Mon Sep 17 00:00:00 2001 From: Felix Herrmann <42500484+FelixHerrmann@users.noreply.github.com> Date: Tue, 5 Apr 2022 12:17:17 +0200 Subject: [PATCH 4/6] Create docs.yml --- .github/workflows/docs.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/docs.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..93be0f7 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,36 @@ +name: Documentations + +on: + push: + branches: [ master ] + workflow_dispatch: + +jobs: + build-docs: + runs-on: macos-12 + + steps: + - uses: actions/checkout@v3 + - name: Set name in local git-config + run: git config --local user.name "runner" + - name: Setup git worktree + run: git worktree add --checkout gh-pages origin/gh-pages + - name: Generate/update /gh-pages/docs + run: make DOCUMENTATION_PATH=./gh-pages/docs generate-documentation + - name: Push to gh-pages branch: + run: + CURRENT_COMMIT_HASH=`git rev-parse --short HEAD` + + cd gh-pages + git add docs + + if [ -n "$(git status --porcelain)" ]; then + git commit -m "Update GitHub Pages documentation site to '$CURRENT_COMMIT_HASH'." + git push origin HEAD:gh-pages + else + echo "No documentation changes found." + fi + + cd .. + - name: Clear git worktree + run: git worktree remove gh-pages From 6596e762a7eb1d94c05c3a473aeea86a296affb5 Mon Sep 17 00:00:00 2001 From: Felix Herrmann <42500484+FelixHerrmann@users.noreply.github.com> Date: Tue, 5 Apr 2022 12:19:49 +0200 Subject: [PATCH 5/6] fixed syntax --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 93be0f7..486fb14 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -18,7 +18,7 @@ jobs: - name: Generate/update /gh-pages/docs run: make DOCUMENTATION_PATH=./gh-pages/docs generate-documentation - name: Push to gh-pages branch: - run: + run: | CURRENT_COMMIT_HASH=`git rev-parse --short HEAD` cd gh-pages From c482c6d4c1fc1a738d2d1b8d7d62db34ae555b95 Mon Sep 17 00:00:00 2001 From: Felix Herrmann <42500484+FelixHerrmann@users.noreply.github.com> Date: Tue, 5 Apr 2022 12:22:33 +0200 Subject: [PATCH 6/6] Update docs.yml fixed syntax --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 486fb14..f0672b3 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -17,7 +17,7 @@ jobs: run: git worktree add --checkout gh-pages origin/gh-pages - name: Generate/update /gh-pages/docs run: make DOCUMENTATION_PATH=./gh-pages/docs generate-documentation - - name: Push to gh-pages branch: + - name: Push to gh-pages branch run: | CURRENT_COMMIT_HASH=`git rev-parse --short HEAD`