Skip to content

Commit 1f69984

Browse files
authored
Merge pull request #2 from Wei18/feat/gen-code
Save generated code
2 parents dc1f12f + c9b483b commit 1f69984

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+375481
-69
lines changed

.github/workflows/actions/setup/action.yml

+11-4
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,20 @@ runs:
1515
with:
1616
swift-version: ${{ inputs.swift }}
1717
- uses: irgaly/setup-mint@v1
18-
- if: contains(inputs.os, 'macos')
18+
- name: "Xcode Cache"
19+
if: contains(inputs.os, 'macos')
1920
uses: irgaly/xcode-cache@v1
2021
with:
2122
key: xcode-cache-deriveddata-${{ github.workflow }}-${{ github.sha }}
22-
restore-keys: xcode-cache-deriveddata-${{ github.workflow }}-
23-
# There is no `Xcode/DerivedData`; use `.build` instead.
24-
deriveddata-directory: .build
23+
restore-keys: |
24+
xcode-cache-deriveddata-${{ github.workflow }}-
25+
- name: "Swift Package Manager Cache"
26+
uses: actions/cache@v3
27+
with:
28+
path: .build
29+
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
30+
restore-keys: |
31+
${{ runner.os }}-spm-
2532
2633
# Hint: Use Composite Actions
2734
# - https://stackoverflow.com/a/75735736/9801139

Makefile

+32-5
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,43 @@ force:
1111
Submodule: force
1212
git submodule update --recursive --remote
1313
git add $@
14-
git commit -m "Update $$(git submodule status Submodule/github/rest-api-description)" || true
14+
git commit -m "[Make] Pull $$(git submodule status Submodule/github/rest-api-description)" || true
15+
echo "::notice:: make $@"
1516

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

22-
.PHONY: install
23-
install: $(OPENAPI_FILES)
22+
SWIFT_FILES := $(addsuffix /Client.swift, $(SUBDIRS))
23+
%.swift: $(OPENAPI_FILES)
24+
mint run apple/swift-openapi-generator generate $(@D)/openapi.yml \
25+
--config $(@D)/openapi-generator-config.yml \
26+
--output-directory $(@D)
27+
git add $@ $(@D)/Types.swift
28+
29+
install-files: $(SWIFT_FILES)
30+
git commit -m "[Make] Re-link openapi.yml & re-gen swift files." || true
31+
echo "::notice:: make $@"
32+
33+
#XCFrameworks:
34+
# mint run giginet/Scipio create . \
35+
# --embed-debug-symbols \
36+
# --support-simulators
37+
# echo "::notice:: make $@"
38+
#
39+
#XCFRAMEWORKS := $(wildcard XCFrameworks/*.xcframework)
40+
#ZIP_FILES := $(XCFRAMEWORKS:%.xcframework=%.zip)
41+
#%.zip: %.xcframework
42+
# zip -r "$@" "$^"
43+
# rm -rf "$^"
44+
# git add "$@"
45+
#
46+
#install-zips: XCFrameworks $(ZIP_FILES)
47+
# git commit -m "[Make] Re-gen framework zips" || true
48+
# echo "::notice:: make $@"
49+
50+
install: install-files
2451

2552
.build/docs: ## Need env GITHUB_PAGES is created as 'true'
2653
swift package --allow-writing-to-directory $@ generate-documentation \

Package.resolved

-54
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,5 @@
11
{
22
"pins" : [
3-
{
4-
"identity" : "openapikit",
5-
"kind" : "remoteSourceControl",
6-
"location" : "https://github.com/mattpolzin/OpenAPIKit",
7-
"state" : {
8-
"revision" : "283454875cc6e5b2801d184d65835b92252d1784",
9-
"version" : "3.1.2"
10-
}
11-
},
12-
{
13-
"identity" : "swift-algorithms",
14-
"kind" : "remoteSourceControl",
15-
"location" : "https://github.com/apple/swift-algorithms",
16-
"state" : {
17-
"revision" : "f6919dfc309e7f1b56224378b11e28bab5bccc42",
18-
"version" : "1.2.0"
19-
}
20-
},
21-
{
22-
"identity" : "swift-argument-parser",
23-
"kind" : "remoteSourceControl",
24-
"location" : "https://github.com/apple/swift-argument-parser",
25-
"state" : {
26-
"revision" : "c8ed701b513cf5177118a175d85fbbbcd707ab41",
27-
"version" : "1.3.0"
28-
}
29-
},
303
{
314
"identity" : "swift-collections",
325
"kind" : "remoteSourceControl",
@@ -45,24 +18,6 @@
4518
"version" : "1.0.2"
4619
}
4720
},
48-
{
49-
"identity" : "swift-numerics",
50-
"kind" : "remoteSourceControl",
51-
"location" : "https://github.com/apple/swift-numerics.git",
52-
"state" : {
53-
"revision" : "0a5bc04095a675662cf24757cc0640aa2204253b",
54-
"version" : "1.0.2"
55-
}
56-
},
57-
{
58-
"identity" : "swift-openapi-generator",
59-
"kind" : "remoteSourceControl",
60-
"location" : "https://github.com/apple/swift-openapi-generator",
61-
"state" : {
62-
"revision" : "76994bfc77061c6cfa3b82415613a9dfbfb47f28",
63-
"version" : "1.1.0"
64-
}
65-
},
6621
{
6722
"identity" : "swift-openapi-runtime",
6823
"kind" : "remoteSourceControl",
@@ -80,15 +35,6 @@
8035
"revision" : "aac0a8273fa1186641e0b336da3f1be01aa6a0eb",
8136
"version" : "1.0.0"
8237
}
83-
},
84-
{
85-
"identity" : "yams",
86-
"kind" : "remoteSourceControl",
87-
"location" : "https://github.com/jpsim/Yams",
88-
"state" : {
89-
"revision" : "0d9ee7ea8c4ebd4a489ad7a73d5c6cad55d6fed3",
90-
"version" : "5.0.6"
91-
}
9238
}
9339
],
9440
"version" : 2

Package.swift

+2-6
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ enum GitHubRestAPIOpenAPITag: String, CaseIterable {
6262
resources: [
6363
.copy("openapi-generator-config.yml"),
6464
.copy("openapi.yml"),
65-
],
66-
plugins: [
67-
.plugin(name: "OpenAPIGenerator", package: "swift-openapi-generator"),
6865
]
6966
)
7067
}
@@ -91,7 +88,6 @@ let package = Package(
9188
platforms: [.macOS(.v10_15)],
9289
products: GitHubRestAPIOpenAPITag.allCases.map(\.library),
9390
dependencies: [
94-
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"),
9591
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"),
9692
.package(url: "https://github.com/apple/swift-openapi-urlsession", from: "1.0.0"),
9793
],
@@ -100,10 +96,10 @@ let package = Package(
10096
]
10197
)
10298

103-
let isBuildDocC = ProcessInfo.processInfo.environment["GITHUB_PAGES"] == "true"
99+
let isBuildingDocC = ProcessInfo.processInfo.environment["GITHUB_PAGES"] == "true"
104100

105101
// swift-docs is not needed for package users
106-
if isBuildDocC {
102+
if isBuildingDocC {
107103
package.dependencies += [
108104
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.3.0"),
109105
]

0 commit comments

Comments
 (0)