diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2018-06-26 14:46:34 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2018-06-26 14:46:34 +0200 |
| commit | 1d2d4c2605f537d929c5677c8aee5a3d80ae9c90 (patch) | |
| tree | 10cc2892af05e07b836b5e6e8d8c8bce7921b136 | |
| parent | 8a0c609994b967f1cdeca811527b6f42a7dfb8a1 (diff) | |
| parent | 51228215a7158d8b70e9a522951a08e7f1018396 (diff) | |
| download | mullvadvpn-1d2d4c2605f537d929c5677c8aee5a3d80ae9c90.tar.xz mullvadvpn-1d2d4c2605f537d929c5677c8aee5a3d80ae9c90.zip | |
Merge branch 'update-version-on-build'
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | Cargo.lock | 4 | ||||
| -rw-r--r-- | README.md | 3 | ||||
| -rwxr-xr-x | build.sh | 40 | ||||
| -rw-r--r-- | mullvad-cli/Cargo.toml | 2 | ||||
| -rw-r--r-- | mullvad-daemon/Cargo.toml | 3 | ||||
| -rw-r--r-- | mullvad-daemon/build.rs | 25 | ||||
| -rw-r--r-- | mullvad-daemon/src/bin/problem-report.rs | 15 | ||||
| -rw-r--r-- | mullvad-daemon/src/cli.rs | 2 | ||||
| -rw-r--r-- | mullvad-daemon/src/main.rs | 8 | ||||
| -rw-r--r-- | mullvad-daemon/src/version.rs | 12 | ||||
| -rw-r--r-- | package.json | 2 | ||||
| -rwxr-xr-x | prepare_release.sh | 15 |
13 files changed, 77 insertions, 55 deletions
diff --git a/.gitignore b/.gitignore index 94c9d5c1e3..a29ecf69e9 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ flow-typed dist-assets/relays.json windows/**/bin/ **/.vs/ +*.bak diff --git a/Cargo.lock b/Cargo.lock index 0509c70917..3c02c48546 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -746,7 +746,7 @@ dependencies = [ [[package]] name = "mullvad-cli" -version = "0.1.0" +version = "2018.1.0" dependencies = [ "clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -760,7 +760,7 @@ dependencies = [ [[package]] name = "mullvad-daemon" -version = "0.1.0" +version = "2018.1.0" dependencies = [ "chrono 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -34,7 +34,8 @@ regular installation of Visual Studio 2017 Community edition works as well). - The host has to have `msbuild.exe` available in `%PATH%`. -- The host has to have `bash` installed. The one coming with [Git for Windows] works. +- The host has to have `bash` installed as well as a few base unix utilities, including `sed` and + `tail`. The environment coming with [Git for Windows] works fine. [Git for Windows]: https://git-scm.com/download/win @@ -1,10 +1,12 @@ #!/usr/bin/env bash -# This script is used to build, and sign a release artifact. See `README.md` for instructions on -# how to just build a development/testing version. +# This script is used to build, and sign a release artifact. See `README.md` for further +# instructions. # # Invoke the script with --dev-build in order to skip checks, cleaning and signing. +set -eu + ################################################################################ # Platform specific configuration. ################################################################################ @@ -26,6 +28,7 @@ esac ################################################################################ RUSTC_VERSION=`rustc +stable --version` +PRODUCT_VERSION=$(node -p "require('./package.json').version" | sed -Ee 's/\.0//g') if [[ "${1:-""}" != "--dev-build" ]]; then @@ -68,10 +71,34 @@ if [[ "${1:-""}" != "--dev-build" ]]; then else echo "!! Development build. Not for general distribution !!" + GIT_COMMIT=$(git rev-parse --short HEAD) + PRODUCT_VERSION="$PRODUCT_VERSION-dev-$GIT_COMMIT" + unset CSC_LINK CSC_KEY_PASSWORD export CSC_IDENTITY_AUTO_DISCOVERY=false fi +echo "Building Mullvad VPN $PRODUCT_VERSION" +SEMVER_VERSION=$(echo $PRODUCT_VERSION | sed -Ee 's/($|-.*)/.0\1/g') + +function restore_metadata_backups() { + mv package.json.bak package.json || true + mv Cargo.lock.bak Cargo.lock || true + mv mullvad-cli/Cargo.toml.bak mullvad-cli/Cargo.toml || true + mv mullvad-daemon/Cargo.toml.bak mullvad-daemon/Cargo.toml || true +} +trap 'restore_metadata_backups' EXIT + +sed -i.bak \ + -Ee "s/\"version\": \"[^\"]+\",/\"version\": \"$SEMVER_VERSION\",/g" \ + package.json + +cp Cargo.lock Cargo.lock.bak +sed -i.bak \ + -Ee "s/^version = \"[^\"]+\"\$/version = \"$SEMVER_VERSION\"/g" \ + mullvad-daemon/Cargo.toml \ + mullvad-cli/Cargo.toml + ################################################################################ # Compile and link all binaries. ################################################################################ @@ -117,12 +144,17 @@ case "$(uname -s)" in MINGW*) yarn pack:win;; esac -RELEASE_VERSION=`./target/release/mullvad-daemon --version | cut -f2 -d' '` +for semver_path in dist/*$SEMVER_VERSION*; do + product_path=$(echo $semver_path | sed -Ee "s/$SEMVER_VERSION/$PRODUCT_VERSION/g") + echo "Moving $semver_path -> $product_path" + mv $semver_path $product_path +done + echo "**********************************" echo "" echo " The build finished successfully! " echo " You have built:" echo "" -echo " $RELEASE_VERSION" +echo " $PRODUCT_VERSION" echo "" echo "**********************************" diff --git a/mullvad-cli/Cargo.toml b/mullvad-cli/Cargo.toml index 9a8799a92f..b71720ecc5 100644 --- a/mullvad-cli/Cargo.toml +++ b/mullvad-cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mullvad-cli" -version = "0.1.0" +version = "2018.1.0" authors = ["Mullvad VPN <admin@mullvad.net>", "Linus Färnstrand <linus@mullvad.net>", "Erik Larkö <erik@mullvad.net>", "Andrej Mihajlov <and@mullvad.net>"] description = "Run Talpid easily from the command line" license = "GPL-3.0" diff --git a/mullvad-daemon/Cargo.toml b/mullvad-daemon/Cargo.toml index f985440a99..90edeaebb4 100644 --- a/mullvad-daemon/Cargo.toml +++ b/mullvad-daemon/Cargo.toml @@ -1,10 +1,9 @@ [package] name = "mullvad-daemon" -version = "0.1.0" +version = "2018.1.0" authors = ["Mullvad VPN <admin@mullvad.net>", "Linus Färnstrand <linus@mullvad.net>", "Erik Larkö <erik@mullvad.net>", "Andrej Mihajlov <and@mullvad.net>"] description = "Mullvad VPN daemon. Runs and controls the VPN tunnels" license = "GPL-3.0" -build = "build.rs" [dependencies] chrono = { version = "0.4", features = ["serde"] } diff --git a/mullvad-daemon/build.rs b/mullvad-daemon/build.rs index 9e6c57fc96..f1f507670e 100644 --- a/mullvad-daemon/build.rs +++ b/mullvad-daemon/build.rs @@ -1,6 +1,5 @@ use std::env; -use std::fs::File; -use std::io::Write; +use std::fs; use std::path::PathBuf; use std::process::Command; @@ -8,25 +7,9 @@ use std::process::Command; fn main() { let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap()); - File::create(out_dir.join("git-commit-desc.txt")) - .unwrap() - .write_all(commit_description().as_bytes()) - .unwrap(); - File::create(out_dir.join("git-commit-date.txt")) - .unwrap() - .write_all(commit_date().as_bytes()) - .unwrap(); -} - -fn commit_description() -> String { - let output = Command::new("git") - .args(&["describe", "--dirty"]) - .output() - .expect("Unable to get git commit description"); - ::std::str::from_utf8(&output.stdout) - .unwrap() - .trim() - .to_owned() + let product_version = env!("CARGO_PKG_VERSION").replacen(".0", "", 1); + fs::write(out_dir.join("product-version.txt"), product_version).unwrap(); + fs::write(out_dir.join("git-commit-date.txt"), commit_date()).unwrap(); } fn commit_date() -> String { diff --git a/mullvad-daemon/src/bin/problem-report.rs b/mullvad-daemon/src/bin/problem-report.rs index dcd67ba227..063dbf0838 100644 --- a/mullvad-daemon/src/bin/problem-report.rs +++ b/mullvad-daemon/src/bin/problem-report.rs @@ -82,7 +82,7 @@ quick_main!(run); fn run() -> Result<()> { let app = clap::App::new("problem-report") - .version(crate_version!()) + .version(daemon_version()) .author(crate_authors!()) .about("Mullvad VPN problem report tool. Collects logs and sends them to Mullvad support.") .setting(clap::AppSettings::SubcommandRequired) @@ -441,15 +441,18 @@ fn read_file_lossy(path: &Path, max_bytes: usize) -> io::Result<String> { fn collect_metadata() -> HashMap<String, String> { let mut metadata = HashMap::new(); - metadata.insert(String::from("mullvad-daemon-version"), daemon_version()); + metadata.insert( + String::from("mullvad-daemon-version"), + daemon_version().to_owned(), + ); metadata.insert(String::from("os"), os_version()); metadata } -fn daemon_version() -> String { - format!( - "{} {}", - include_str!(concat!(env!("OUT_DIR"), "/git-commit-desc.txt")), +fn daemon_version() -> &'static str { + concat!( + include_str!(concat!(env!("OUT_DIR"), "/product-version.txt")), + " ", include_str!(concat!(env!("OUT_DIR"), "/git-commit-date.txt")) ) } diff --git a/mullvad-daemon/src/cli.rs b/mullvad-daemon/src/cli.rs index ffb4a62586..573236d797 100644 --- a/mullvad-daemon/src/cli.rs +++ b/mullvad-daemon/src/cli.rs @@ -37,7 +37,7 @@ pub fn get_config() -> Config { fn create_app() -> App<'static, 'static> { let app = App::new(crate_name!()) - .version(version::current()) + .version(version::CURRENT) .author(crate_authors!()) .about(crate_description!()) .arg( diff --git a/mullvad-daemon/src/main.rs b/mullvad-daemon/src/main.rs index 892c438188..37bfcb56a9 100644 --- a/mullvad-daemon/src/main.rs +++ b/mullvad-daemon/src/main.rs @@ -490,7 +490,7 @@ impl Daemon { &mut self, tx: OneshotSender<BoxFuture<AppVersionInfo, mullvad_rpc::Error>>, ) { - let current_version = version::current().to_owned(); + let current_version = version::CURRENT.to_owned(); let fut = self .version_proxy .latest_app_version() @@ -506,7 +506,7 @@ impl Daemon { } fn on_get_current_version(&mut self, tx: OneshotSender<AppVersion>) { - let current_version = version::current().to_owned(); + let current_version = version::CURRENT.to_owned(); Self::oneshot_send(tx, current_version, "get_current_version response"); } @@ -915,8 +915,8 @@ fn log_version() { info!( "Starting {} - {} {}", env!("CARGO_PKG_NAME"), - version::current(), - version::commit_date(), + version::CURRENT, + version::COMMIT_DATE, ) } diff --git a/mullvad-daemon/src/version.rs b/mullvad-daemon/src/version.rs index 2252406e5f..2c28c2bba4 100644 --- a/mullvad-daemon/src/version.rs +++ b/mullvad-daemon/src/version.rs @@ -1,9 +1,5 @@ -/// Returns a string that identifies the current version of the application -pub fn current() -> &'static str { - include_str!(concat!(env!("OUT_DIR"), "/git-commit-desc.txt")) -} +/// A string that identifies the current version of the application +pub const CURRENT: &str = include_str!(concat!(env!("OUT_DIR"), "/product-version.txt")); -/// Current description returns the current build date -pub fn commit_date() -> &'static str { - include_str!(concat!(env!("OUT_DIR"), "/git-commit-date.txt")) -} +/// Contains the date of the git commit this was built from +pub const COMMIT_DATE: &str = include_str!(concat!(env!("OUT_DIR"), "/git-commit-date.txt")); diff --git a/package.json b/package.json index 042b00cef9..12d3cee684 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mullvad-vpn", - "version": "2018.1.0-beta10", + "version": "2018.1.0", "description": "Mullvad VPN client", "main": "init.js", "author": { diff --git a/prepare_release.sh b/prepare_release.sh index f75732b228..ad9858d070 100755 --- a/prepare_release.sh +++ b/prepare_release.sh @@ -29,12 +29,19 @@ if [[ $(grep $VERSION CHANGELOG.md) == "" ]]; then exit 1 fi -echo "Updating version in package.json..." +echo "Updating version in metadata files..." SEMVER_VERSION=`echo $VERSION | sed -re 's/($|-.*)/.0\1/g'` -sed -i -re "s/\"version\": \"[^\"]+\",/\"version\": \"$SEMVER_VERSION\",/g" package.json +sed -i -re "s/\"version\": \"[^\"]+\",/\"version\": \"$SEMVER_VERSION\",/g" \ + package.json +sed -i -re "s/^version = \"[^\"]+\"\$/version = \"$SEMVER_VERSION\"/g" \ + mullvad-daemon/Cargo.toml \ + mullvad-cli/Cargo.toml -echo "Commiting package.json change to git..." -git commit -S package.json -m "Updating version in package.json" +echo "Commiting metadata changes to git..." +git commit -S -m "Updating version in package.json" \ + package.json \ + mullvad-daemon/Cargo.toml \ + mullvad-cli/Cargo.toml echo "Tagging current git commit with release tag $VERSION..." git tag -s $VERSION -m $VERSION |
