Skip to content

Bump version to 0.4.0 #20

Bump version to 0.4.0

Bump version to 0.4.0 #20

Workflow file for this run

name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
runner: macos-14
os: macos
- target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
os: linux
- target: x86_64-pc-windows-msvc
runner: windows-latest
os: windows
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: release-${{ matrix.target }}
- name: Install Linux deps
if: matrix.os == 'linux'
run: sudo apt-get update && sudo apt-get install -y libudev-dev libxkbcommon-dev libglib2.0-dev libgtk-3-dev libxdo-dev
- name: Build release binaries
run: cargo build --release --target ${{ matrix.target }} -p hidpp-cli -p hidpp-daemon
- name: Determine version
id: version
shell: bash
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Package (Unix)
if: matrix.os != 'windows'
shell: bash
run: |
STAGING="hidpp-${{ steps.version.outputs.version }}-${{ matrix.target }}"
mkdir -p "${STAGING}"
cp "target/${{ matrix.target }}/release/hidpp" "${STAGING}/"
cp "target/${{ matrix.target }}/release/hidppd" "${STAGING}/"
if [ "${{ matrix.os }}" = "linux" ]; then
cp udev/99-hidpp.rules "${STAGING}/"
fi
"target/${{ matrix.target }}/release/hidppd" sample-config > "${STAGING}/config.toml.sample" 2>/dev/null || true
tar czf "${STAGING}.tar.gz" "${STAGING}"
echo "ASSET=${STAGING}.tar.gz" >> "$GITHUB_ENV"
- name: Package (Windows)
if: matrix.os == 'windows'
shell: pwsh
run: |
$version = "${{ steps.version.outputs.version }}"
$staging = "hidpp-${version}-${{ matrix.target }}"
New-Item -ItemType Directory -Path $staging
Copy-Item "target/${{ matrix.target }}/release/hidpp.exe" $staging/
Copy-Item "target/${{ matrix.target }}/release/hidppd.exe" $staging/
Compress-Archive -Path $staging -DestinationPath "${staging}.zip"
echo "ASSET=${staging}.zip" >> $env:GITHUB_ENV
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: ${{ env.ASSET }}
dmg:
name: macOS DMG
needs: build
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- name: Download macOS build
uses: actions/download-artifact@v4
with:
name: aarch64-apple-darwin
- name: Determine version
id: version
shell: bash
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Create DMG
shell: bash
run: |
VERSION="${{ steps.version.outputs.version }}"
DMG_DIR="dmg-staging"
tar xzf "hidpp-${VERSION}-aarch64-apple-darwin.tar.gz"
SRC_DIR="hidpp-${VERSION}-aarch64-apple-darwin"
# Assemble .app bundle.
APP="${DMG_DIR}/HID++.app/Contents"
mkdir -p "${APP}/MacOS" "${APP}/Resources"
cp "${SRC_DIR}/hidpp" "${APP}/MacOS/"
cp "${SRC_DIR}/hidppd" "${APP}/MacOS/"
chmod +x "${APP}/MacOS/hidpp" "${APP}/MacOS/hidppd"
cp bundle/Info.plist "${APP}/Info.plist"
cp bundle/AppIcon.icns "${APP}/Resources/AppIcon.icns"
echo 'APPL????' > "${APP}/PkgInfo"
# Applications alias for drag-to-install.
ln -s /Applications "${DMG_DIR}/Applications"
DMG_NAME="hidpp-${VERSION}-macos-arm64.dmg"
hdiutil create -volname "HID++ ${VERSION}" \
-srcfolder "${DMG_DIR}" \
-ov -format UDZO \
"${DMG_NAME}"
echo "DMG_ASSET=${DMG_NAME}" >> "$GITHUB_ENV"
- name: Upload DMG
uses: actions/upload-artifact@v4
with:
name: macos-dmg
path: ${{ env.DMG_ASSET }}
release:
name: GitHub Release
needs: [ build, dmg ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: hidpp ${{ github.ref_name }}
draft: false
prerelease: ${{ contains(github.ref_name, '-') }}
generate_release_notes: true
files: |
hidpp-*.tar.gz
hidpp-*.zip
hidpp-*.dmg
update-tap:
name: Update Homebrew Tap
needs: release
runs-on: ubuntu-latest
steps:
- name: Generate app token
uses: actions/create-github-app-token@v2
id: app-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
repositories: homebrew-tap
- name: Determine version
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Compute source tarball SHA256
id: sha
run: |
curl -sL -o source.tar.gz \
"https://github.com/jlevere/hidpp/archive/refs/tags/${GITHUB_REF_NAME}.tar.gz"
SHA=$(sha256sum source.tar.gz | awk '{print $1}')
echo "sha256=$SHA" >> "$GITHUB_OUTPUT"
- name: Checkout tap repo
uses: actions/checkout@v4
with:
repository: jlevere/homebrew-tap
token: ${{ steps.app-token.outputs.token }}
path: tap
- name: Update formula
run: |
cd tap
sed -i 's|url "https://github.com/jlevere/hidpp/archive/refs/tags/v.*\.tar\.gz"|url "https://github.com/jlevere/hidpp/archive/refs/tags/${{ github.ref_name }}.tar.gz"|' Formula/hidpp.rb
sed -i 's|sha256 ".*"|sha256 "${{ steps.sha.outputs.sha256 }}"|' Formula/hidpp.rb
- name: Commit and push
run: |
cd tap
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/hidpp.rb
git diff --cached --quiet && echo "No changes" && exit 0
git commit -m "bump hidpp to ${{ steps.version.outputs.version }}"
git push