Skip to content

fix(update): keep archived release warning-free #90

fix(update): keep archived release warning-free

fix(update): keep archived release warning-free #90

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
keep_build_cache:
description: "Restore and save Cargo build cache for faster release builds"
type: boolean
default: true
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build (${{ matrix.target }})
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
binary: onetcli
archive: onetcli-aarch64-apple-darwin.tar.gz
- target: x86_64-apple-darwin
os: macos-15-intel
binary: onetcli
archive: onetcli-x86_64-apple-darwin.tar.gz
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
binary: onetcli
archive: onetcli-x86_64-unknown-linux-gnu.tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm
binary: onetcli
archive: onetcli-aarch64-unknown-linux-gnu.tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
binary: onetcli.exe
archive: onetcli-x86_64-pc-windows-msvc.zip
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
- name: Free disk space (macOS)
if: runner.os == 'macOS'
run: |
df -h
remove_path() {
local path="$1"
if [ -e "$path" ]; then
sudo rm -rf "$path" || echo "::warning::Failed to remove $path"
fi
}
remove_directory_contents() {
local path="$1"
if [ -d "$path" ]; then
sudo find "$path" -mindepth 1 -maxdepth 1 -exec rm -rf {} + \
|| echo "::warning::Failed to remove some entries under $path"
fi
}
remove_path /usr/local/lib/node_modules
remove_path "$HOME/.npm"
remove_path "$HOME/.nvm"
remove_directory_contents "$HOME/Library/Caches"
remove_path /System/Library/Frameworks/Python.framework
df -h
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: script/bootstrap
- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: script/bootstrap
- name: Install system dependencies (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
cmake --version
- name: Cache Cargo
if: ${{ github.event_name != 'workflow_dispatch' || inputs.keep_build_cache }}
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: release-cargo-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}-${{ github.run_id }}
restore-keys: |
release-cargo-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}-
release-cargo-${{ runner.os }}-${{ matrix.target }}-
- name: Set environment variables
shell: bash
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}"
echo "ONETCLI_VERSION=${VERSION}" >> "$GITHUB_ENV"
else
echo "ONETCLI_VERSION=0.0.0-dev.$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"
fi
if [[ "${{ matrix.target }}" == "aarch64-unknown-linux-gnu" ]]; then
echo "CARGO_BUILD_JOBS=1" >> "$GITHUB_ENV"
echo "CARGO_PROFILE_RELEASE_LTO=false" >> "$GITHUB_ENV"
echo "CARGO_PROFILE_RELEASE_CODEGEN_UNITS=16" >> "$GITHUB_ENV"
fi
- name: Verify secrets are set
shell: bash
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
run: |
if [ -z "$SUPABASE_URL" ]; then
echo "::error::SUPABASE_URL secret is empty or not set"
exit 1
fi
if [ -z "$SUPABASE_ANON_KEY" ]; then
echo "::error::SUPABASE_ANON_KEY secret is empty or not set"
exit 1
fi
- name: Build release binary
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
ONETCLI_PUBLIC_BASE_URL: ${{ vars.ONETCLI_PUBLIC_BASE_URL }}
ONETCLI_TEAM_MANAGEMENT_URL_TEMPLATE: ${{ vars.ONETCLI_TEAM_MANAGEMENT_URL_TEMPLATE }}
run: |
cargo --version
rustc --version
echo "CARGO_BUILD_JOBS=${CARGO_BUILD_JOBS:-}"
echo "CARGO_PROFILE_RELEASE_LTO=${CARGO_PROFILE_RELEASE_LTO:-}"
echo "CARGO_PROFILE_RELEASE_CODEGEN_UNITS=${CARGO_PROFILE_RELEASE_CODEGEN_UNITS:-}"
cargo build --release -p main --target ${{ matrix.target }}
- name: Clean build artifacts (macOS)
if: ${{ runner.os == 'macOS' && github.event_name == 'workflow_dispatch' && inputs.keep_build_cache == false }}
run: |
rm -rf target/debug
find target -name "incremental" -o -name "deps" -o -name "build" | xargs rm -rf || true
rm -rf ~/.cargo/registry/cache ~/.cargo/git/db
df -h
- name: Create macOS app bundle
if: runner.os == 'macOS'
run: |
chmod +x script/bundle-macos.sh
chmod +x script/bundle-macos-dmg.sh
script/bundle-macos.sh ${{ matrix.target }}
script/bundle-macos-dmg.sh ${{ matrix.target }}
tar czf ${{ matrix.archive }} -C target OnetCli.app
- name: Package (Linux)
if: runner.os == 'Linux'
run: |
mkdir -p package/usr/bin
mkdir -p package/usr/share/applications
mkdir -p package/usr/share/icons/hicolor/128x128/apps
mkdir -p package/usr/share/icons/hicolor/256x256/apps
mkdir -p package/usr/share/icons/hicolor/512x515/apps
cp target/${{ matrix.target }}/release/${{ matrix.binary }} package/usr/bin/
cp resources/linux/onetcli.desktop package/usr/share/applications/
cp resources/linux/onetcli-128.png package/usr/share/icons/hicolor/128x128/apps/onetcli.png
cp resources/linux/onetcli-256.png package/usr/share/icons/hicolor/256x256/apps/onetcli.png
cp resources/linux/onetcli-512.png package/usr/share/icons/hicolor/512x515/apps/onetcli.png
tar czf ${{ matrix.archive }} -C package .
- name: Install Linux packaging dependencies
if: matrix.target == 'x86_64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y rpm
- name: Package Linux installers (x86_64)
if: matrix.target == 'x86_64-unknown-linux-gnu'
shell: bash
run: |
set -euo pipefail
PACKAGE_VERSION="${ONETCLI_VERSION//-/.}"
DEB_NAME="onetcli_${PACKAGE_VERSION}_amd64.deb"
RPM_NAME="onetcli-${PACKAGE_VERSION}-1.x86_64.rpm"
APPIMAGE_NAME="onetcli_${PACKAGE_VERSION}_amd64.AppImage"
rm -rf package-deb rpmbuild OnetCli.AppDir linuxdeploy-x86_64.AppImage
mkdir -p package-deb/DEBIAN
cp -a package/. package-deb/
cat > package-deb/DEBIAN/control <<EOF
Package: onetcli
Version: ${PACKAGE_VERSION}
Section: utils
Priority: optional
Architecture: amd64
Maintainer: feigeCode <noreply@github.com>
Homepage: https://github.com/feigeCode/onetcli
Description: One Net Client - Database, SSH, Terminal, AI Tools
EOF
dpkg-deb --root-owner-group --build package-deb "${DEB_NAME}"
RPM_ROOT="${PWD}/rpmbuild"
mkdir -p "${RPM_ROOT}"/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
tar czf "${RPM_ROOT}/SOURCES/onetcli-${PACKAGE_VERSION}.tar.gz" -C package .
cat > "${RPM_ROOT}/SPECS/onetcli.spec" <<EOF
Name: onetcli
Version: ${PACKAGE_VERSION}
Release: 1%{?dist}
Summary: One Net Client - Database, SSH, Terminal, AI Tools
License: Apache-2.0
URL: https://github.com/feigeCode/onetcli
BuildArch: x86_64
Source0: %{name}-%{version}.tar.gz
%description
One Net Client - Database, SSH, Terminal, AI Tools.
%prep
mkdir -p %{_builddir}/%{name}-%{version}
tar -xzf %{SOURCE0} -C %{_builddir}/%{name}-%{version}
%build
%install
mkdir -p %{buildroot}
cp -a %{_builddir}/%{name}-%{version}/* %{buildroot}/
%files
/usr/bin/onetcli
/usr/share/applications/onetcli.desktop
/usr/share/icons/hicolor/128x128/apps/onetcli.png
/usr/share/icons/hicolor/256x256/apps/onetcli.png
/usr/share/icons/hicolor/512x515/apps/onetcli.png
EOF
rpmbuild --define "_topdir ${RPM_ROOT}" -bb "${RPM_ROOT}/SPECS/onetcli.spec"
generated_rpm="$(find "${RPM_ROOT}/RPMS" -name "onetcli-${PACKAGE_VERSION}-1*.x86_64.rpm" -print -quit)"
test -n "${generated_rpm}"
cp "${generated_rpm}" "${RPM_NAME}"
mkdir -p OnetCli.AppDir
cp -a package/. OnetCli.AppDir/
curl -L -o linuxdeploy-x86_64.AppImage \
https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
chmod +x linuxdeploy-x86_64.AppImage
VERSION="${PACKAGE_VERSION}" APPIMAGE_EXTRACT_AND_RUN=1 ./linuxdeploy-x86_64.AppImage \
--appdir OnetCli.AppDir \
--executable OnetCli.AppDir/usr/bin/onetcli \
--desktop-file resources/linux/onetcli.desktop \
--icon-file package/usr/share/icons/hicolor/512x515/apps/onetcli.png \
--output appimage
generated_appimage="$(find . -maxdepth 1 -name '*.AppImage' ! -name 'linuxdeploy-x86_64.AppImage' -print -quit)"
test -n "${generated_appimage}"
mv "${generated_appimage}" "${APPIMAGE_NAME}"
- name: Package (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Force package | Out-Null
Copy-Item "target/${{ matrix.target }}/release/${{ matrix.binary }}" "package/${{ matrix.binary }}"
Compress-Archive -Path "package/*" -DestinationPath "${{ matrix.archive }}"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.archive }}
path: ${{ matrix.archive }}
- name: Upload macOS DMG artifact
if: runner.os == 'macOS'
uses: actions/upload-artifact@v4
with:
name: onetcli-${{ matrix.target }}.dmg
path: "*.dmg"
- name: Upload Linux installer artifacts
if: matrix.target == 'x86_64-unknown-linux-gnu'
uses: actions/upload-artifact@v4
with:
name: onetcli-linux-x86_64-installers
path: |
onetcli_*.deb
onetcli-*.rpm
onetcli_*.AppImage
release:
name: Create Release
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: List artifacts
run: ls -la artifacts/
- name: Generate checksums
run: |
cd artifacts
shopt -s nullglob
release_files=(onetcli-* onetcli_*)
if [ "${#release_files[@]}" -eq 0 ]; then
echo "::error::No release artifacts found for checksum generation"
exit 1
fi
sha256sum "${release_files[@]}" > sha256sums.txt
cat sha256sums.txt
- name: Write release metadata
run: |
node <<'NODE'
const fs = require("fs");
const releaseTag = process.env.GITHUB_REF_NAME;
const version = releaseTag.replace(/^v/, "");
fs.writeFileSync(
"artifacts/release-metadata.json",
`${JSON.stringify({ release_tag: releaseTag, version }, null, 2)}\n`,
);
NODE
- name: Upload release metadata
uses: actions/upload-artifact@v4
with:
name: release-metadata
path: artifacts/release-metadata.json
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: OnetCli ${{ github.ref_name }}
generate_release_notes: true
files: |
artifacts/onetcli-*.tar.gz
artifacts/onetcli-*.zip
artifacts/onetcli-*.dmg
artifacts/onetcli_*.deb
artifacts/onetcli-*.rpm
artifacts/onetcli_*.AppImage
artifacts/sha256sums.txt