From 61ecbcfd82f1d41c6245c3893adf7798d19b5a95 Mon Sep 17 00:00:00 2001 From: Ioannis Tsagkatakis Date: Fri, 21 Jun 2024 16:26:54 +0300 Subject: [PATCH] Testing new CD --- .cargo/config.toml | 5 ++ .github/workflows/cd.yml | 102 ++++++++++++++++++++++++++++----------- Cargo.toml | 25 +++++++++- 3 files changed, 102 insertions(+), 30 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..7e766c3 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,5 @@ +[target.x86_64-pc-windows-msvc] +rustflags = ["-C", "target-feature=+crt-static"] + +[target.i686-pc-windows-msvc] +rustflags = ["-C", "target-feature=+crt-static"] diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 0c512f9..92ddd00 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,51 +1,64 @@ -name: CD # Continuous Deployment +name: Continuous Deployment on: push: tags: - '[v]?[0-9]+.[0-9]+.[0-9]+' + workflow_dispatch: jobs: - publish: - name: Publishing for ${{ matrix.job.os }} + build-binaries: + name: Publishing for ${{ matrix.job.name }} runs-on: ${{ matrix.job.os }} strategy: matrix: rust: [stable] job: + - os: macos-latest + name: MacOS x86_64-apple-darwin os-name: macos target: x86_64-apple-darwin architecture: x86_64 binary-postfix: "" use-cross: false + - os: macos-latest + name: MacOS aarch64-apple-darwin os-name: macos target: aarch64-apple-darwin architecture: arm64 binary-postfix: "" use-cross: false + - os: ubuntu-latest + name: Ubuntu x86_64-unknown-linux-gnu os-name: linux target: x86_64-unknown-linux-gnu architecture: x86_64 binary-postfix: "" use-cross: false + - os: windows-latest + name: Windows os-name: windows target: x86_64-pc-windows-msvc architecture: x86_64 binary-postfix: ".exe" use-cross: false + - os: ubuntu-latest + name: Ubuntu aarch64-unknown-linux-gnu os-name: linux target: aarch64-unknown-linux-gnu architecture: arm64 binary-postfix: "" use-cross: true + - os: ubuntu-latest - os-name: linux + name: Ubuntu + os-name: linux i686-unknown-linux-gnu target: i686-unknown-linux-gnu architecture: i686 binary-postfix: "" @@ -62,7 +75,8 @@ jobs: profile: minimal override: true - uses: Swatinem/rust-cache@v2 - - name: Cargo build + + - name: Cargo build ${{ matrix.job.target }} uses: actions-rs/cargo@v1 with: command: build @@ -70,42 +84,72 @@ jobs: toolchain: ${{ matrix.rust }} args: --release --target ${{ matrix.job.target }} - - name: install strip command - shell: bash - run: | - if [[ ${{ matrix.job.target }} == aarch64-unknown-linux-gnu ]]; then - sudo apt update - sudo apt-get install -y binutils-aarch64-linux-gnu - fi - - name: Packaging final binary + - name: Packaging final binary ${{ matrix.job.target }} shell: bash run: | cd target/${{ matrix.job.target }}/release - ####### reduce binary size by removing debug symbols ####### - BINARY_NAME=places${{ matrix.job.binary-postfix }} - if [[ ${{ matrix.job.target }} == aarch64-unknown-linux-gnu ]]; then - GCC_PREFIX="aarch64-linux-gnu-" - else - GCC_PREFIX="" - fi - "$GCC_PREFIX"strip $BINARY_NAME - ########## create tar.gz ########## + BINARY_NAME=places${{ matrix.job.binary-postfix }} RELEASE_NAME=places-${GITHUB_REF/refs\/tags\//}-${{ matrix.job.os-name }}-${{ matrix.job.architecture }} tar czvf $RELEASE_NAME.tar.gz $BINARY_NAME - ########## create sha256 ########## - if [[ ${{ runner.os }} == 'Windows' ]]; then - certutil -hashfile $RELEASE_NAME.tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > $RELEASE_NAME.sha256 - else - shasum -a 256 $RELEASE_NAME.tar.gz > $RELEASE_NAME.sha256 - fi - name: Releasing assets uses: softprops/action-gh-release@v2 with: files: | target/${{ matrix.job.target }}/release/places-*.tar.gz - target/${{ matrix.job.target }}/release/places-*.sha256 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + build-msi: + name: "Build MSI installer" + runs-on: "windows-2019" + timeout-minutes: 30 + steps: + - name: Checkout repository + uses: actions/checkout@v4 # v4.1.1 + with: + fetch-depth: 1 + + - name: Install Net-Framework-Core + shell: powershell + run: Install-WindowsFeature Net-Framework-Core + + - name: Install wixtoolset + uses: crazy-max/ghaction-chocolatey@0e015857dd851f84fcb7fb53380eb5c4c8202333 # v3.0.0 + with: + args: install -y wixtoolset + + - name: Set up Rust toolchain + uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a + with: + toolchain: stable + target: x86_64-pc-windows-msvc + + - name: Build MSI file + shell: powershell + env: + BTM_GENERATE: "" + run: | + cargo install cargo-wix --version 0.3.8 --locked + cargo wix + + - name: Generate artifact attestation for file + uses: actions/attest-build-provenance@v1 + with: + subject-path: "places-cli_x86_64_installer.msi" + + - name: Create release directory for artifact, move files + shell: bash + run: | + mkdir release + mv places-cli_x86_64_installer.msi release/ + + - name: Releasing assets + uses: softprops/action-gh-release@v2 + with: + files: | + target/${{ matrix.job.target }}/release/places-cli_x86_64_installer.msi env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Cargo.toml b/Cargo.toml index 99e5e9d..b114e76 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,9 @@ clap_complete = "4.5.5" lto = true debug = false - +### +### .deb package related! +### [package.metadata.deb] name = "places-cli" extended-description = """\ @@ -82,3 +84,24 @@ assets = [ "644", ], ] + +[package.metadata.deb.variants.arm64] +depends = "libc6:arm64 (>= 2.28)" + +[package.metadata.deb.variants.armhf] +depends = "libc6:armhf (>= 2.28)" + +[package.metadata.wix] +output = "places-cli_x86_64_installer.msi" + +[package.metadata.generate-rpm] +assets = [ + { source = "target/release/places", dest = "/usr/bin/", mode = "755" }, + { source = "LICENSE", dest = "/usr/share/doc/places/", mode = "644" }, + { source = "Readme.md", dest = "/usr/share/doc/places/", mode = "644" }, + { source = "CHANGELOG.md", dest = "/usr/share/doc/places/", mode = "644" }, + { source = "support/manpage/places.1.gz", dest = "/usr/share/man/man1/places.1.gz", mode = "644", doc = true }, + { source = "support/completion/places.bash", dest = "/usr/share/bash-completion/completions/places", mode = "644" }, + { source = "support/completion/places.fish", dest = "/usr/share/fish/vendor_completions.d/places.fish", mode = "644" }, + { source = "support/completion/_places", dest = "/usr/share/zsh/vendor-completions/", mode = "644" }, +]