diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index c8a7803..8f01dbb 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -105,16 +105,16 @@ jobs: VERSION="${{ github.event.inputs.tag || github.ref_name }}" PKGVER="${VERSION#v}" - # Source tarball — prefix=unitdore/ matches `cd "$pkgname"` in PKGBUILD - git archive --format=tar.gz --prefix=unitdore/ HEAD \ - > pkg/arch/unitdore-${PKGVER}.tar.gz - SHA=$(sha256sum pkg/arch/unitdore-${PKGVER}.tar.gz | cut -d' ' -f1) + # Source archive — prefix=unitdore-vVERSION/ matches `cd "$pkgname-v$pkgver"` in PKGBUILD + git archive --format=zip --prefix=unitdore-v${PKGVER}/ HEAD \ + > pkg/arch/unitdore-${PKGVER}.zip + SHA=$(sha256sum pkg/arch/unitdore-${PKGVER}.zip | cut -d' ' -f1) # Patch PKGBUILD for local build sed -i \ -e "s/^pkgver=.*/pkgver=${PKGVER}/" \ -e "s/^sha256sums=.*/sha256sums=('${SHA}')/" \ - -e "s|source=.*|source=(\"unitdore-\${pkgver}.tar.gz\")|" \ + -e "s|source=.*|source=(\"unitdore-\${pkgver}.zip\")|" \ pkg/arch/PKGBUILD mkdir -p pkg/arch/out @@ -148,6 +148,57 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + pkg-aur: + needs: release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Publish to AUR + env: + AUR_SSH_KEY: ${{ secrets.AUR_SSH_KEY }} + run: | + VERSION="${{ github.event.inputs.tag || github.ref_name }}" + PKGVER="${VERSION#v}" + + # Setup SSH for AUR + mkdir -p ~/.ssh + echo "$AUR_SSH_KEY" > ~/.ssh/aur + chmod 600 ~/.ssh/aur + ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts + + # Clone AUR repo + GIT_SSH_COMMAND="ssh -i ~/.ssh/aur" git clone ssh://aur@aur.archlinux.org/unitdore.git aur-repo + + # Compute SHA256 of the release tarball (same URL the PKGBUILD will download) + SHA=$(curl -fsSL "https://git.warky.dev/wdevs/unitdore/archive/v${PKGVER}.zip" | sha256sum | cut -d' ' -f1) + + # Update PKGBUILD — keep remote source URL, only bump version and checksum + sed -e "s/^pkgver=.*/pkgver=${PKGVER}/" \ + -e "s/^pkgrel=.*/pkgrel=1/" \ + -e "s/^sha256sums=.*/sha256sums=('${SHA}')/" \ + pkg/arch/PKGBUILD > aur-repo/PKGBUILD + + # Generate .SRCINFO inside an Arch container + docker run --rm \ + -v "$PWD/aur-repo:/build" \ + -w /build \ + archlinux:latest \ + bash -c " + pacman -Sy --noconfirm base-devel && + useradd -m builder && + chown -R builder:builder /build && + runuser -u builder -- bash -c 'cd /build && makepkg --printsrcinfo > .SRCINFO' + " + + # Commit and push to AUR master + cd aur-repo + git config user.email "hein@warky.dev" + git config user.name "Hein" + git add PKGBUILD .SRCINFO + git commit -m "Update to v${PKGVER}" + GIT_SSH_COMMAND="ssh -i ~/.ssh/aur" git push origin HEAD:master + pkg-deb: needs: release runs-on: ubuntu-latest diff --git a/pkg/arch/PKGBUILD b/pkg/arch/PKGBUILD index 0ccaf1f..052db2d 100644 --- a/pkg/arch/PKGBUILD +++ b/pkg/arch/PKGBUILD @@ -4,7 +4,7 @@ pkgver=0.1.0 pkgrel=1 pkgdesc="A door you open and close for container units — manage containers via systemd" arch=('x86_64' 'aarch64') -url="https://warky.dev" +url="https://git.warky.dev/wdevs/unitdore" license=('MIT') depends=('systemd') optdepends=( @@ -13,11 +13,11 @@ optdepends=( ) makedepends=('go') backup=('etc/unitdore/units.yaml') -source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz") +source=("$pkgname-$pkgver.zip::$url/archive/v$pkgver.zip") sha256sums=('SKIP') build() { - cd "$pkgname" + cd "$pkgname-v$pkgver" export CGO_ENABLED=0 go build \ -trimpath \ @@ -26,12 +26,12 @@ build() { } check() { - cd "$pkgname" + cd "$pkgname-v$pkgver" go test ./... } package() { - cd "$pkgname" + cd "$pkgname-v$pkgver" # Binary install -Dm755 "$pkgname" "$pkgdir/usr/bin/$pkgname" diff --git a/pkg/centos/unitdore.spec b/pkg/centos/unitdore.spec index beda9a9..cebe76e 100644 --- a/pkg/centos/unitdore.spec +++ b/pkg/centos/unitdore.spec @@ -4,7 +4,7 @@ Release: 1%{?dist} Summary: Manage container units via systemd License: MIT -URL: https://warky.dev +URL: https://git.warky.dev/wdevs/unitdore Source0: %{name}-%{version}.tar.gz BuildRequires: golang >= 1.23