diff --git a/.travis.yml b/.travis.yml index b5b4cd3..41c26d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,34 +1,32 @@ +os: linux +dist: xenial language: node_js -node_js: "9.11.1" +node_js: '10.18.0' + +jobs: + include: + - os: linux + dist: trusty + services: docker + language: generic cache: + yarn: true directories: - node_modules - $HOME/.cache/electron - $HOME/.cache/electron-builder - - $HOME/.npm/_prebuilds -env: - global: - - ELECTRON_CACHE=$HOME/.cache/electron - - ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder - -jobs: - include: - - stage: Test - script: - - npm test - - stage: Deploy Windows & Mac - if: tag IS present - os: osx - osx_image: xcode10.1 - script: - - npm run release -- --mac --win - before_cache: - - rm -rf $HOME/.cache/electron-builder/wine - - stage: Deploy linux - if: tag IS present - os: linux - dist: trusty - script: - - npm run release +script: + - | + if [ "$TRAVIS_OS_NAME" == "linux" ]; then + docker run --rm \ + -e GH_TOKEN=$GH_TOKEN \ + -v ${PWD}:/project \ + -v ~/.cache/electron:/root/.cache/electron \ + -v ~/.cache/electron-builder:/root/.cache/electron-builder \ + electronuserland/builder:wine \ + /bin/bash -c "yarn --link-duplicates --pure-lockfile && yarn build" + else + echo 'other build method' + fi diff --git a/README.md b/README.md index aa64a34..fd99c5c 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,46 @@ # :vhs: Youtube - Download and Cut ![Repo status](https://www.repostatus.org/badges/latest/active.svg) +[![Build Status](https://travis-ci.com/Markkop/yt-dlandcut.svg?branch=master)](https://travis-ci.com/Markkop/yt-dlandcut) ![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat) ## What it is -This tool downloads a Youtube video to `videos` folder and cuts it given a starting and an ending time.\ -The time must be in the format `HH:MM:SS` and the duration can't be longer than 24 hours. +This app **downloads** youtube videos using [youtube-dl](https://youtube-dl.org/) and **cuts** them with [ffmpeg](https://www.ffmpeg.org/) given starting and ending times. +Currently it only supports **Windows** e **Linux**. ## How to use -- Install NodeJS and ffmpeg -- Clone or download this repository -- Run `npm start` inside the project's folder -- Provide required information -- Check `videos` folder +Download the [latest release](https://github.com/Markkop/yt-dlandcut/releases/latest) for Linux (**.appImage**) or Windows (**.exe**) at the [releases](https://github.com/Markkop/yt-dlandcut/releases/) page. -## User Options +## Options -![An example of user options](http://i.imgur.com/avvmjF8.png) +- **Youtube url\***: normal or shortened url +- **Starting and ending times\***: in HH:MM:SS format +- **Convert to mp3**: if the cut should also be converted to audio +- **Download again**: to not skip download if file exists +- **Open on finish**: opens cut video/audio +- **Custom file name**: instead of video's title + +## How to develop + +Clone this repository and run `yarn` to install dependencies. +Make sure to have `node` and `npm` installed. + +## How to deploy/release + +It looks like `electron-builder` already does a lot when [releasing](https://www.electron.build/configuration/publish) a new version of an Electron app to github. + +The first option to build and release this project's binaries is by running the `package.json` script command `yarn release`. +Electron Builder will know that it should also deploy after building because of this script command name `release` and it will look for a `GH_TOKEN` environment variable to publish to GitHub as a draft release with the package version. +You can set this environment variable by adding `export GH_TOKEN=CHANGE_THIS` to `~/.zshrc` or `~/.bashrc` file and sourcing it with `source ~./zshrc` after [creating a token](https://github.com/settings/tokens/new). + +However, the [recommend way](https://www.electron.build/configuration/publish#recommended-github-releases-workflow) is by using a Continuous Integration service, [TravisCI](https://travis-ci.com/) in this case. +First, a collaborator have to [draft a new release](https://help.github.com/articles/creating-releases/) with the `package.json` version. Then, after every push, TravisCI will run `yarn build`, building the files and providing them as assets in the drafted Github's release. + +For this to happen, it's required to have `"build": { "publish": "github" }` in `package.json` and `GH_TOKEN` as environment variable inside TravisCI dashboard's build settings. +Then after a passing build, a collaborator can simply publish it. +The current `.travis.yml` is similar to this [sample](https://www.electron.build/multi-platform-build#sample-travisyml-to-build-electron-app-for-macos-linux-and-windows). + +It's also possible to deploy using [provider: releases](https://docs.travis-ci.com/user/deployment/releases/) TravisCI deploy configuration. +Here are some examples: [this](https://github.com/lane-c-wagner/electron-ci-boilerplate/blob/master/.travis.yml) and [this](https://github.com/gontarczyk-artur/electron-travis-poc/blob/master/.travis.yml). diff --git a/package.json b/package.json index 56242ad..dbd02dd 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,16 @@ { "name": "yt-dlandcut", - "version": "2.0.0", + "version": "2.0.14", "description": "Download and Cut an Youtube video by its starting and ending times", "repository": "github:markkop/yt-dlandcut", "main": "build/electron/main.js", "scripts": { - "start": "electron .", "postinstall": "electron-builder install-app-deps", + "start": "electron .", + "transpile": "babel src --out-dir build", "pack": "electron-builder --dir", - "dist:linux": "electron-builder build --linux AppImage ", - "dist:win": "electron-builder build --win portable ", - "dist": "electron-builder build --win portable --linux AppImage ", - "build": "babel src --out-dir build", - "release": "build" + "build": "yarn transpile && electron-builder", + "release": "yarn transpile && electron-builder --win --linux" }, "keywords": [], "author": "Marcelo 'Mark' Kopmann", @@ -42,8 +40,12 @@ "node_modules/youtube-dl/bin/youtube-dl", "package.json" ], - "publish": [ - "github" - ] + "linux": { + "target": "appImage" + }, + "win": { + "target": "portable" + }, + "publish": "github" } }