Skip to content

fix: battery threshold UI reads from hardware instead of stale cache #47

fix: battery threshold UI reads from hardware instead of stale cache

fix: battery threshold UI reads from hardware instead of stale cache #47

Workflow file for this run

name: Build and Release
on:
push:
tags:
- 'v*'
branches:
- main
jobs:
build-and-release:
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
build-essential \
curl \
wget \
file \
libssl-dev \
libayatana-appindicator3-dev \
librsvg2-dev
- name: Install npm dependencies
run: npm install
- name: Build Tauri app
run: npm run tauri build
- name: Get version
id: version
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
else
echo "version=dev-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
fi
- name: Rename packages
run: |
cd src-tauri/target/release/bundle/deb
DEB_FILE=$(ls *.deb | head -n 1)
mv "$DEB_FILE" "thinkutils_${{ steps.version.outputs.version }}_amd64.deb"
cd ../rpm
RPM_FILE=$(ls *.rpm | head -n 1)
mv "$RPM_FILE" "thinkutils-${{ steps.version.outputs.version }}.x86_64.rpm"
- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: |
src-tauri/target/release/bundle/deb/*.deb
src-tauri/target/release/bundle/rpm/*.rpm
src-tauri/target/release/bundle/appimage/*.AppImage
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update APT repository
if: startsWith(github.ref, 'refs/tags/')
run: |
# Install dpkg-scanpackages
sudo apt-get install -y dpkg-dev
# Clone or create gh-pages branch
git fetch origin gh-pages:gh-pages 2>/dev/null || true
git worktree add gh-pages-dir gh-pages 2>/dev/null || {
git worktree add --detach gh-pages-dir
cd gh-pages-dir
git checkout --orphan gh-pages
git rm -rf . 2>/dev/null || true
cd ..
}
# Set up apt directory
mkdir -p gh-pages-dir/apt
# Copy the new .deb (keep only the latest version)
rm -f gh-pages-dir/apt/*.deb
cp src-tauri/target/release/bundle/deb/*.deb gh-pages-dir/apt/
# Generate APT repo metadata
cd gh-pages-dir/apt
dpkg-scanpackages --multiversion . /dev/null > Packages
gzip -k -f Packages
# Generate Release file
apt-ftparchive release . > Release
# Create index page
cat > ../index.html << 'HTMLEOF'
<!DOCTYPE html>
<html>
<head><title>ThinkUtils APT Repository</title></head>
<body>
<h1>ThinkUtils APT Repository</h1>
<p>Add this repository to install ThinkUtils via apt:</p>
<pre>
echo "deb [trusted=yes] https://gh.vietanh.dev/ThinkUtils/apt ./" | sudo tee /etc/apt/sources.list.d/thinkutils.list
sudo apt update
sudo apt install thinkutils
</pre>
</body>
</html>
HTMLEOF
# Commit and push
cd ..
git add -A
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -m "Update APT repository for ${{ steps.version.outputs.version }}"
git push origin gh-pages
- name: Upload artifacts (non-tag builds)
if: "!startsWith(github.ref, 'refs/tags/')"
uses: actions/upload-artifact@v4
with:
name: thinkutils-packages-${{ steps.version.outputs.version }}
path: |
src-tauri/target/release/bundle/deb/*.deb
src-tauri/target/release/bundle/rpm/*.rpm