Skip to content

Commit 360443c

Browse files
committed
whole lotta changes, mainly adding auto updates (to be completed)
1 parent 1d143fc commit 360443c

File tree

17 files changed

+434
-22
lines changed

17 files changed

+434
-22
lines changed

.github/workflows/main.yml

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,28 @@ jobs:
2121
action: build
2222
configuration: Release
2323
- name: (debug) show filetree
24-
run: brew install tree && tree -a && tree -a ~/Library/Developer/Xcode/DerivedData
24+
run: |
25+
brew install tree
26+
tree -a
27+
tree -a ~/Library/Developer/Xcode/DerivedData
2528
- name: Compress app bundle
2629
run: |
2730
mv ~/Library/Developer/Xcode/DerivedData/M1necraft-*/Build/Products/Release/M1necraft.app .
2831
zip -r -y M1necraft.app.zip M1necraft.app
32+
- name: Copy Sparkle distribution archive
33+
run: |
34+
cp ~/Library/Developer/Xcode/DerivedData/M1necraft-*/SourcePackages/artifacts/sparkle .
2935
- name: Upload build artifacts
3036
uses: actions/upload-artifact@v2
3137
with:
3238
name: build_artifacts
3339
path: ${{ github.workspace }}/M1necraft.app.zip
3440
retention-days: 1
41+
- name: Upload Sparkle tools
42+
with:
43+
name: sparkle_updater
44+
path: ${{ github.workspace }}/sparkle
45+
retention-days: 1
3546
release:
3647
needs: build
3748
runs-on: macos-latest
@@ -45,6 +56,36 @@ jobs:
4556
with:
4657
files: ${{ github.workspace }}/M1necraft.app.zip
4758
generate_release_notes: true
59+
update-appcast:
60+
needs: [build, release]
61+
runs-on: macos-latest
62+
env:
63+
APPCAST_WORKDIR: ${{ github.workspace }}/appcast
64+
steps:
65+
- uses: actions/checkout@v3
66+
- name: Create $APPCAST_WORKDIR directory
67+
run: mkdir $APPCAST_WORKDIR
68+
- uses: actions/download-artifact@v2
69+
with:
70+
name: sparkle_updater
71+
path: ${{ env.APPCAST_WORKDIR }}
72+
- name: Import Sparkle keys
73+
working-directory: ${{ env.APPCAST_WORKDIR }}
74+
env:
75+
SPARKLE_PRIVATE_KEY: ${{ secrets.SPARKLE_PRIVATE_KEY }}
76+
run: echo "$SPARKLE_PRIVATE_KEY" | ./bin/generate_keys -f /dev/stdin
77+
- name: Generate Appcast
78+
working-directory: ${{ env.APPCAST_WORKDIR }}
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
81+
run: |
82+
pip install -r requirements.txt
83+
${{ github.workspace }}/scripts/update_appcast
84+
- name: Publish Appcast
85+
uses: JamesIves/github-pages-deploy-action@v4.3.3
86+
with:
87+
branch: gh-pages
88+
folder: ${{ env.APPCAST_WORKDIR }}
4889
bump-homebrew-cask:
4990
runs-on: macos-latest
5091
steps:

.gitignore

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Script generated files in development
2+
appcast.xml
3+
releases/
4+
5+
# External references for my use when developing
16
resources/
27
MCAppleSilicon/
38

@@ -115,3 +120,164 @@ fastlane/test_output
115120
# https://github.com/johnno1962/injectionforxcode
116121

117122
iOSInjectionProject/
123+
124+
# Byte-compiled / optimized / DLL files
125+
__pycache__/
126+
*.py[cod]
127+
*$py.class
128+
129+
# C extensions
130+
*.so
131+
132+
# Distribution / packaging
133+
.Python
134+
build/
135+
develop-eggs/
136+
dist/
137+
downloads/
138+
eggs/
139+
.eggs/
140+
lib/
141+
lib64/
142+
parts/
143+
sdist/
144+
var/
145+
wheels/
146+
share/python-wheels/
147+
*.egg-info/
148+
.installed.cfg
149+
*.egg
150+
MANIFEST
151+
152+
# PyInstaller
153+
# Usually these files are written by a python script from a template
154+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
155+
*.manifest
156+
*.spec
157+
158+
# Installer logs
159+
pip-log.txt
160+
pip-delete-this-directory.txt
161+
162+
# Unit test / coverage reports
163+
htmlcov/
164+
.tox/
165+
.nox/
166+
.coverage
167+
.coverage.*
168+
.cache
169+
nosetests.xml
170+
coverage.xml
171+
*.cover
172+
*.py,cover
173+
.hypothesis/
174+
.pytest_cache/
175+
cover/
176+
177+
# Translations
178+
*.mo
179+
*.pot
180+
181+
# Django stuff:
182+
*.log
183+
local_settings.py
184+
db.sqlite3
185+
db.sqlite3-journal
186+
187+
# Flask stuff:
188+
instance/
189+
.webassets-cache
190+
191+
# Scrapy stuff:
192+
.scrapy
193+
194+
# Sphinx documentation
195+
docs/_build/
196+
197+
# PyBuilder
198+
.pybuilder/
199+
target/
200+
201+
# Jupyter Notebook
202+
.ipynb_checkpoints
203+
204+
# IPython
205+
profile_default/
206+
ipython_config.py
207+
208+
# pyenv
209+
# For a library or package, you might want to ignore these files since the code is
210+
# intended to run in multiple environments; otherwise, check them in:
211+
# .python-version
212+
213+
# pipenv
214+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
215+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
216+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
217+
# install all needed dependencies.
218+
#Pipfile.lock
219+
220+
# poetry
221+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
222+
# This is especially recommended for binary packages to ensure reproducibility, and is more
223+
# commonly ignored for libraries.
224+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
225+
#poetry.lock
226+
227+
# pdm
228+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
229+
#pdm.lock
230+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
231+
# in version control.
232+
# https://pdm.fming.dev/#use-with-ide
233+
.pdm.toml
234+
235+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
236+
__pypackages__/
237+
238+
# Celery stuff
239+
celerybeat-schedule
240+
celerybeat.pid
241+
242+
# SageMath parsed files
243+
*.sage.py
244+
245+
# Environments
246+
.env
247+
.venv
248+
env/
249+
venv/
250+
ENV/
251+
env.bak/
252+
venv.bak/
253+
254+
# Spyder project settings
255+
.spyderproject
256+
.spyproject
257+
258+
# Rope project settings
259+
.ropeproject
260+
261+
# mkdocs documentation
262+
/site
263+
264+
# mypy
265+
.mypy_cache/
266+
.dmypy.json
267+
dmypy.json
268+
269+
# Pyre type checker
270+
.pyre/
271+
272+
# pytype static type analyzer
273+
.pytype/
274+
275+
# Cython debug symbols
276+
cython_debug/
277+
278+
# PyCharm
279+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
280+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
281+
# and can be added to the global gitignore or merged into this file. For a more nuclear
282+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
283+
#.idea/

M1necraft.xcodeproj/project.pbxproj

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
643F03BC28201CAD00C0066B /* Path.swift in Sources */ = {isa = PBXBuildFile; fileRef = 643F03BB28201CAD00C0066B /* Path.swift */; };
1919
643F03C0282034B300C0066B /* ErrorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 643F03BF282034B300C0066B /* ErrorView.swift */; };
2020
643F03C92821552800C0066B /* OctoKit in Frameworks */ = {isa = PBXBuildFile; productRef = 643F03C82821552800C0066B /* OctoKit */; };
21+
6464838428256EBB004FB9F2 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = 6464838328256EBB004FB9F2 /* Sparkle */; };
22+
64648386282571DF004FB9F2 /* AppUpdaterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64648385282571DF004FB9F2 /* AppUpdaterView.swift */; };
2123
647D4DC927AE905B00EFC1FE /* AppStoreButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 647D4DC827AE905B00EFC1FE /* AppStoreButtonStyle.swift */; };
2224
647D4DCB27AFC6C900EFC1FE /* Main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 647D4DCA27AFC6C900EFC1FE /* Main.swift */; };
2325
647D4DCD27AFCA2000EFC1FE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 647D4DCC27AFCA2000EFC1FE /* AppDelegate.swift */; };
@@ -71,6 +73,7 @@
7173
64243AD5276D9DEE009826F8 /* M1necraftUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = M1necraftUITestsLaunchTests.swift; sourceTree = "<group>"; };
7274
643F03BB28201CAD00C0066B /* Path.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Path.swift; sourceTree = "<group>"; };
7375
643F03BF282034B300C0066B /* ErrorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorView.swift; sourceTree = "<group>"; };
76+
64648385282571DF004FB9F2 /* AppUpdaterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppUpdaterView.swift; sourceTree = "<group>"; };
7477
647D4DC827AE905B00EFC1FE /* AppStoreButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppStoreButtonStyle.swift; sourceTree = "<group>"; };
7578
647D4DCA27AFC6C900EFC1FE /* Main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Main.swift; sourceTree = "<group>"; };
7679
647D4DCC27AFCA2000EFC1FE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@@ -98,6 +101,7 @@
98101
643F03C92821552800C0066B /* OctoKit in Frameworks */,
99102
64D0F30C27A98EA900713A33 /* Glob in Frameworks */,
100103
643F03B7281EF63800C0066B /* Path in Frameworks */,
104+
6464838428256EBB004FB9F2 /* Sparkle in Frameworks */,
101105
64CA5E9D2770497400C73E3D /* Alamofire in Frameworks */,
102106
64CA5EA72771DC7800C73E3D /* ZIPFoundation in Frameworks */,
103107
);
@@ -151,6 +155,7 @@
151155
64EAA53E276F546000A032F1 /* Constants.swift */,
152156
64EAA53A276F448E00A032F1 /* LoginView.swift */,
153157
64CA5EA32771C96E00C73E3D /* Utils.swift */,
158+
64648385282571DF004FB9F2 /* AppUpdaterView.swift */,
154159
643F03BF282034B300C0066B /* ErrorView.swift */,
155160
647D4E1327B172C600EFC1FE /* ModInstallHelpView.swift */,
156161
64243ABB276D9DEE009826F8 /* Assets.xcassets */,
@@ -226,6 +231,7 @@
226231
64D0F30B27A98EA900713A33 /* Glob */,
227232
643F03B6281EF63800C0066B /* Path */,
228233
643F03C82821552800C0066B /* OctoKit */,
234+
6464838328256EBB004FB9F2 /* Sparkle */,
229235
);
230236
productName = M1necraft;
231237
productReference = 64243AB4276D9DED009826F8 /* M1necraft.app */;
@@ -305,6 +311,7 @@
305311
64D0F30A27A98EA900713A33 /* XCRemoteSwiftPackageReference "Glob" */,
306312
643F03B5281EF63800C0066B /* XCRemoteSwiftPackageReference "Path" */,
307313
643F03C72821552800C0066B /* XCRemoteSwiftPackageReference "octokit" */,
314+
6464838228256EBB004FB9F2 /* XCRemoteSwiftPackageReference "Sparkle" */,
308315
);
309316
productRefGroup = 64243AB5276D9DED009826F8 /* Products */;
310317
projectDirPath = "";
@@ -358,6 +365,7 @@
358365
64EAA53B276F448E00A032F1 /* LoginView.swift in Sources */,
359366
647D4E1627B17CEF00EFC1FE /* CloseButton.swift in Sources */,
360367
64243ABA276D9DED009826F8 /* ContentView.swift in Sources */,
368+
64648386282571DF004FB9F2 /* AppUpdaterView.swift in Sources */,
361369
64D0F31027AAB11500713A33 /* SetupView.swift in Sources */,
362370
64EAA53D276F518F00A032F1 /* LauncherView.swift in Sources */,
363371
647D4DCF27AFCECC00EFC1FE /* AppCompat.swift in Sources */,
@@ -713,6 +721,14 @@
713721
kind = branch;
714722
};
715723
};
724+
6464838228256EBB004FB9F2 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
725+
isa = XCRemoteSwiftPackageReference;
726+
repositoryURL = "https://github.com/sparkle-project/Sparkle";
727+
requirement = {
728+
kind = upToNextMajorVersion;
729+
minimumVersion = 2.0.0;
730+
};
731+
};
716732
64CA5E9B2770497400C73E3D /* XCRemoteSwiftPackageReference "Alamofire" */ = {
717733
isa = XCRemoteSwiftPackageReference;
718734
repositoryURL = "https://github.com/Alamofire/Alamofire";
@@ -750,6 +766,11 @@
750766
package = 643F03C72821552800C0066B /* XCRemoteSwiftPackageReference "octokit" */;
751767
productName = OctoKit;
752768
};
769+
6464838328256EBB004FB9F2 /* Sparkle */ = {
770+
isa = XCSwiftPackageProductDependency;
771+
package = 6464838228256EBB004FB9F2 /* XCRemoteSwiftPackageReference "Sparkle" */;
772+
productName = Sparkle;
773+
};
753774
64CA5E9C2770497400C73E3D /* Alamofire */ = {
754775
isa = XCSwiftPackageProductDependency;
755776
package = 64CA5E9B2770497400C73E3D /* XCRemoteSwiftPackageReference "Alamofire" */;

M1necraft.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

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

M1necraft/AppCompat.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ struct M1necraftAppCompat {
2727
class AppDelegateCompat: AppDelegate {
2828
var window: NSWindow!
2929

30+
@StateObject var m = ContentView.ViewModel()
31+
@StateObject var updater = UpdaterViewModel()
32+
3033
@MainActor func application(_ application: NSApplication) {
31-
let contentView = ContentView(m: ContentView.ViewModel())
34+
let contentView = ContentView()
35+
.environmentObject(m)
36+
.environmentObject(updater)
3237

3338
window = NSWindow(
3439
contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),

M1necraft/AppUpdaterView.swift

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//
2+
// AppUpdaterView.swift
3+
// M1necraft
4+
//
5+
// Created by Raphael Tang on 6/5/22.
6+
//
7+
8+
import SwiftUI
9+
import Sparkle
10+
11+
final class UpdaterViewModel: ObservableObject {
12+
private let updaterController: SPUStandardUpdaterController
13+
14+
@Published var canCheckForUpdates = false
15+
16+
init() {
17+
updaterController = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil)
18+
updaterController.updater.publisher(for: \.canCheckForUpdates).assign(to: &$canCheckForUpdates)
19+
}
20+
21+
func checkForUpdates() {
22+
updaterController.checkForUpdates(nil)
23+
}
24+
}
25+
26+
struct AppUpdaterView: View {
27+
@ObservedObject var updater: UpdaterViewModel
28+
29+
var body: some View {
30+
Button("Check for Updates...", action: updater.checkForUpdates)
31+
.disabled(!updater.canCheckForUpdates)
32+
}
33+
}
34+
35+
struct AppUpdaterView_Previews: PreviewProvider {
36+
static var previews: some View {
37+
AppUpdaterView(updater: UpdaterViewModel())
38+
}
39+
}

0 commit comments

Comments
 (0)