From 8dab582db9d47d02f623267aa64f86ffb20c0938 Mon Sep 17 00:00:00 2001 From: MissterHao Date: Tue, 29 Nov 2022 16:54:47 +0800 Subject: [PATCH] feat: Add publish files for DEBUAN and scoop --- .github/workflows/release.yml | 154 +++++++++++++++++++++++++++ Cargo.toml | 3 +- publish/deb/ruscode/DEBIAN/control | 7 ++ publish/deb/ruscode/usr/bin/.gitkeep | 0 publish/scoop/ruscode.json | 6 ++ 5 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml create mode 100644 publish/deb/ruscode/DEBIAN/control create mode 100644 publish/deb/ruscode/usr/bin/.gitkeep create mode 100644 publish/scoop/ruscode.json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..273b0af --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,154 @@ +name: release + +on: + workflow_dispatch: + push: + branches: + - "feature/*" + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + - "v0" + +env: + CARGO_INCREMENTAL: 0 + CARGO_NET_RETRY: 10 + RUSTUP_MAX_RETRIES: 10 + # Don't emit giant backtraces in the CI logs. + RUST_BACKTRACE: short + +jobs: + lint: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04] + rust: [stable] + + steps: + - name: Checkout repro + uses: actions/checkout@v3 + + # nice reusable workflow to get rust ready + - name: Setup rust toolchain + uses: hecrj/setup-rust-action@master + with: + rust-version: ${{ matrix.rust }} + components: "clippy, rustfmt" + + # make sure all code has been formatted with rustfmt + - name: Check formatting (rustfmt) + run: cargo fmt --check -- --color always + + # run a collection of lints + - name: Check against available lints (clippy) + run: cargo clippy --all-targets -- -D warnings + + build: + name: Build + needs: lint + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, ubuntu-20.04, windows-latest] + # os: [ubuntu-latest, macOS-latest, windows-latest] + rust: [stable] + include: + # - os: macOS-latest + # rust: "stable" + # targets: "x86_64-apple-darwin" + - os: ubuntu-latest + rust: "stable" + targets: "x86_64-unknown-linux-musl" + - os: ubuntu-20.04 + rust: "stable" + targets: "x86_64-unknown-linux-musl" + - os: windows-latest + rust: "stable" + targets: "x86_64-pc-windows-msvc" + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Set env + run: | + echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + echo "STRIP_RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV + + - name: Set up Rust + uses: hecrj/setup-rust-action@v1 + with: + rust-version: ${{ matrix.rust }} + + - name: Cache + uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + # Build Binary + - name: Build '${{ matrix.os }}-${{ env.RELEASE_VERSION }}' + run: | + echo "OS: ${{ matrix.os }} " + cargo build --release --color auto + + # Strip Debug Information + - name: Strip debug information '${{ matrix.os }}-${{ env.RELEASE_VERSION }}' + if: ${{ (matrix.os != 'windows-latest') }} + run: | + echo "OS: ${{ matrix.os }} " + strip target/release/ruscode + + # Archive Binary + - name: Archive Windows binary artifacts + if: ${{ (matrix.os == 'windows-latest') }} + uses: actions/upload-artifact@v3 + with: + name: window-binary-${{ env.RELEASE_VERSION }} + path: target/release/ruscode.exe + + - name: Archive '${{ matrix.os }}' binary artifacts + if: ${{ (matrix.os != 'windows-latest') }} + uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.os }}-binary + path: target/release/ruscode + + - name: package to deb + if: ${{ (matrix.os != 'windows-latest')}} + run: | + # Install packages + sudo apt-get install -y gcc dpkg-dev gpg + + mkdir -p ~/deb/ruscode_${{ env.STRIP_RELEASE_VERSION }}-0_amd64/usr/bin + mkdir -p ~/deb/ruscode_${{ env.STRIP_RELEASE_VERSION }}-0_amd64/DEBIAN/ + cp publish/deb/ruscode/DEBIAN/control ~/deb/ruscode_${{ env.STRIP_RELEASE_VERSION }}-0_amd64/DEBIAN/control + cp target/release/ruscode ~/deb/ruscode_${{ env.STRIP_RELEASE_VERSION }}-0_amd64/usr/bin/ruscode + + + # Build Package + dpkg --build ~/deb/ruscode_${{ env.STRIP_RELEASE_VERSION }}-0_amd64 + + # Check Package Information + dpkg-deb --info ~/deb/ruscode_${{ env.STRIP_RELEASE_VERSION }}-0_amd64.deb + + # Lists the contents of the filesystem tree archive portion of the package archive. + dpkg-deb --contents ~/deb/ruscode_${{ env.STRIP_RELEASE_VERSION }}-0_amd64.deb + + # Install + sudo apt-get install -f ~/deb/ruscode_${{ env.STRIP_RELEASE_VERSION }}-0_amd64.deb + + # Display installed package + which ruscode + + # Test basic command + ruscode --help + + - name: Archive '${{ matrix.os }}' deb artifacts + if: ${{ (matrix.os != 'windows-latest') }} + uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.os }}-deb + path: ~/deb/ruscode_${{ env.STRIP_RELEASE_VERSION }}-0_amd64.deb diff --git a/Cargo.toml b/Cargo.toml index 34e6d9a..213285e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ruscode" -version = "0.1.0" +version = "1.0.0" edition = "2021" authors = ["Hao-Wei"] readme = "README.md" @@ -37,3 +37,4 @@ chrono = "0.4.23" lto = true codegen-units = 1 opt-level = 'z' +panic = "abort" diff --git a/publish/deb/ruscode/DEBIAN/control b/publish/deb/ruscode/DEBIAN/control new file mode 100644 index 0000000..b125295 --- /dev/null +++ b/publish/deb/ruscode/DEBIAN/control @@ -0,0 +1,7 @@ +Package: ruscode +Version: 1.0.0 +Maintainer: HaoWeiLi 晧暐 +Depends: +Architecture: all +Homepage: https://github.com/MissterHao/ruscode +Description: A visual studio code's workspaces organizer written in Rust diff --git a/publish/deb/ruscode/usr/bin/.gitkeep b/publish/deb/ruscode/usr/bin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/publish/scoop/ruscode.json b/publish/scoop/ruscode.json new file mode 100644 index 0000000..505b719 --- /dev/null +++ b/publish/scoop/ruscode.json @@ -0,0 +1,6 @@ +{ + "version": "1.0.0", + "url": "http://public-url/window-binary.zip", + "bin": "ruscode.exe", + "homepage": "https://github.com/MissterHao/ruscode" +} \ No newline at end of file