diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fd2303c..ef6c2ad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -186,3 +186,41 @@ jobs: DEB_PATH: ${{ steps.package_info.outputs.deb_path }} run: | gh release upload ${{ needs.create_gh_release.outputs.tag_name }} "${{ env.DEB_PATH }}" + + aur-publish: + permissions: + contents: read + needs: + - create_gh_release + - build_and_upload_source_archive + if: '!github.event.prerelease' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Install dependencies + run: | + sudo apt-get update -qq + sudo apt-get install -y --no-install-recommends git gettext-base + + - name: Generate PKGBUILD + env: + PKG_VERSION: ${{ needs.create_gh_release.outputs.version }} + TAG_NAME: ${{ needs.create_gh_release.outputs.tag_name }} + PKGBUILD_TEMPLATE_PATH: ./AUR/PKGBUILD.in + PKGBUILD_PATH: ./AUR/PKGBUILD + run: | + export PROJECT_NAME=$(grep -A 10 '\[package\]' Cargo.toml | grep '^name *=' | sed 's/name *= *"\(.*\)"/\1/') + echo "Generating PKGBUILD at $PKGBUILD_PATH" + /usr/bin/envsubst < "$PKGBUILD_TEMPLATE_PATH" > "$PKGBUILD_PATH" + + - name: Publish AUR package + uses: KSXGitHub/github-actions-deploy-aur@v4.1.1 + with: + pkgname: my-awesome-package + pkgbuild: ./AUR/PKGBUILD + commit_username: ${{ secrets.AUR_USERNAME }} + commit_email: ${{ secrets.AUR_EMAIL }} + ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} + commit_message: Update AUR package + ssh_keyscan_types: rsa,ecdsa,ed25519 diff --git a/AUR/PKGBUILD.in b/AUR/PKGBUILD.in new file mode 100644 index 0000000..8928c75 --- /dev/null +++ b/AUR/PKGBUILD.in @@ -0,0 +1,53 @@ +# Maintainer: Quintus Leung +pkgname=${PROJECT_NAME} +pkgver=${PKG_VERSION} +pkgrel=1 +pkgdesc="A high-performance SOCKS5 and HTTP proxy server written in Rust" +arch=('x86_64' 'i686' 'aarch64') +url="https://github.com/quintusl/rust-socksd" +license=('MIT' 'Apache-2.0') +depends=('glibc' 'gcc-libs') +makedepends=('cargo') +install=$pkgname.install +backup=('etc/rust-socksd/config.yml' 'etc/rust-socksd/users.yml') +source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz") +sha256sums=('SKIP') + +prepare() { + cd "$pkgname-$pkgver" + export RUSTUP_TOOLCHAIN=stable + cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')" +} + +build() { + cd "$pkgname-$pkgver" + export RUSTUP_TOOLCHAIN=stable + export CARGO_TARGET_DIR=target + cargo build --frozen --release --all-features +} + +check() { + cd "$pkgname-$pkgver" + export RUSTUP_TOOLCHAIN=stable + cargo test --frozen --all-features +} + +package() { + cd "$pkgname-$pkgver" + + # Install binary + install -Dm0755 -t "$pkgdir/usr/bin/" "target/release/$pkgname" + + # Install systemd service + install -Dm0644 config/rust-socksd.service "$pkgdir/usr/lib/systemd/system/rust-socksd.service" + install -Dm0644 config/rust-socksd.sysusers.conf "$pkgdir/usr/lib/sysusers.d/rust-socksd.conf" + + # Install configuration + install -Dm0644 config/config.yml.journald.example "$pkgdir/etc/rust-socksd/config.yml" + install -Dm0664 config/users.yml.example "$pkgdir/etc/rust-socksd/users.yml" + + # Install documentation + install -Dm0644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md" + install -Dm0644 LICENSE-MIT "$pkgdir/usr/share/licenses/$pkgname/LICENSE-MIT" + install -Dm0644 LICENSE-APACHE "$pkgdir/usr/share/licenses/$pkgname/LICENSE-APACHE" +}