-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
346 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
build: | ||
name: Release | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [macOS-latest, windows-latest, ubuntu-latest] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v1 | ||
- name: Setup Toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: beta | ||
override: true | ||
- name: Build | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: run | ||
args: --manifest-path=tools/builder/Cargo.toml | ||
- name: Create Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
draft: true | ||
files: target/upload/* | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "oxidize" | ||
version = "1.0.1" | ||
version = "0.0.0" | ||
authors = ["John-John Tedro <[email protected]>"] | ||
edition = "2018" | ||
license = "MIT/Apache-2.0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,64 @@ | ||
fn main() { | ||
use failure::{format_err, ResultExt as _}; | ||
use std::{env, fs, path::PathBuf, process::Command}; | ||
|
||
type Result<T> = std::result::Result<T, failure::Error>; | ||
|
||
fn version() -> Result<String> { | ||
if let Ok(version) = env::var("OXIDIZE_VERSION") { | ||
return Ok(version); | ||
} | ||
|
||
let output = Command::new("git") | ||
.args(&["rev-parse", "--short", "HEAD"]) | ||
.output()?; | ||
|
||
let version = std::str::from_utf8(&output.stdout)?; | ||
Ok(format!("git-{}", version)) | ||
} | ||
|
||
/// Construct a Windows version information. | ||
fn file_version() -> Option<(String, u64)> { | ||
let version = match env::var("OXIDIZE_FILE_VERSION") { | ||
Ok(version) => version, | ||
Err(_) => return None, | ||
}; | ||
|
||
let mut info = 0u64; | ||
|
||
let mut it = version.split('.'); | ||
|
||
info |= it.next()?.parse().unwrap_or(0) << 48; | ||
info |= it.next()?.parse().unwrap_or(0) << 32; | ||
info |= it.next()?.parse().unwrap_or(0) << 16; | ||
info |= match it.next() { | ||
Some(n) => n.parse().unwrap_or(0), | ||
None => 0, | ||
}; | ||
|
||
Some((version, info)) | ||
} | ||
|
||
fn main() -> Result<()> { | ||
let version = version()?; | ||
|
||
if cfg!(target_os = "windows") { | ||
use winres::VersionInfo::*; | ||
|
||
let mut res = winres::WindowsResource::new(); | ||
res.set_icon("res/icon.ico"); | ||
res.compile().unwrap(); | ||
|
||
if let Some((version, info)) = file_version() { | ||
res.set("FileVersion", &version); | ||
res.set("ProductVersion", &version); | ||
res.set_version_info(FILEVERSION, info); | ||
res.set_version_info(PRODUCTVERSION, info); | ||
} | ||
|
||
res.compile().context("compiling resorces")?; | ||
} | ||
|
||
let out_dir = | ||
PathBuf::from(env::var_os("OUT_DIR").ok_or_else(|| format_err!("missing: OUT_DIR"))?); | ||
fs::write(out_dir.join("version.txt"), &version).context("writing version.txt")?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.