Skip to content

fine tune value display #47

fine tune value display

fine tune value display #47

Workflow file for this run

on:
push:
tags:
- "v*"
jobs:
version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
lfs: true
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- run: mkdir -p ./version
- run: git describe --tags "$(git rev-list --tags --max-count=1)" > ./version/version
- uses: actions/upload-artifact@master
with:
name: version
path: ./version/version
build:
needs:
- version
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-latest
target: universal-apple-darwin
suffix: .dmg
use_docker: false
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
suffix: ""
use_docker: true
- os: windows-latest
target: x86_64-pc-windows-msvc
suffix: .exe
use_docker: false
steps:
- uses: actions/checkout@master
with:
lfs: true
- id: get_repository_name
run: echo "REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//")" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/download-artifact@master
with:
name: version
path: ./version
- id: get_version
run: echo "VERSION=$(cat ./version/version)" >> $GITHUB_OUTPUT
shell: bash
- name: Set up Docker for Linux build
if: ${{ matrix.use_docker }}
run: |
echo "Running Linux build in Docker container"
- name: Build Linux binary in Docker
if: ${{ matrix.use_docker }}
run: |
docker run --rm -v $(pwd):/usr/src/rusty_meter -w /usr/src/rusty_meter rockylinux:8 /bin/bash -c '
dnf install -y epel-release &&
dnf config-manager --set-enabled powertools &&
dnf groupinstall -y "Development Tools" &&
dnf install -y curl clang clang-devel libxkbcommon-devel mesa-libGL-devel libX11-devel \
wayland-devel libpng-devel libjpeg-devel openssl-devel pkgconf-pkg-config &&
curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.92.0 &&
source $HOME/.cargo/env &&
rustc --version &&
ls -l /usr/lib64/libclang* &&
export LIBCLANG_PATH=/usr/lib64 &&
cargo build --release --target x86_64-unknown-linux-gnu &&
ldd --version &&
objdump -p target/x86_64-unknown-linux-gnu/release/rusty_meter | grep GLIBC
'
- name: Create AppImage for Linux
if: ${{ matrix.use_docker }}
run: |
# Download linuxdeploy AppImage
wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
chmod +x linuxdeploy-x86_64.AppImage
# Create AppDir structure
mkdir -p AppDir/usr/bin
mkdir -p AppDir/usr/share/applications
mkdir -p AppDir/usr/share/icons/hicolor/48x48/apps
# Copy binary
cp target/x86_64-unknown-linux-gnu/release/rusty_meter AppDir/usr/bin/
# Copy icon
cp assets/chart-line-solid.png AppDir/usr/share/icons/hicolor/48x48/apps/chart-line-solid.png
# Create .desktop file
cat << EOF > AppDir/usr/share/applications/multimeter.desktop
[Desktop Entry]
Name=RustyMeter
Exec=rusty_meter
Type=Application
Icon=chart-line-solid
Terminal=false
Categories=Utility;
EOF
# Generate AppImage
./linuxdeploy-x86_64.AppImage --appdir AppDir --output appimage
mv RustyMeter*.AppImage RustyMeter-${{ steps.get_version.outputs.VERSION }}-x86_64.AppImage
- name: Install Rust toolchain (non-Docker)
if: ${{ !matrix.use_docker }}
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Cache Rust dependencies (non-Docker)
if: ${{ !matrix.use_docker }}
uses: actions/cache@master
with:
path: ~/.cargo/registry
key: "${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}"
- name: Cache Rust git index (non-Docker)
if: ${{ !matrix.use_docker }}
uses: actions/cache@master
with:
path: ~/.cargo/git
key: "${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}"
- name: Cache build target (non-Docker)
if: ${{ !matrix.use_docker }}
uses: actions/cache@master
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Install dependencies for macOS DMG
if: ${{ matrix.target == 'universal-apple-darwin' }}
run: |
brew install librsvg libpng create-dmg
npm install -g @electron-forge/cli
- name: Build macOS universal binary
if: ${{ matrix.target == 'universal-apple-darwin' }}
run: |
rustup target add x86_64-apple-darwin aarch64-apple-darwin
cargo build --release --target x86_64-apple-darwin
cargo build --release --target aarch64-apple-darwin
lipo -create -output target/release/rusty_meter \
target/x86_64-apple-darwin/release/rusty_meter \
target/aarch64-apple-darwin/release/rusty_meter
chmod +x target/release/rusty_meter
- name: Convert SVG to ICNS
if: ${{ matrix.target == 'universal-apple-darwin' }}
run: |
mkdir -p icon.iconset
mkdir -p icon-dmg.iconset
# Generate high-quality PNGs for application ICNS
rsvg-convert -w 16 -h 16 assets/chart-line-solid.svg -o icon.iconset/icon_16x16.png
rsvg-convert -w 32 -h 32 assets/chart-line-solid.svg -o icon.iconset/icon_16x16@2x.png
rsvg-convert -w 32 -h 32 assets/chart-line-solid.svg -o icon.iconset/icon_32x32.png
rsvg-convert -w 64 -h 64 assets/chart-line-solid.svg -o icon.iconset/icon_32x32@2x.png
rsvg-convert -w 128 -h 128 assets/chart-line-solid.svg -o icon.iconset/icon_128x128.png
rsvg-convert -w 256 -h 256 assets/chart-line-solid.svg -o icon.iconset/icon_128x128@2x.png
rsvg-convert -w 256 -h 256 assets/chart-line-solid.svg -o icon.iconset/icon_256x256.png
rsvg-convert -w 512 -h 512 assets/chart-line-solid.svg -o icon.iconset/icon_256x256@2x.png
rsvg-convert -w 512 -h 512 assets/chart-line-solid.svg -o icon.iconset/icon_512x512.png
rsvg-convert -w 1024 -h 1024 assets/chart-line-solid.svg -o icon.iconset/icon_512x512@2x.png
iconutil -c icns icon.iconset -o assets/RustyMeter.icns
# Generate high-quality PNGs for DMG ICNS
rsvg-convert -w 16 -h 16 assets/chart-line-solid.svg -o icon-dmg.iconset/icon_16x16.png
rsvg-convert -w 32 -h 32 assets/chart-line-solid.svg -o icon-dmg.iconset/icon_16x16@2x.png
rsvg-convert -w 32 -h 32 assets/chart-line-solid.svg -o icon-dmg.iconset/icon_32x32.png
rsvg-convert -w 64 -h 64 assets/chart-line-solid.svg -o icon-dmg.iconset/icon_32x32@2x.png
rsvg-convert -w 128 -h 128 assets/chart-line-solid.svg -o icon-dmg.iconset/icon_128x128.png
rsvg-convert -w 256 -h 256 assets/chart-line-solid.svg -o icon-dmg.iconset/icon_128x128@2x.png
rsvg-convert -w 256 -h 256 assets/chart-line-solid.svg -o icon-dmg.iconset/icon_256x256.png
rsvg-convert -w 512 -h 512 assets/chart-line-solid.svg -o icon-dmg.iconset/icon_256x256@2x.png
rsvg-convert -w 512 -h 512 assets/chart-line-solid.svg -o icon-dmg.iconset/icon_512x512.png
rsvg-convert -w 1024 -h 1024 assets/chart-line-solid.svg -o icon-dmg.iconset/icon_512x512@2x.png
iconutil -c icns icon-dmg.iconset -o assets/RustyMeter-dmg.icns
- name: Create macOS app bundle
if: ${{ matrix.target == 'universal-apple-darwin' }}
run: |
mkdir -p RustyMeter.app/Contents/MacOS
mkdir -p RustyMeter.app/Contents/Resources
cp target/release/rusty_meter RustyMeter.app/Contents/MacOS/RustyMeter
cp assets/RustyMeter.icns RustyMeter.app/Contents/Resources/RustyMeter.icns
cat << EOF > RustyMeter.app/Contents/Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>RustyMeter</string>
<key>CFBundleIconFile</key>
<string>RustyMeter</string>
<key>CFBundleIdentifier</key>
<string>com.example.RustyMeter</string>
<key>CFBundleName</key>
<string>RustyMeter</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleVersion</key>
<string>${{ steps.get_version.outputs.VERSION }}</string>
<key>LSMinimumSystemVersion</key>
<string>10.13</string>
</dict>
</plist>
EOF
- name: Create DMG
if: ${{ matrix.target == 'universal-apple-darwin' }}
run: |
create-dmg \
--volname "RustyMeter" \
--volicon "assets/RustyMeter-dmg.icns" \
--window-pos 200 120 \
--window-size 800 400 \
--icon-size 100 \
--icon "RustyMeter.app" 200 190 \
--hide-extension "RustyMeter.app" \
--app-drop-link 600 185 \
"RustyMeter-${{ steps.get_version.outputs.VERSION }}.dmg" \
"RustyMeter.app"
ls -l *.dmg
- name: Build (non-Docker, non-macOS)
if: ${{ !matrix.use_docker && matrix.target != 'universal-apple-darwin' }}
uses: actions-rs/cargo@v1
env:
VERSION: "${{ steps.get_version.outputs.VERSION }}"
REPOSITORY_NAME: "${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}"
with:
command: build
args: "--release"
- name: Upload artifact
uses: actions/upload-artifact@master
with:
name: ${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-${{ matrix.target }}
path: |
${{ matrix.target == 'universal-apple-darwin' && format('RustyMeter-{0}.dmg', steps.get_version.outputs.VERSION) || matrix.target == 'x86_64-unknown-linux-gnu' && format('RustyMeter-{0}-x86_64.AppImage', steps.get_version.outputs.VERSION) || format('./target/{1}release/rusty_meter{0}', matrix.suffix, matrix.use_docker && 'x86_64-unknown-linux-gnu/' || '') }}
${{ matrix.target == 'x86_64-unknown-linux-gnu' && './target/x86_64-unknown-linux-gnu/release/rusty_meter' || '' }}
release:
needs:
- build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
lfs: true
- id: get_repository_name
run: echo "REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//")" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/download-artifact@master
with:
name: version
path: ./version
- id: get_version
run: echo "VERSION=$(cat ./version/version)" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/download-artifact@master
with:
name: ${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-x86_64-unknown-linux-gnu
path: ./${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-x86_64-unknown-linux-gnu/
- uses: actions/download-artifact@master
with:
name: ${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-universal-apple-darwin
path: ./${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-universal-apple-darwin/
- uses: actions/download-artifact@master
with:
name: ${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-x86_64-pc-windows-msvc
path: ./${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-x86_64-pc-windows-msvc/
- run: ls -lah ./${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-universal-apple-darwin/
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
tag_name: "${{ steps.get_version.outputs.VERSION }}"
release_name: "Release ${{ steps.get_version.outputs.VERSION }}"
draft: false
prerelease: false
- uses: actions/upload-release-asset@latest
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
upload_url: "${{ steps.create_release.outputs.upload_url }}"
asset_path: ./${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-x86_64-unknown-linux-gnu/target/x86_64-unknown-linux-gnu/release/rusty_meter
asset_name: ${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-x86_64-unknown-linux-gnu
asset_content_type: application/octet-stream
- uses: actions/upload-release-asset@latest
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
upload_url: "${{ steps.create_release.outputs.upload_url }}"
asset_path: ./${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-x86_64-unknown-linux-gnu/RustyMeter-${{ steps.get_version.outputs.VERSION }}-x86_64.AppImage
asset_name: ${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-x86_64.AppImage
asset_content_type: application/x-executable
- uses: actions/upload-release-asset@latest
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
upload_url: "${{ steps.create_release.outputs.upload_url }}"
asset_path: ./${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-universal-apple-darwin/RustyMeter-${{ steps.get_version.outputs.VERSION }}.dmg
asset_name: ${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-universal-apple-darwin.dmg
asset_content_type: application/x-diskcopy
- uses: actions/upload-release-asset@latest
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
upload_url: "${{ steps.create_release.outputs.upload_url }}"
asset_path: ./${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-x86_64-pc-windows-msvc/rusty_meter.exe
asset_name: ${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-x86_64-pc-windows-msvc.exe
asset_content_type: application/octet-stream