Skip to content

Change installation path for binary to /usr/local/bin in PKGBUILD #9

Change installation path for binary to /usr/local/bin in PKGBUILD

Change installation path for binary to /usr/local/bin in PKGBUILD #9

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Run tests
run: |
cargo fmt --all -- --check
cargo clippy -- -D warnings
cargo test
release:
needs: test
name: Release - ${{ matrix.platform.release_for }}
strategy:
matrix:
platform:
- release_for: Linux-x86_64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
bin: observer
name: observer-linux-amd64
runs-on: ${{ matrix.platform.os }}
steps:
- uses: actions/checkout@v4
- name: Install cross-compilation dependencies
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.target }}
- name: Build binary
run: cargo build --release --target ${{ matrix.platform.target }}
- name: Package Release
shell: bash
run: |
mkdir -p release
cp target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} release/
cp install.sh release/
cp observer.service release/
cp config.toml release/
cd release
tar czf ../${{ matrix.platform.name }}.tar.gz *
- name: Generate SHA256 checksum
run: |
cd ${{ github.workspace }}
sha256sum ${{ matrix.platform.name }}.tar.gz > ${{ matrix.platform.name }}.sha256
- name: Upload Release
uses: softprops/action-gh-release@v1
with:
files: |
${{ matrix.platform.name }}.tar.gz
${{ matrix.platform.name }}.sha256
aur-publish:
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Update PKGBUILD version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
sed -i "s/pkgver=.*/pkgver=$VERSION/" PKGBUILD
NEW_SHA256=$(curl -sL https://github.com/${{ github.repository }}/releases/download/v${VERSION}/observer-linux-amd64.sha256 | awk '{print $1}')
sed -i "s/sha256sums=('.*')/sha256sums=('${NEW_SHA256}')/" PKGBUILD
- name: Generate .SRCINFO
run: |
docker run --rm -v $PWD:/pkg -w /pkg archlinux:base-devel bash -c '
pacman -Syu --noconfirm &&
pacman -S --noconfirm pacman-contrib &&
useradd builduser -m &&
chown -R builduser:builduser /pkg &&
su builduser -c "makepkg --printsrcinfo > .SRCINFO"
'
- name: Publish to AUR
uses: KSXGitHub/[email protected]
with:
pkgname: observer
pkgbuild: ./PKGBUILD
commit_username: ${{ secrets.AUR_USERNAME }}
commit_email: ${{ secrets.AUR_EMAIL }}
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: "Update to version ${{ github.ref_name }}"