Skip to content

Commit

Permalink
Testing new CD
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsagata committed Jun 21, 2024
1 parent 8cd9e54 commit 61ecbcf
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -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"]
102 changes: 73 additions & 29 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -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: ""
Expand All @@ -62,50 +75,81 @@ 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
use-cross: ${{ matrix.job.use-cross }}
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 }}
25 changes: 24 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ clap_complete = "4.5.5"
lto = true
debug = false


###
### .deb package related!
###
[package.metadata.deb]
name = "places-cli"
extended-description = """\
Expand Down Expand Up @@ -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" },
]

0 comments on commit 61ecbcf

Please sign in to comment.