Skip to content

Save generated code #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 1, 2024
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
15 changes: 11 additions & 4 deletions .github/workflows/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,20 @@ runs:
with:
swift-version: ${{ inputs.swift }}
- uses: irgaly/setup-mint@v1
- if: contains(inputs.os, 'macos')
- 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 }}-
# There is no `Xcode/DerivedData`; use `.build` instead.
deriveddata-directory: .build
restore-keys: |
xcode-cache-deriveddata-${{ github.workflow }}-
- name: "Swift Package Manager Cache"
uses: actions/cache@v3
with:
path: .build
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-

# Hint: Use Composite Actions
# - https://stackoverflow.com/a/75735736/9801139
Expand Down
37 changes: 32 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,43 @@ force:
Submodule: force
git submodule update --recursive --remote
git add $@
git commit -m "Update $$(git submodule status Submodule/github/rest-api-description)" || true
git commit -m "[Make] Pull $$(git submodule status Submodule/github/rest-api-description)" || true
echo "::notice:: make $@"

OPENAPI_FILES := $(addsuffix /openapi.yml, $(SUBDIRS))
Sources/%/openapi.yml: Submodule
%/openapi.yml: Submodule
ln -sf ../../Submodule/github/rest-api-description/descriptions/api.github.com/api.github.com.yaml $@
git add $@
git commit -m "Relink $@" || true

.PHONY: install
install: $(OPENAPI_FILES)
SWIFT_FILES := $(addsuffix /Client.swift, $(SUBDIRS))
%.swift: $(OPENAPI_FILES)
mint run apple/swift-openapi-generator generate $(@D)/openapi.yml \
--config $(@D)/openapi-generator-config.yml \
--output-directory $(@D)
git add $@ $(@D)/Types.swift

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

#XCFrameworks:
# mint run giginet/Scipio create . \
# --embed-debug-symbols \
# --support-simulators
# echo "::notice:: make $@"
#
#XCFRAMEWORKS := $(wildcard XCFrameworks/*.xcframework)
#ZIP_FILES := $(XCFRAMEWORKS:%.xcframework=%.zip)
#%.zip: %.xcframework
# zip -r "$@" "$^"
# rm -rf "$^"
# git add "$@"
#
#install-zips: XCFrameworks $(ZIP_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 \
Expand Down
54 changes: 0 additions & 54 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,32 +1,5 @@
{
"pins" : [
{
"identity" : "openapikit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/mattpolzin/OpenAPIKit",
"state" : {
"revision" : "283454875cc6e5b2801d184d65835b92252d1784",
"version" : "3.1.2"
}
},
{
"identity" : "swift-algorithms",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-algorithms",
"state" : {
"revision" : "f6919dfc309e7f1b56224378b11e28bab5bccc42",
"version" : "1.2.0"
}
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser",
"state" : {
"revision" : "c8ed701b513cf5177118a175d85fbbbcd707ab41",
"version" : "1.3.0"
}
},
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
Expand All @@ -45,24 +18,6 @@
"version" : "1.0.2"
}
},
{
"identity" : "swift-numerics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-numerics.git",
"state" : {
"revision" : "0a5bc04095a675662cf24757cc0640aa2204253b",
"version" : "1.0.2"
}
},
{
"identity" : "swift-openapi-generator",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-openapi-generator",
"state" : {
"revision" : "76994bfc77061c6cfa3b82415613a9dfbfb47f28",
"version" : "1.1.0"
}
},
{
"identity" : "swift-openapi-runtime",
"kind" : "remoteSourceControl",
Expand All @@ -80,15 +35,6 @@
"revision" : "aac0a8273fa1186641e0b336da3f1be01aa6a0eb",
"version" : "1.0.0"
}
},
{
"identity" : "yams",
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/Yams",
"state" : {
"revision" : "0d9ee7ea8c4ebd4a489ad7a73d5c6cad55d6fed3",
"version" : "5.0.6"
}
}
],
"version" : 2
Expand Down
8 changes: 2 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ enum GitHubRestAPIOpenAPITag: String, CaseIterable {
resources: [
.copy("openapi-generator-config.yml"),
.copy("openapi.yml"),
],
plugins: [
.plugin(name: "OpenAPIGenerator", package: "swift-openapi-generator"),
]
)
}
Expand All @@ -91,7 +88,6 @@ let package = Package(
platforms: [.macOS(.v10_15)],
products: GitHubRestAPIOpenAPITag.allCases.map(\.library),
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-openapi-urlsession", from: "1.0.0"),
],
Expand All @@ -100,10 +96,10 @@ let package = Package(
]
)

let isBuildDocC = ProcessInfo.processInfo.environment["GITHUB_PAGES"] == "true"
let isBuildingDocC = ProcessInfo.processInfo.environment["GITHUB_PAGES"] == "true"

// swift-docs is not needed for package users
if isBuildDocC {
if isBuildingDocC {
package.dependencies += [
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.3.0"),
]
Expand Down
Loading