Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ runs:
with:
swift-version: ${{ inputs.swift }}
- uses: irgaly/setup-mint@v1
- uses: chrisdickinson/setup-yq@latest

- name: "Xcode Cache"
if: contains(inputs.os, 'macos')
uses: irgaly/xcode-cache@v1
with:
key: xcode-cache-deriveddata-${{ github.workflow }}-${{ github.sha }}
restore-keys: |
xcode-cache-deriveddata-${{ github.workflow }}-

- name: "Swift Package Manager Cache"
uses: actions/cache@v3
with:
Expand Down
64 changes: 41 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# Special-Targets #
# https://www.gnu.org/software/make/manual/html_node/Special-Targets.html
.DEFAULT_GOAL := install
SUBDIRS := $(wildcard Sources/*)
OPENAPI_PATH := Submodule/github/rest-api-description/descriptions/api.github.com/api.github.com.yaml
.SECONDARY: $(%.yml)

.PHONY: force
force:
Expand All @@ -14,28 +15,47 @@ Submodule: force
git commit -m "[Make] Pull $$(git submodule status Submodule/github/rest-api-description)" || true
echo "::notice:: make $@"

OPENAPI_FILES := $(addsuffix /openapi.yml, $(SUBDIRS))
%/openapi.yml: Submodule
ln -sf ../../Submodule/github/rest-api-description/descriptions/api.github.com/api.github.com.yaml $@
git add $@
TAG_NAMES := $(shell yq -r '.tags[].name' $(OPENAPI_PATH))
SUBDIRS := $(addprefix Sources/, $(TAG_NAMES))
OPENAPI_CONFIG_FILES := $(addsuffix /openapi-generator-config.yml, $(SUBDIRS))
%/openapi-generator-config.yml: Submodule
mkdir -p "$(@D)"
@tag_name=$(shell basename $(shell dirname $@)); \
echo "generate:" > $@; \
echo " - types" >> $@; \
echo " - client" >> $@; \
echo "" >> $@; \
echo "" >> $@; \
echo "filter:" >> $@; \
echo " tags:" >> $@; \
echo " - $$tag_name" >> $@; \
echo "" >> $@; \
echo "" >> $@; \
echo "accessModifier: public" >> $@; \
echo "" >> $@;
# git add $@ # INTERMEDIATE file after *.swift

%/openapi.yml: %/openapi-generator-config.yml Submodule
ln -sf ../../$(OPENAPI_PATH) $@
# git add $@ # INTERMEDIATE file after *.swift

SWIFT_FILES := $(addsuffix /Client.swift, $(SUBDIRS))
%.swift: $(OPENAPI_FILES)
%/Client.swift: %/openapi.yml
mint run apple/swift-openapi-generator generate $(@D)/openapi.yml \
--config $(@D)/openapi-generator-config.yml \
--output-directory $(@D)
git add $@ $(@D)/Types.swift
--config $(@D)/openapi-generator-config.yml \
--output-directory $(@D)
git add $(@D)
git commit -m "[Make] Sync *.swift" || true

install-files: $(SWIFT_FILES)
git commit -m "[Make] Re-link openapi.yml & re-gen swift files." || true
install: $(SWIFT_FILES)
echo "::notice:: make $@"

#XCFrameworks:
# mint run giginet/Scipio create . \
# --embed-debug-symbols \
# --support-simulators
# --embed-debug-symbols \
# --support-simulators
# echo "::notice:: make $@"
#

#XCFRAMEWORKS := $(wildcard XCFrameworks/*.xcframework)
#ZIP_FILES := $(XCFRAMEWORKS:%.xcframework=%.zip)
#%.zip: %.xcframework
Expand All @@ -47,14 +67,12 @@ install-files: $(SWIFT_FILES)
# git commit -m "[Make] Re-gen framework zips" || true
# echo "::notice:: make $@"

install: install-files

.build/docs: ## Need env GITHUB_PAGES is created as 'true'
swift package --allow-writing-to-directory $@ generate-documentation \
--disable-indexing \
--output-path $@ \
--transform-for-static-hosting \
--hosting-base-path github-rest-api-swift-openapi;
#.build/docs: ## Need env GITHUB_PAGES is created as 'true'
# swift package --allow-writing-to-directory $@ generate-documentation \
# --disable-indexing \
# --output-path $@ \
# --transform-for-static-hosting \
# --hosting-base-path github-rest-api-swift-openapi;

.PHONY: help
.SILENT: help
Expand Down
7 changes: 4 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Foundation
/// which can be useful when generating client code for a subset of a large API,
/// or splitting an implementation of a server across multiple modules.
enum GitHubRestAPIOpenAPITag: String, CaseIterable {
case actions
case activity
case apps
case billing
Expand Down Expand Up @@ -59,9 +60,9 @@ enum GitHubRestAPIOpenAPITag: String, CaseIterable {
.product(name: "OpenAPIURLSession", package: "swift-openapi-urlsession"),
],
path: "Sources/\(rawValue)",
resources: [
.copy("openapi-generator-config.yml"),
.copy("openapi.yml"),
exclude: [
"openapi-generator-config.yml",
"openapi.yml",
]
)
}
Expand Down
Loading