Skip to content

feat: optimize the profile release for binary (#752) #205

feat: optimize the profile release for binary (#752)

feat: optimize the profile release for binary (#752) #205

Workflow file for this run

name: Release
on:
push:
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 480
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-gnu
- aarch64-unknown-linux-musl
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: Checkout
uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
cache-on-failure: true
- name: Get the release version from the tag
shell: bash
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools
uses: taiki-e/setup-cross-toolchain-action@v1
with:
target: ${{ matrix.target }}
- name: Install cargo-deb
uses: taiki-e/cache-cargo-install-action@v2
with:
tool: cargo-deb
- name: Install cargo-generate-rpm
uses: taiki-e/install-action@v2
with:
tool: cargo-generate-rpm
- name: Install dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y protobuf-compiler libclang-dev
- name: Build binaries
shell: bash
run: |
cargo build --release --bins --target ${{ matrix.target }}
- name: Build archive client(DEB)
shell: bash
run: |
binary_name="client"
dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}"
cargo deb -p dragonfly-client --target ${{ matrix.target }} --variant ${{ matrix.target }} --output $dirname.deb
echo "CLIENT_DEB_ASSET=$dirname.deb" >> $GITHUB_ENV
- name: Build archive client(RPM)
shell: bash
run: |
binary_name="client"
dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}"
cargo generate-rpm -p dragonfly-client --target ${{ matrix.target }} --variant ${{ matrix.target }} --output $dirname.rpm
echo "CLIENT_RPM_ASSET=$dirname.rpm" >> $GITHUB_ENV
- name: Build archive client(TAR)
shell: bash
run: |
binary_name="client"
dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}"
mkdir -p "$dirname"
mv "target/${{ matrix.target }}/release/dfget" "$dirname"
mv "target/${{ matrix.target }}/release/dfdaemon" "$dirname"
mv "target/${{ matrix.target }}/release/dfstore" "$dirname"
mv "target/${{ matrix.target }}/release/dfcache" "$dirname"
mv "target/${{ matrix.target }}/release/dfinit" "$dirname"
mv CONTRIBUTING.md LICENSE README.md "$dirname"
tar -czf "$dirname.tar.gz" "$dirname"
echo "CLIENT_TAR_ASSET=$dirname.tar.gz" >> $GITHUB_ENV
- name: Upload Release Artifacts
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.target }}
path: |
${{ env.CLIENT_RPM_ASSET }}
${{ env.CLIENT_DEB_ASSET }}
${{ env.CLIENT_TAR_ASSET }}
release-github:
runs-on: ubuntu-latest
timeout-minutes: 120
needs: [build]
permissions:
contents: write
steps:
- name: Download Release Artifacts
uses: actions/download-artifact@v4
with:
path: releases
pattern: release-*
merge-multiple: true
- name: Release
uses: ncipollo/release-action@v1
with:
artifacts: "releases/*"
generateReleaseNotes: true
allowUpdates: true
draft: true
publish-crates:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install protobuf-compiler libclang-dev
- uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
ignore-unpublished-changes: true