From f8a753dcb8cf51a2ed2a871226daa0f196225d53 Mon Sep 17 00:00:00 2001 From: Demmie <2e3s19@gmail.com> Date: Sat, 10 Jun 2023 22:25:39 -0400 Subject: [PATCH] Build binaries for releases by GHA --- .github/workflows/release.yml | 81 +++++++++++++++++++++++++++++++++++ src/config.rs | 6 ++- 2 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2835bbc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,81 @@ +name: Release + +on: + push: + tags: + - 'v[0-9]*.*.*' + +env: + CARGO_TERM_COLOR: always +jobs: + build: + # 22.04 is the earliest version with OpenSSL 3 + runs-on: ubuntu-22.04 + env: + AW_WEBUI_DIST: ./aw-webui/dist + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly + - name: Install dependencies + run: | + apt-get update + apt-get install -y curl + apt-get install build-essential -y + apt-get install libdbus-1-dev -y + apt-get install libssl-dev -y + apt-get install pkg-config -y + - name: install cargo-deb + run: cargo install cargo-deb + + # Build aw-webui + - name: Checkout aw-webui + uses: actions/checkout@v3 + with: + repository: ActivityWatch/aw-webui + path: aw-webui + ref: 839366e66f859faadd7f9128de3bea14b25ce4ae + submodules: true + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: 20.x + - name: Copy logo + run: cp media/logo/logo.png static/ + working-directory: aw-webui + - run: npm ci + working-directory: aw-webui + - run: npm run build + working-directory: aw-webui + + # Buil and upload binaries + - uses: Swatinem/rust-cache@v2 + - name: cargo build bundle + run: cargo build --release --features=bundle + + - run: zip "awatcher-bundle.zip" awatcher + working-directory: target/release + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: target/release/awatcher-bundle.zip + + - name: cargo build bare + run: cargo build --release + + - run: zip "awatcher.zip" awatcher + working-directory: target/release + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: target/release/awatcher.zip + + - name: cargo build deb + run: cargo deb --features=bundle + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file_glob: true + file: target/debian/*.deb diff --git a/src/config.rs b/src/config.rs index 20d3473..af59c5e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -47,6 +47,7 @@ pub fn from_cli() -> anyhow::Result { arg!(--port "Custom server port") .value_parser(value_parser!(u32)) .default_value(defaults::port().to_string()), + #[cfg(not(feature = "bundle"))] arg!(--host "Custom server host") .value_parser(value_parser!(String)) .default_value(defaults::host()), @@ -56,10 +57,10 @@ pub fn from_cli() -> anyhow::Result { arg!(--"poll-time-idle" "Period between sending heartbeats to the server for idle activity") .value_parser(value_parser!(u32)) .default_value(defaults::poll_time_idle_seconds().to_string()), - arg!(--"poll-time-window" "Period between sending heartbeats to the server for idle activity") + arg!(--"poll-time-window" "Period between sending heartbeats to the server for window activity") .value_parser(value_parser!(u32)) .default_value(defaults::poll_time_window_seconds().to_string()), - arg!(--"no-server" "Don't communicate to the ActivityWatch server") + arg!(--"no-server" "Don't send data to the ActivityWatch server") .value_parser(value_parser!(bool)) .action(ArgAction::SetTrue), #[cfg(feature = "bundle")] @@ -138,6 +139,7 @@ fn merge_cli(config: &mut FileConfig, matches: &ArgMatches) { &mut config.client.idle_timeout_seconds, ); get_arg_value("port", matches, &mut config.server.port); + #[cfg(not(feature = "bundle"))] get_arg_value("host", matches, &mut config.server.host); }