Skip to content

Commit

Permalink
Download CLI with SuperAdmin + Github release (#290)
Browse files Browse the repository at this point in the history
* feat(app) add download cli

* feat(ci) add release to actions

* fix(app) cli binary names
  • Loading branch information
helderbetiol authored Nov 16, 2023
1 parent 7dbdd76 commit 4ce753c
Show file tree
Hide file tree
Showing 14 changed files with 307 additions and 7 deletions.
47 changes: 47 additions & 0 deletions .github/actions/build/API/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: API Publish
description: Publish API into Nextcloud

inputs:
VERSION:
description: "Version of the API"
required: true
NEXT_CREDENTIALS:
description: "NEXT_CREDENTIALS"
required: true

runs:
using: "composite"
steps:
- uses: actions/[email protected]

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'

- name: Build
shell: bash
run: |
cd API
make allos
- name: Upload result for job
uses: actions/upload-artifact@v3
with:
name: api-build
path: |
API/OGrEE_API_Linux_x64
API/OGrEE_API_OSX_x64
API/OGrEE_API_Win_x64
- name: Send to Nextcloud
shell: bash
env:
NEXT_CREDENTIALS: ${{ inputs.NEXT_CREDENTIALS }}
NEXT_ADDR: https://nextcloud.ditrit.io/remote.php/dav/files/github.actions/Ogree/1_Core/1_API/bin/${{ inputs.VERSION }}
run: |
cd API
curl -u $NEXT_CREDENTIALS -X MKCOL $NEXT_ADDR
curl -u $NEXT_CREDENTIALS -T OGrEE_API_Linux_x64 $NEXT_ADDR/OGrEE_API_Linux_${{ inputs.VERSION }}
curl -u $NEXT_CREDENTIALS -T OGrEE_API_OSX_x64 $NEXT_ADDR/OGrEE_API_OSX_${{ inputs.VERSION }}
curl -u $NEXT_CREDENTIALS -T OGrEE_API_Win_x64 $NEXT_ADDR/OGrEE_API_Win_${{ inputs.VERSION }}.exe
11 changes: 10 additions & 1 deletion .github/actions/build/CLI/action.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: CLI Publish
description: PUblish CLI into Nextcloud
description: Publish CLI into Nextcloud

inputs:
VERSION:
Expand All @@ -25,6 +25,15 @@ runs:
cd CLI
make main && make mac && make win
- name: Upload result for job
uses: actions/upload-artifact@v3
with:
name: cli-build
path: |
CLI/cli
CLI/cli.mac
CLI/cli.exe
- name: Send to Nextcloud
shell: bash
env:
Expand Down
6 changes: 6 additions & 0 deletions .github/actions/build/flutter-app/linux/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,10 @@ runs:
zip -r ./OGrEE_APP_Web.zip build/web/*
curl -u $NEXT_CREDENTIALS -T OGrEE_APP_Web.zip $NEXT_ADDR/OGrEE_APP_Web_${{ inputs.VERSION }}.zip
- name: Upload result for job
uses: actions/upload-artifact@v3
with:
name: app-web-build
path: APP/OGrEE_APP_Web.zip

6 changes: 6 additions & 0 deletions .github/actions/build/multi-docker/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ runs:
TEAM_USERNAME: ${{ inputs.TEAM_USERNAME }}
TEAM_PASSWORD: ${{ inputs.TEAM_PASSWORD }}

- name: Publish API on Nexcloud
uses: ./.github/actions/build/API
with:
VERSION: ${{ env.VERSION }}
NEXT_CREDENTIALS: ${{ inputs.NEXT_CREDENTIALS }}

- name: Publish CLI on Nexcloud
uses: ./.github/actions/build/CLI
with:
Expand Down
6 changes: 6 additions & 0 deletions .github/actions/build/windows/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ runs:
run: |
"%programfiles(x86)%\Inno Setup 6\iscc.exe" "inno-wininstaller.iss"
shell: cmd

- name: Upload result for job
uses: actions/upload-artifact@v3
with:
name: app-win-build
path: Output/ogree-app-installer.exe

- name: Send to Nextcloud
shell: pwsh
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/build-docker-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:

build-app-windows:
name: 🏗️📤 Build APP and Installer for Windows
permissions: write-all
needs: build-docker
runs-on: windows-latest
steps:
Expand All @@ -63,4 +64,22 @@ jobs:
VERSION: ${{ env.VERSION }}
NEXT_CREDENTIALS: ${{ secrets.NEXT_CREDENTIALS }}

- name: Download all artifacts
uses: actions/download-artifact@v3

- name: 🏷️ Create release if release
if: ${{ !contains(env.ENVIRONMENT, 'Candidate') }}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.VERSION }}
files: |
cli-build/cli.exe
cli-build/cli
cli-build/cli.mac
api-build/OGrEE_API_Linux_x64
api-build/OGrEE_API_OSX_x64
api-build/OGrEE_API_Win_x64
app-web-build/OGrEE_APP_Web.zip
app-win-build/ogree-app-installer.exe
8 changes: 8 additions & 0 deletions APP/lib/common/snackbar.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void showSnackBar(
ScaffoldMessengerState messenger,
String message, {
Duration duration = const Duration(seconds: 6),
bool isError = false,
bool isSuccess = false,
String copyText = "",
}) {
var color = Colors.blueGrey.shade900;
if (isError) color = Colors.red.shade900;
Expand All @@ -18,6 +20,12 @@ void showSnackBar(
backgroundColor: color,
content: Text(message),
duration: duration,
action: copyText == ""
? null
: SnackBarAction(
label: "COPY",
onPressed: () =>
Clipboard.setData(ClipboardData(text: copyText))),
showCloseIcon: duration.inSeconds > 5,
),
);
Expand Down
7 changes: 7 additions & 0 deletions APP/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"reset": "Reset",
"close": "Close",
"unavailable": "Unavailable",
"download": "Download",

"welcome": "Welcome to OGrEE",
"welcomeConnect": "Login to your personal space:",
Expand Down Expand Up @@ -133,6 +134,12 @@
"downloadBackup": "Download backup archive",
"backupInfoMessage": "A backup archive file will be created in the host machine of the database container.\nIf this option is selected, this file will also be downloaded in your current machine.",

"tools": "Tools",
"downloadCli": "Download latest CLI",
"downloadCliTitle": "Download latest CLI",
"selectOS": "Select OS:",
"fileSavedTo": "File succesfully saved to:",
"unableDownload": "Unable to download file",
"onlyOneTool": "Only one {tool} is allowed",
"selectSQL": "Select SQL file",
"importNetbox": "Import Netbox Dump",
Expand Down
7 changes: 7 additions & 0 deletions APP/lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"reset": "Réinitialiser",
"close": "Fermer",
"unavailable": "Indisponible",
"download": "Télécharger",

"@welcome": { "description": "Login Page" },
"welcome": "Bienvenue sur OGrEE",
Expand Down Expand Up @@ -163,6 +164,12 @@
"downloadBackup": "Télécharger archive de backup",
"backupInfoMessage": "Un fichier de backup sera créé dans la machine hôte de ce déploiement Docker.\nSi sélectionné, le fichier sera aussi télécharger dans votre machine.",

"tools": "Outils",
"downloadCli": "Télécharger la CLI",
"downloadCliTitle": "Télécharger la CLI la plus récente",
"selectOS": "Choisir SO :" ,
"fileSavedTo": "Téléchargé dans :",
"unableDownload": "Impossible de télécharger le fichier",
"onlyOneTool": "Seul un {tool} est possible",
"@onlyOneTool": {
"placeholders": {
Expand Down
2 changes: 1 addition & 1 deletion APP/lib/models/netbox.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'dart:convert';

enum Tools { netbox, opendcim }
enum Tools { netbox, opendcim, cli }

class Netbox {
String userName;
Expand Down
10 changes: 9 additions & 1 deletion APP/lib/pages/projects_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import 'package:ogree_app/widgets/projects/project_card.dart';
import 'package:ogree_app/widgets/tenants/tenant_card.dart';
import 'package:ogree_app/widgets/tools/create_netbox_popup.dart';
import 'package:ogree_app/widgets/tools/create_opendcim_popup.dart';
import 'package:ogree_app/widgets/tools/download_cli_popup.dart';
import 'package:ogree_app/widgets/tools/tool_card.dart';

class ProjectsPage extends StatefulWidget {
Expand Down Expand Up @@ -226,6 +227,10 @@ class _ProjectsPageState extends State<ProjectsPage> {
value: Tools.opendcim,
child: Text("${localeMsg.create} OpenDCIM"),
),
PopupMenuItem(
value: Tools.cli,
child: Text(localeMsg.downloadCli),
),
];

return ElevatedButton(
Expand Down Expand Up @@ -256,6 +261,9 @@ class _ProjectsPageState extends State<ProjectsPage> {
CreateOpenDcimPopup(parentCallback: refreshFromChildren));
}
break;
case Tools.cli:
showCustomPopup(context, DownloadCliPopup());
break;
}
},
itemBuilder: (_) => entries,
Expand All @@ -267,7 +275,7 @@ class _ProjectsPageState extends State<ProjectsPage> {
top: 8, bottom: 8, right: _isSmallDisplay ? 0 : 10),
child: const Icon(Icons.timeline),
),
_isSmallDisplay ? Container() : Text("${localeMsg.create} tools"),
_isSmallDisplay ? Container() : Text(localeMsg.tools),
],
),
),
Expand Down
2 changes: 1 addition & 1 deletion APP/lib/pages/results_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ class _ResultsPageState extends State<ResultsPage> {
}
file.writeAsBytes(bytes, flush: true).then((value) => showSnackBar(
ScaffoldMessenger.of(context),
"File succesfully saved to: $fileName"));
"${AppLocalizations.of(context)!.fileSavedTo} $fileName"));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions APP/lib/widgets/tenants/popups/backup_popup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ class _BackupPopupState extends State<BackupPopup> {
var path = (await getApplicationDocumentsDirectory()).path;
var fileName = '$path/$filename';
var file = File(fileName);
file.writeAsBytes(value, flush: true).then((value) =>
showSnackBar(
messenger, "File succesfully saved to: $fileName"));
file.writeAsBytes(value, flush: true).then((value) => showSnackBar(
messenger,
"${AppLocalizations.of(context)!.fileSavedTo} $fileName"));
}
} else {
showSnackBar(messenger, value, isSuccess: true);
Expand Down
Loading

0 comments on commit 4ce753c

Please sign in to comment.