Skip to content

Commit

Permalink
whole lotta changes, mainly adding auto updates (to be completed)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphtlw committed May 9, 2022
1 parent 1d143fc commit 360443c
Show file tree
Hide file tree
Showing 17 changed files with 434 additions and 22 deletions.
43 changes: 42 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,28 @@ jobs:
action: build
configuration: Release
- name: (debug) show filetree
run: brew install tree && tree -a && tree -a ~/Library/Developer/Xcode/DerivedData
run: |
brew install tree
tree -a
tree -a ~/Library/Developer/Xcode/DerivedData
- name: Compress app bundle
run: |
mv ~/Library/Developer/Xcode/DerivedData/M1necraft-*/Build/Products/Release/M1necraft.app .
zip -r -y M1necraft.app.zip M1necraft.app
- name: Copy Sparkle distribution archive
run: |
cp ~/Library/Developer/Xcode/DerivedData/M1necraft-*/SourcePackages/artifacts/sparkle .
- name: Upload build artifacts
uses: actions/upload-artifact@v2
with:
name: build_artifacts
path: ${{ github.workspace }}/M1necraft.app.zip
retention-days: 1
- name: Upload Sparkle tools
with:
name: sparkle_updater
path: ${{ github.workspace }}/sparkle
retention-days: 1
release:
needs: build
runs-on: macos-latest
Expand All @@ -45,6 +56,36 @@ jobs:
with:
files: ${{ github.workspace }}/M1necraft.app.zip
generate_release_notes: true
update-appcast:
needs: [build, release]
runs-on: macos-latest
env:
APPCAST_WORKDIR: ${{ github.workspace }}/appcast
steps:
- uses: actions/checkout@v3
- name: Create $APPCAST_WORKDIR directory
run: mkdir $APPCAST_WORKDIR
- uses: actions/download-artifact@v2
with:
name: sparkle_updater
path: ${{ env.APPCAST_WORKDIR }}
- name: Import Sparkle keys
working-directory: ${{ env.APPCAST_WORKDIR }}
env:
SPARKLE_PRIVATE_KEY: ${{ secrets.SPARKLE_PRIVATE_KEY }}
run: echo "$SPARKLE_PRIVATE_KEY" | ./bin/generate_keys -f /dev/stdin
- name: Generate Appcast
working-directory: ${{ env.APPCAST_WORKDIR }}
env:
GITHUB_TOKEN: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
run: |
pip install -r requirements.txt
${{ github.workspace }}/scripts/update_appcast
- name: Publish Appcast
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: ${{ env.APPCAST_WORKDIR }}
bump-homebrew-cask:
runs-on: macos-latest
steps:
Expand Down
166 changes: 166 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Script generated files in development
appcast.xml
releases/

# External references for my use when developing
resources/
MCAppleSilicon/

Expand Down Expand Up @@ -115,3 +120,164 @@ fastlane/test_output
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
21 changes: 21 additions & 0 deletions M1necraft.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
643F03BC28201CAD00C0066B /* Path.swift in Sources */ = {isa = PBXBuildFile; fileRef = 643F03BB28201CAD00C0066B /* Path.swift */; };
643F03C0282034B300C0066B /* ErrorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 643F03BF282034B300C0066B /* ErrorView.swift */; };
643F03C92821552800C0066B /* OctoKit in Frameworks */ = {isa = PBXBuildFile; productRef = 643F03C82821552800C0066B /* OctoKit */; };
6464838428256EBB004FB9F2 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = 6464838328256EBB004FB9F2 /* Sparkle */; };
64648386282571DF004FB9F2 /* AppUpdaterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64648385282571DF004FB9F2 /* AppUpdaterView.swift */; };
647D4DC927AE905B00EFC1FE /* AppStoreButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 647D4DC827AE905B00EFC1FE /* AppStoreButtonStyle.swift */; };
647D4DCB27AFC6C900EFC1FE /* Main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 647D4DCA27AFC6C900EFC1FE /* Main.swift */; };
647D4DCD27AFCA2000EFC1FE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 647D4DCC27AFCA2000EFC1FE /* AppDelegate.swift */; };
Expand Down Expand Up @@ -71,6 +73,7 @@
64243AD5276D9DEE009826F8 /* M1necraftUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = M1necraftUITestsLaunchTests.swift; sourceTree = "<group>"; };
643F03BB28201CAD00C0066B /* Path.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Path.swift; sourceTree = "<group>"; };
643F03BF282034B300C0066B /* ErrorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorView.swift; sourceTree = "<group>"; };
64648385282571DF004FB9F2 /* AppUpdaterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppUpdaterView.swift; sourceTree = "<group>"; };
647D4DC827AE905B00EFC1FE /* AppStoreButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppStoreButtonStyle.swift; sourceTree = "<group>"; };
647D4DCA27AFC6C900EFC1FE /* Main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Main.swift; sourceTree = "<group>"; };
647D4DCC27AFCA2000EFC1FE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -98,6 +101,7 @@
643F03C92821552800C0066B /* OctoKit in Frameworks */,
64D0F30C27A98EA900713A33 /* Glob in Frameworks */,
643F03B7281EF63800C0066B /* Path in Frameworks */,
6464838428256EBB004FB9F2 /* Sparkle in Frameworks */,
64CA5E9D2770497400C73E3D /* Alamofire in Frameworks */,
64CA5EA72771DC7800C73E3D /* ZIPFoundation in Frameworks */,
);
Expand Down Expand Up @@ -151,6 +155,7 @@
64EAA53E276F546000A032F1 /* Constants.swift */,
64EAA53A276F448E00A032F1 /* LoginView.swift */,
64CA5EA32771C96E00C73E3D /* Utils.swift */,
64648385282571DF004FB9F2 /* AppUpdaterView.swift */,
643F03BF282034B300C0066B /* ErrorView.swift */,
647D4E1327B172C600EFC1FE /* ModInstallHelpView.swift */,
64243ABB276D9DEE009826F8 /* Assets.xcassets */,
Expand Down Expand Up @@ -226,6 +231,7 @@
64D0F30B27A98EA900713A33 /* Glob */,
643F03B6281EF63800C0066B /* Path */,
643F03C82821552800C0066B /* OctoKit */,
6464838328256EBB004FB9F2 /* Sparkle */,
);
productName = M1necraft;
productReference = 64243AB4276D9DED009826F8 /* M1necraft.app */;
Expand Down Expand Up @@ -305,6 +311,7 @@
64D0F30A27A98EA900713A33 /* XCRemoteSwiftPackageReference "Glob" */,
643F03B5281EF63800C0066B /* XCRemoteSwiftPackageReference "Path" */,
643F03C72821552800C0066B /* XCRemoteSwiftPackageReference "octokit" */,
6464838228256EBB004FB9F2 /* XCRemoteSwiftPackageReference "Sparkle" */,
);
productRefGroup = 64243AB5276D9DED009826F8 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -358,6 +365,7 @@
64EAA53B276F448E00A032F1 /* LoginView.swift in Sources */,
647D4E1627B17CEF00EFC1FE /* CloseButton.swift in Sources */,
64243ABA276D9DED009826F8 /* ContentView.swift in Sources */,
64648386282571DF004FB9F2 /* AppUpdaterView.swift in Sources */,
64D0F31027AAB11500713A33 /* SetupView.swift in Sources */,
64EAA53D276F518F00A032F1 /* LauncherView.swift in Sources */,
647D4DCF27AFCECC00EFC1FE /* AppCompat.swift in Sources */,
Expand Down Expand Up @@ -713,6 +721,14 @@
kind = branch;
};
};
6464838228256EBB004FB9F2 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/sparkle-project/Sparkle";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.0.0;
};
};
64CA5E9B2770497400C73E3D /* XCRemoteSwiftPackageReference "Alamofire" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/Alamofire/Alamofire";
Expand Down Expand Up @@ -750,6 +766,11 @@
package = 643F03C72821552800C0066B /* XCRemoteSwiftPackageReference "octokit" */;
productName = OctoKit;
};
6464838328256EBB004FB9F2 /* Sparkle */ = {
isa = XCSwiftPackageProductDependency;
package = 6464838228256EBB004FB9F2 /* XCRemoteSwiftPackageReference "Sparkle" */;
productName = Sparkle;
};
64CA5E9C2770497400C73E3D /* Alamofire */ = {
isa = XCSwiftPackageProductDependency;
package = 64CA5E9B2770497400C73E3D /* XCRemoteSwiftPackageReference "Alamofire" */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@
"version" : "3.1.0"
}
},
{
"identity" : "sparkle",
"kind" : "remoteSourceControl",
"location" : "https://github.com/sparkle-project/Sparkle",
"state" : {
"revision" : "286edd1fa22505a9e54d170e9fd07d775ea233f2",
"version" : "2.1.0"
}
},
{
"identity" : "zipfoundation",
"kind" : "remoteSourceControl",
Expand Down
7 changes: 6 additions & 1 deletion M1necraft/AppCompat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ struct M1necraftAppCompat {
class AppDelegateCompat: AppDelegate {
var window: NSWindow!

@StateObject var m = ContentView.ViewModel()
@StateObject var updater = UpdaterViewModel()

@MainActor func application(_ application: NSApplication) {
let contentView = ContentView(m: ContentView.ViewModel())
let contentView = ContentView()
.environmentObject(m)
.environmentObject(updater)

window = NSWindow(
contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),
Expand Down
39 changes: 39 additions & 0 deletions M1necraft/AppUpdaterView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// AppUpdaterView.swift
// M1necraft
//
// Created by Raphael Tang on 6/5/22.
//

import SwiftUI
import Sparkle

final class UpdaterViewModel: ObservableObject {
private let updaterController: SPUStandardUpdaterController

@Published var canCheckForUpdates = false

init() {
updaterController = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil)
updaterController.updater.publisher(for: \.canCheckForUpdates).assign(to: &$canCheckForUpdates)
}

func checkForUpdates() {
updaterController.checkForUpdates(nil)
}
}

struct AppUpdaterView: View {
@ObservedObject var updater: UpdaterViewModel

var body: some View {
Button("Check for Updates...", action: updater.checkForUpdates)
.disabled(!updater.canCheckForUpdates)
}
}

struct AppUpdaterView_Previews: PreviewProvider {
static var previews: some View {
AppUpdaterView(updater: UpdaterViewModel())
}
}
Loading

0 comments on commit 360443c

Please sign in to comment.