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

Lines changed: 11 additions & 4 deletions
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

Lines changed: 32 additions & 5 deletions
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

Lines changed: 0 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 2 additions & 6 deletions
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)