Skip to content

Commit

Permalink
Merge pull request #25 from knoeone/feature/submit-build
Browse files Browse the repository at this point in the history
Feature/submit build
  • Loading branch information
spacedevin authored Dec 3, 2023
2 parents 81e0df5 + fde5e6b commit 823b45a
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 51 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Sample workflow for building and deploying a Jekyll site to GitHub Pages
name: Deploy Jekyll with GitHub Pages dependencies preinstalled

on:
# Runs on pushes targeting the default branch
push:

jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
architecture: x64
- run: flutter config --enable-macos-desktop
- run: flutter build macos
61 changes: 61 additions & 0 deletions lib/models/soundset/publish.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
part of 'soundset.dart';

extension SoundSetPublish on SoundSet {
Future publish() async {
var appTempDir = 'soundsets';

final Directory tempDir = await getTemporaryDirectory();
var hash = sha1.convert(utf8.encode(name)).toString();

var tmpDirName = p.join(tempDir.path, appTempDir, hash, '${name}.eragesoundset');

try {
await Directory(p.join(tempDir.path, appTempDir, hash)).delete(recursive: true);
} catch (e) {
print(e);
}

try {
await Directory(tmpDirName).create(recursive: true);
} catch (e) {
print(e);
}

var files = [
plist!['SoundFile_MailError'],
plist!['SoundFile_MailSent'],
plist!['SoundFile_NewMail'],
plist!['SoundFile_NoMail'],
plist!['SoundFile_Reminder'],
plist!['SoundFile_Welcome'],
plist!['ImageFile_Icon'],
'soundset.plist',
'README.md',
];

void copyFile(assetFilePath) => File(
p.join(
path as String,
assetFilePath,
),
).copySync(
p.join(
tmpDirName,
assetFilePath,
),
);

for (var file in files) {
try {
copyFile(file);
} catch (e) {
print(e);
}
}

return DownloaderSendResponse(
files: files,
path: p.join(tempDir.path, appTempDir, hash),
);
}
}
3 changes: 2 additions & 1 deletion lib/models/soundset/soundset.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ part 'replace_select.dart';
part 'replace_file.dart';
part 'save_audio.dart';
part 'plist.dart';
part 'publish.dart';

class SoundSet {
String name;
Expand Down Expand Up @@ -75,7 +76,7 @@ class SoundSet {
description = json['description'] as String,
repo = json['repo'] as String,
download = json['download'] as String,
icon = json['icon'] as String,
icon = json['icon'],
tmp = true;

factory SoundSet.fromPath(name, path) {
Expand Down
47 changes: 0 additions & 47 deletions lib/utils/downloader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,53 +26,6 @@ class DownloaderSendResponse {
}

abstract class Downloader {
static Future send(SoundSet set) async {
var appTempDir = 'soundsets';

final Directory tempDir = await getTemporaryDirectory();
var name = sha1.convert(utf8.encode(set.name)).toString();

var tmpDirName = path.join(tempDir.path, appTempDir, name, '${set.name}.eragesoundset');

try {
await Directory(path.join(tempDir.path, appTempDir, name)).delete(recursive: true);
} catch (e) {
print(e);
}

try {
await Directory(tmpDirName).create(recursive: true);
} catch (e) {
print(e);
}

var files = [
set.plist!['SoundFile_MailError'],
set.plist!['SoundFile_MailSent'],
set.plist!['SoundFile_NewMail'],
set.plist!['SoundFile_NoMail'],
set.plist!['SoundFile_Reminder'],
set.plist!['SoundFile_Welcome'],
set.plist!['ImageFile_Icon'],
'soundset.plist',
'README.md',
];

void copyFile(name) =>
File(path.join(set.path as String, name)).copySync(path.join(tmpDirName, name));

for (var file in files) {
if (File(file).existsSync()) {
copyFile(file);
}
}

return DownloaderSendResponse(
files: files,
path: path.join(tempDir.path, appTempDir, name),
);
}

static reveal(String file) async {
launchUrl(Uri.parse(file.indexOf('https://') == 0 ? file : 'file://$file'));
}
Expand Down
6 changes: 3 additions & 3 deletions lib/utils/publish.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ abstract class Publish {

if (_publishing != null) {
_publishing = null;
publishSet(_publishing);
publishSet(_publishing as SoundSet);
}
}

Expand All @@ -52,7 +52,7 @@ abstract class Publish {
return false;
}

static publishSet(set) async {
static publishSet(SoundSet set) async {
if (set == null) return;
_publishing = set;
if (!getAuth()) return;
Expand All @@ -75,7 +75,7 @@ abstract class Publish {

List<GitBlob> blobs = [];
List<CreateGitTreeEntry> entries = [];
DownloaderSendResponse sending = await Downloader.send(set);
DownloaderSendResponse sending = await set.publish();

await Future.delayed(Duration(seconds: 1));

Expand Down
2 changes: 2 additions & 0 deletions macos/ci_scripts/ci_post_clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ brew install cocoapods
# Install CocoaPods dependencies.
cd macos && pod install # run `pod install` in the `ios` directory.

flutter build macos

exit 0

0 comments on commit 823b45a

Please sign in to comment.