From 4d96a934e3a4b560e1d94d54164763c29f7c92f3 Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Tue, 24 Feb 2026 17:21:59 +0800 Subject: Update publish-aur.yml --- .github/workflows/publish-aur.yml | 68 ++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 37 deletions(-) diff --git a/.github/workflows/publish-aur.yml b/.github/workflows/publish-aur.yml index ee4eec9..c26c8bf 100644 --- a/.github/workflows/publish-aur.yml +++ b/.github/workflows/publish-aur.yml @@ -1,9 +1,7 @@ -name: Publish to AUR -on: + name: Publish to AUR + + on: push: - branches: - - main - - master tags: - 'v*' workflow_dispatch: @@ -12,42 +10,32 @@ on: description: 'Tag (v开头)' required: false type: string - -jobs: + + jobs: aur: runs-on: ubuntu-latest container: image: archlinux:latest - if: | - github.event_name == 'workflow_dispatch' && github.event.inputs.tag != '' || - startsWith(github.ref, 'refs/tags/v') steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - name: Install dependencies + run: pacman -Sy --noconfirm git openssh base-devel - name: Set up SSH for AUR run: | mkdir -p ~/.ssh echo "${{ secrets.AUR_SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519 chmod 600 ~/.ssh/id_ed25519 - - - name: Install dependencies - run: pacman -Sy --noconfirm git openssh base-devel - - - name: Add AUR host to known_hosts - run: ssh-keyscan -t ed25519 aur.archlinux.org >> ~/.ssh/known_hosts + chmod 700 ~/.ssh + ssh-keyscan -t ed25519 aur.archlinux.org >> ~/.ssh/known_hosts - - name: Set SSH permissions for current user - run: chown $(id -u):$(id -g) ~/.ssh/id_ed25519 ~/.ssh/known_hosts - - - name: Clone AUR repository + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Prepare PKGBUILD and .SRCINFO run: | - GIT_SSH_COMMAND="ssh -i ~/.ssh/id_ed25519 -o UserKnownHostsFile=~/.ssh/known_hosts" git clone ssh://aur@aur.archlinux.org/soon.git aur-repo - cd aur-repo - if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ github.event.inputs.tag }}" != "" ]; - then + if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.tag }}" ]; then TAG="${{ github.event.inputs.tag }}" else TAG="${GITHUB_REF##*/}" @@ -55,12 +43,18 @@ jobs: VERSION="${TAG#v}" sed -i "s/^pkgver=.*/pkgver=${VERSION}/" PKGBUILD makepkg --printsrcinfo > .SRCINFO - git add PKGBUILD .SRCINFO - if git diff --cached --quiet; then - echo "No changes to commit" - exit 0 - fi - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git commit -m "release: $TAG" - git push origin master + + - name: Set git user + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + - name: Push to AUR + run: | + rm -rf pkg src + GIT_SSH_COMMAND="ssh -i ~/.ssh/id_ed25519 -o UserKnownHostsFile=~/.ssh/known_hosts" git clone ssh://aur@aur.archlinux.org/soon.git aur-push + cp PKGBUILD .SRCINFO aur-push/ 2>/dev/null || true + cd aur-push + git add PKGBUILD .SRCINFO 2>/dev/null || true + git commit -m "release: $VERSION" || echo "Nothing to commit" + git push -- cgit v1.2.3-70-g09d2