From 8c8a794865040efc6ba722e09fa4d5829ec3b85a Mon Sep 17 00:00:00 2001 From: Tony <68118705+Legend-Master@users.noreply.github.com> Date: Tue, 22 Oct 2024 13:53:42 +0800 Subject: [PATCH] Release versoview to github releases (#203) * Release versoview to github releases * Add linux nix * Fix target and path * Remove arm64 and windows and x64 mac for now * Enable sccache * Fix zip path * Don't use sccache for nix * Use artifacts path * Wrong path * Use tar.gz and split windows and mac * use cd instead * Fix missing .tar.gz * Missing slash * missing .tar.gz * Wrong directory * Sawp verso and versoview --- .github/workflows/build.yml | 6 +- .github/workflows/doc.yml | 2 +- .github/workflows/release-versoview.yml | 137 ++++++++++++++++++++++++ Cargo.lock | 18 ++-- Cargo.toml | 4 +- src/main.rs | 4 +- {versoview => verso}/Cargo.toml | 2 +- {versoview => verso}/src/lib.rs | 0 8 files changed, 155 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/release-versoview.yml rename {versoview => verso}/Cargo.toml (90%) rename {versoview => verso}/src/lib.rs (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e346b8c4..a6caf400 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -117,7 +117,7 @@ jobs: - name: Fetch Verso version if: ${{ github.event_name == 'schedule' }} run: | - echo "VERSO_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "verso") | .version')" >> $GITHUB_ENV + echo "VERSO_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "versoview") | .version')" >> $GITHUB_ENV - name: Generate flatpak cargo sources if: ${{ github.event_name == 'schedule' }} @@ -190,7 +190,7 @@ jobs: - name: Fetch Verso version if: ${{ github.event_name == 'schedule' }} run: | - echo "VERSO_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "verso") | .version')" >> $Env:GITHUB_ENV + echo "VERSO_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "versoview") | .version')" >> $Env:GITHUB_ENV - name: Upload artifact if: ${{ github.event_name == 'schedule' }} @@ -261,7 +261,7 @@ jobs: - name: Fetch Verso version if: ${{ github.event_name == 'schedule' }} run: | - echo "VERSO_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "verso") | .version')" >> $GITHUB_ENV + echo "VERSO_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "versoview") | .version')" >> $GITHUB_ENV - name: Upload artifact if: ${{ github.event_name == 'schedule' }} diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index ce73ce21..172ebd36 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -31,7 +31,7 @@ jobs: nix-channel --update nixpkgs - name: "Build Verso docs" - run: nix-shell shell.nix --run 'cargo doc -p verso --no-deps' + run: nix-shell shell.nix --run 'cargo doc -p versoview --no-deps' - name: "Remove doc lock file" run: rm target/doc/.lock diff --git a/.github/workflows/release-versoview.yml b/.github/workflows/release-versoview.yml new file mode 100644 index 00000000..1128a81e --- /dev/null +++ b/.github/workflows/release-versoview.yml @@ -0,0 +1,137 @@ +name: Release VersoView + +on: + workflow_dispatch: + +env: + RUST_BACKTRACE: 1 + CARGO_INCREMENTAL: 0 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + build-linux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: nixbuild/nix-quick-install-action@v28 + + - name: Restore and cache Nix store + uses: nix-community/cache-nix-action@v5 + with: + paths: | + ~/.cargo + target/release/ + primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', 'Cargo.lock', 'Cargo.toml') }} + restore-prefixes-first-match: nix-${{ runner.os }}- + gc-max-store-size-linux: 1073741824 + + - name: Add Nix channel + run: | + nix-channel --add https://nixos.org/channels/nixos-24.05 nixpkgs + nix-channel --update nixpkgs + + - name: Build + run: nix-shell shell.nix --run 'cargo build --release' + + - name: Make archive + run: nix-shell shell.nix --run 'cd ./target/release && tar -czvf verso-x86_64-unknown-linux-gnu.tar.gz versoview' + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: verso-x86_64-unknown-linux-gnu + path: ./target/release/verso-x86_64-unknown-linux-gnu.tar.gz + + build-windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.4 + + - name: Install Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install mako + run: python -m pip install mako + + - name: Install scroop + uses: MinoruSekine/setup-scoop@v3 + - name: Install dependencies + run: | + scoop install llvm cmake + + - name: Build + env: + SCCACHE_GHA_ENABLED: true + RUSTC_WRAPPER: "sccache" + run: cargo build --release + + - name: Make archive + working-directory: ./target/release + run: tar -czvf verso-x86_64-pc-windows-msvc.tar.gz versoview.exe + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: verso-x86_64-pc-windows-msvc + path: ./target/release/verso-x86_64-pc-windows-msvc.tar.gz + + build-mac: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.4 + + - name: Install Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install mako + run: python -m pip install mako + + - name: Install dependencies + run: | + brew install cmake + curl https://gstreamer.freedesktop.org/data/pkg/osx/1.24.6/gstreamer-1.0-1.24.6-universal.pkg -o runtime.pkg + sudo installer -pkg runtime.pkg -target / + curl https://gstreamer.freedesktop.org/data/pkg/osx/1.24.6/gstreamer-1.0-devel-1.24.6-universal.pkg -o develop.pkg + sudo installer -pkg develop.pkg -target / + + - name: Build + env: + SCCACHE_GHA_ENABLED: true + RUSTC_WRAPPER: "sccache" + run: cargo build --release + + - name: Make archive + working-directory: ./target/release + run: tar -czvf verso-aarch64-apple-darwin.tar.gz versoview + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: verso-aarch64-apple-darwin + path: ./target/release/verso-aarch64-apple-darwin.tar.gz + + publish-release: + runs-on: ubuntu-latest + needs: [build-linux, build-windows, build-mac] + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + merge-multiple: true + path: artifacts + + - name: Publish release + run: | + RELEASE_TAG=versoview-v$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "versoview") | .version') + git fetch --tags --quiet + if ! git show-ref --tags --verify --quiet "refs/tags/${RELEASE_TAG}" ; then + gh release create ${RELEASE_TAG} ./artifacts/*.tar.gz + fi diff --git a/Cargo.lock b/Cargo.lock index d8d2f000..1e59eb1b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6217,6 +6217,15 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "verso" version = "0.0.1" +dependencies = [ + "ipc-channel", + "serde", + "versoview_messages", +] + +[[package]] +name = "versoview" +version = "0.0.1" dependencies = [ "arboard", "base", @@ -6273,15 +6282,6 @@ dependencies = [ "winit", ] -[[package]] -name = "versoview" -version = "0.0.1" -dependencies = [ - "ipc-channel", - "serde", - "versoview_messages", -] - [[package]] name = "versoview_messages" version = "0.0.1" diff --git a/Cargo.toml b/Cargo.toml index 63a7cc3b..de3751c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,12 @@ [workspace] -members = ["versoview", "versoview_messages"] +members = ["verso", "versoview_messages"] [workspace.dependencies] ipc-channel = "0.19" serde = { version = "1.0", features = ["derive"] } [package] -name = "verso" +name = "versoview" version = "0.0.1" authors = ["Wu Yu Wei"] edition = "2021" diff --git a/src/main.rs b/src/main.rs index 0b4cc0c8..c30c4bca 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,8 @@ // Prevent console window from appearing on Windows #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] -use verso::config::Config; -use verso::{Result, Verso}; +use versoview::config::Config; +use versoview::{Result, Verso}; use winit::application::ApplicationHandler; use winit::event_loop::{self, DeviceEvents}; use winit::event_loop::{EventLoop, EventLoopProxy}; diff --git a/versoview/Cargo.toml b/verso/Cargo.toml similarity index 90% rename from versoview/Cargo.toml rename to verso/Cargo.toml index 1544e6c9..f7f82154 100644 --- a/versoview/Cargo.toml +++ b/verso/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "versoview" +name = "verso" version = "0.0.1" edition = "2021" diff --git a/versoview/src/lib.rs b/verso/src/lib.rs similarity index 100% rename from versoview/src/lib.rs rename to verso/src/lib.rs