mirror of
https://github.com/CringeStudios/element-desktop.git
synced 2025-01-18 07:24:59 +01:00
Set version automatically
Convert the check script to a script that sets the version to match whatever Riot is being packaged. Add a README because the two ways of interacting with versions are starting to get complex to reason about. Also add a docker build script.
This commit is contained in:
parent
c43a742df4
commit
3b58fdc8d9
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
/dist
|
||||
/webapp
|
||||
/webapp.asar
|
||||
/packages
|
||||
/deploys
|
||||
/node_modules
|
69
README
69
README
@ -5,3 +5,72 @@ This is *not* where the source for Riot desktop lives... yet. As of now,
|
||||
it still lives in the main riot-web repo: https://github.com/vector-im/riot-web
|
||||
|
||||
This is an experimental split-out of the Riot desktop code from the main repo.
|
||||
|
||||
Fetching Riot
|
||||
=============
|
||||
Since this package is just the Electron wrapper for Riot, it doesn't contain any of the Riot code,
|
||||
so the first step is to get a working copy of Riot. There are a few ways of doing this:
|
||||
|
||||
```
|
||||
# Fetch the prebuilt release Riot package from the riot.im GitHub releases page. The version
|
||||
# fetched will be the same as the local riot-desktop package.
|
||||
yarn run fetch --noverify
|
||||
```
|
||||
|
||||
...or if you'd like to use GPG to verify the downloaded package:
|
||||
```
|
||||
# Fetch the Riot public key from the riot.im web server over a secure connection and import
|
||||
# it into your local GPG keychain (you'll need GPG installed). You only need to to do this
|
||||
# once.
|
||||
yarn run fetch --importkey
|
||||
# Fetch the package and verify the signature
|
||||
yarn run fetch
|
||||
```
|
||||
|
||||
...or either of the above, but fetching a specific version of Riot:
|
||||
```
|
||||
# Fetch the prebuilt release Riot package from the riot.im GitHub releases page. The version
|
||||
# fetched will be the same as the local riot-desktop package.
|
||||
yarn run fetch --noverify v1.5.6
|
||||
```
|
||||
|
||||
If you only want to run the app locally and don't need to build packages, you can
|
||||
provide the `webapp` directory directly:
|
||||
```
|
||||
# Assuming you've checked out and built a copy of riot-web in ../riot-web
|
||||
ln -s ../riot-web/webapp ./
|
||||
```
|
||||
|
||||
[TODO: add support for fetching develop builds, arbitrary URLs and arbitrary paths]
|
||||
|
||||
|
||||
Building
|
||||
========
|
||||
Now you have a copy of Riot, you're ready to build packages. If you'd just like to
|
||||
run Riot locally, skip to the next section.
|
||||
|
||||
```
|
||||
yarn run build
|
||||
```
|
||||
This will do a couple of things:
|
||||
* Run the `setversion` script to set the local package version to match whatever
|
||||
version of Riot you installed above.
|
||||
* Run electron-builder to build a package. The package built will match the operating system
|
||||
you're running the build process on.
|
||||
|
||||
You can also build using docker, which will always produce the linux package:
|
||||
```
|
||||
yarn run dockerbuild
|
||||
```
|
||||
|
||||
After running, the packages should be in `dist/`.
|
||||
|
||||
Starting
|
||||
========
|
||||
If you'd just like to run the electron app locally for development:
|
||||
```
|
||||
# Install electron - we don't normally need electron itself as it's provided
|
||||
# by electron-builder when building packages
|
||||
yarn add electron
|
||||
yarn start
|
||||
```
|
||||
|
@ -14,10 +14,10 @@
|
||||
"scripts": {
|
||||
"mkdirs": "mkdirp packages deploys",
|
||||
"fetch": "yarn run mkdirs && node scripts/fetch-package.js",
|
||||
"check": "node scripts/check-webapp.js",
|
||||
"setversion": "node scripts/set-version.js",
|
||||
"start": "electron .",
|
||||
"lint": "eslint src/",
|
||||
"build": "yarn run check && electron-builder",
|
||||
"build": "yarn run setversion && electron-builder",
|
||||
"clean": "rimraf webapp.asar dist packages deploys"
|
||||
},
|
||||
"dependencies": {
|
||||
|
@ -1,15 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fs = require('fs').promises;
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
const webappDir = await fs.stat('webapp.asar');
|
||||
return 0;
|
||||
} catch (e) {
|
||||
console.log("No 'webapp.asar' found. Run 'yarn run fetch'");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
main().then((ret) => process.exit(ret));
|
12
scripts/dockerbuild.sh
Executable file
12
scripts/dockerbuild.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Taken from https://www.electron.build/multi-platform-build#docker
|
||||
docker run --rm -ti \
|
||||
--env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS_TAG|TRAVIS|TRAVIS_REPO_|TRAVIS_BUILD_|TRAVIS_BRANCH|TRAVIS_PULL_REQUEST_|APPVEYOR_|CSC_|GH_|GITHUB_|BT_|AWS_|STRIP|BUILD_') \
|
||||
--env ELECTRON_CACHE="/root/.cache/electron" \
|
||||
--env ELECTRON_BUILDER_CACHE="/root/.cache/electron-builder" \
|
||||
-v ${PWD}:/project \
|
||||
-v ${PWD##*/}-node-modules:/project/node_modules \
|
||||
-v ~/.cache/electron:/root/.cache/electron \
|
||||
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
|
||||
electronuserland/builder yarn run build
|
39
scripts/set-version.js
Executable file
39
scripts/set-version.js
Executable file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/*
|
||||
* Checks for the pre3sence of a webapp, inspects its version and sets the
|
||||
* version metadata of the package to match.
|
||||
*/
|
||||
|
||||
const fs = require('fs').promises;
|
||||
const asar = require('asar');
|
||||
const child_process = require('child_process');
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
const webappDir = await fs.stat('webapp.asar');
|
||||
} catch (e) {
|
||||
console.log("No 'webapp.asar' found. Run 'yarn run fetch'");
|
||||
return 1;
|
||||
}
|
||||
|
||||
const ver = asar.extractFile('webapp.asar', 'version').toString().trim();
|
||||
await new Promise((resolve, reject) => {
|
||||
child_process.execFile('yarn', [
|
||||
'version',
|
||||
'-s',
|
||||
'--no-git-tag-version', // This also means "don't commit to git" as it turns out
|
||||
'--new-version',
|
||||
ver,
|
||||
], (err) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
console.log("Version set to " + ver);
|
||||
}
|
||||
|
||||
main().then((ret) => process.exit(ret));
|
Loading…
Reference in New Issue
Block a user