aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/.github/workflows/publish-aur.yml
blob: ba8f9029ed45026dde9e430e96fd4feab1343b24 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
   name: Publish to AUR

   on:
     push:
       tags:
         - 'v*'
     workflow_dispatch:
       inputs:
         tag:
           description: 'Tag (v开头)'
           required: false
           type: string

   jobs:
     aur:
       runs-on: ubuntu-latest
       container:
         image: archlinux:latest
       steps:
         - 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
             chmod 700 ~/.ssh
             ssh-keyscan -t ed25519 aur.archlinux.org >> ~/.ssh/known_hosts

         - name: Checkout repository
           uses: actions/checkout@v4
           with:
             fetch-depth: 0

         - name: Debug workspace
           run: |
             echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE"
             ls -al $GITHUB_WORKSPACE

         - 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: Prepare PKGBUILD and .SRCINFO
           run: |
             cd $GITHUB_WORKSPACE
             if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.tag }}" ]; then
               TAG="${{ github.event.inputs.tag }}"
             else
               TAG="${GITHUB_REF##*/}"
             fi
             VERSION="${TAG#v}"
             sed -i "s/^pkgver=.*/pkgver=${VERSION}/" PKGBUILD
             makepkg --printsrcinfo > .SRCINFO

         - name: Push to AUR
           run: |
             cd $GITHUB_WORKSPACE
             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 README* LICENSE* aur-push/ 2>/dev/null || true
             cd aur-push
             git config user.name "github-actions[bot]"
             git config user.email "github-actions[bot]@users.noreply.github.com"
             git add PKGBUILD .SRCINFO README* LICENSE* 2>/dev/null || true
             git commit -m "release: $VERSION" || echo "Nothing to commit"
             git push