Skip to content

Commit

Permalink
Merge 2e18dde into master
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Oct 8, 2022
2 parents 7707d1b + 2e18dde commit d63f663
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 17 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
# [exe2dist](https://github.com/rtmigo/exe2dist_dart) #experimental
# [exe2dist](https://github.com/rtmigo/exe2dist) #experimental

A CLI tool that packages a binary executable into a redistributable archive.

`dir/native_binary1``myapp_linux_arm64.tgz`
`dir/native_binary1``myapp_linux_arm64.tgz` with `myapp` inside

`dir/native_binary2``myapp_windows_x86-64.zip`
`dir/native_binary2``myapp_windows_amd64.zip` with `myapp.exe` inside

* detects the architecture for which the executable is compiled
* sets executable bits (`chmod 755`)
* archives a file to an archive appropriate for the platform
* sets executable bits for *nix binaries (`chmod 755`)
* adds `.exe` extension to Windows executables
* packs the binary to an archive appropriate for the platform

I use this tool to automate my CI/CD. Therefore, the functionality is limited to
my use cases.

`exe2dist` works on Linux and MacOS. Compressible binaries can be for other
platforms as well.
`exe2dist` runs on Linux and MacOS.

The executables that are being processed may be for other platforms.

## Install

Expand All @@ -26,7 +28,7 @@ Download and unpack the Linux version to the current directory in one line.

```bash
# install
wget -c https://github.com/rtmigo/exe2dist_dart/releases/download/0.2.2/exe2dist_linux_amd64.tgz -O - | tar -xz
wget -c https://github.com/rtmigo/exe2dist/releases/download/0.2.3/exe2dist_linux_amd64.tgz -O - | tar -xz

# run
./exe2dist
Expand All @@ -35,7 +37,7 @@ wget -c https://github.com/rtmigo/exe2dist_dart/releases/download/0.2.2/exe2dist
Same for the newest version instead of the fixed one.

```bash
wget -c https://github.com/rtmigo/exe2dist_dart/releases/latest/download/exe2dist_linux_amd64.tgz -O - | tar -xz
wget -c https://github.com/rtmigo/exe2dist/releases/latest/download/exe2dist_linux_amd64.tgz -O - | tar -xz
```

## Use
Expand All @@ -58,4 +60,3 @@ exe2dist theapp binaries/* distros/

Copyright © 2022 [Artsiom iG](https://github.com/rtmigo).
Released under the [MIT License](LICENSE).

8 changes: 5 additions & 3 deletions bin/exe2dist.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import 'source/constants.g.dart';

Future<void> main(List<String> arguments) async {
if (arguments.length != 3) {
print("exe2dist: native binary compression tool");
print("(c) Artsiom iG <github.com/rtmigo>");
print("exe2dist (c) Artsiom iG");
print("version $buildVersion ($buildDate)");
print("https://github.com/rtmigo/exe2dist#readme");


print("");
print("Usage:");
print(" exe2dist <source-glob> <program-name> <target-dir>");
print(" exe2dist <program-name> <source-glob> <target-dir>");
print("");
print("Examples:");
print(" exe2dist theapp myfile.exe distros/");
Expand All @@ -28,6 +29,7 @@ Future<void> main(List<String> arguments) async {

try {
for (final entity in Glob(sourceGlob).listSync()) {
// TODO test glob
if (entity.statSync().type == FileSystemEntityType.file) {
await binaryToDist(
sourceExe: File(entity.path),
Expand Down
4 changes: 2 additions & 2 deletions bin/source/constants.g.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Do not edit. Auto-generated
const buildVersion='0.1.0';
const buildVersion='0.2.3';
const buildDate='2022-10-08';
const buildOs='linux';
const buildShortHead='b2b3ccc';
const buildShortHead='28cb6da';
3 changes: 2 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dart script/update_constants.dart
dart compile exe bin/exe2dist.dart -o build/exe2dist.exe
dart script/update_readme.dart
#dart compile exe bin/exe2dist.dart -o build/exe2dist.exe
8 changes: 8 additions & 0 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e && cd "${0%/*}"

dart script/update_constants.dart
dart script/update_readme.dart
git add .
git commit -m "publish" --allow-empty
git push
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: exe2dist
description: Binary executable packaging tool.
version: 0.2.2
version: 0.2.3

environment:
sdk: '>=2.18.0 <3.0.0'
Expand Down
5 changes: 5 additions & 0 deletions script/update_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@ void main() {
"const buildDate='${nowDate()}';\n"
"const buildOs='${Platform.operatingSystem}';\n"
"const buildShortHead='${gitShortHead()}';\n");

//final rmd = File("README.md").readAsStringSync();
//rmd.replaceAll(RegExp("download/[\\d\\.]+/exe2dist"), "download/[\\d\\.]+/exe2dist");

// download/0.2.2/exe2dist
}
28 changes: 28 additions & 0 deletions script/update_readme.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-FileCopyrightText: (c) 2022 Artsiom iG <github.com/rtmigo>
// SPDX-License-Identifier: MIT


import 'dart:io';

import 'package:yaml/yaml.dart';

String nowDate() => DateTime.now().toUtc().toString().substring(0, 10);

String gitShortHead() =>
Process.runSync("git", ["rev-parse", "--short", "HEAD"])
.stdout.toString().trim();

void main() {
final doc = loadYaml(File("pubspec.yaml").readAsStringSync());
final version = doc["version"];

final readmeFile = File("README.md");
final oldText = readmeFile.readAsStringSync();
final newText = oldText.replaceAll(RegExp("download/[\\d\\.]+/exe2dist"), "download/$version/exe2dist");
if (newText!=oldText) {
print("Readme changed");
readmeFile.writeAsStringSync(newText);
} else {
print("Readme not changed");
}
}

0 comments on commit d63f663

Please sign in to comment.