aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/update-pkgbuilds.yml
blob: e33843d297e519c1197c555fab1f2b62e4f24588 (plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
name: Update PKGBUILDs

on:
  schedule:
    - cron: '0 4 * * *'
  workflow_dispatch:

jobs:
  update-sing-box-beta-bin:
    name: Update sing-box-beta-bin
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v6

      - name: Get latest pre-release version
        id: version
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          VERSION=$(gh api repos/SagerNet/sing-box/releases \
            --jq '[.[] | select(.prerelease)] | first | .tag_name | ltrimstr("v")')
          echo "version=$VERSION" >> "$GITHUB_OUTPUT"

      - name: Check current version
        id: check
        run: |
          CURRENT=$(grep '^_pkgver=' repo/sing-box-beta-bin/PKGBUILD | cut -d'"' -f2)
          echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
          if [ "$CURRENT" = "${{ steps.version.outputs.version }}" ]; then
            echo "skip=true" >> "$GITHUB_OUTPUT"
          else
            echo "skip=false" >> "$GITHUB_OUTPUT"
          fi

      - name: Download assets and compute sha256sums
        if: steps.check.outputs.skip == 'false'
        id: sums
        env:
          VERSION: ${{ steps.version.outputs.version }}
          GIT_URL: https://github.com/SagerNet/sing-box
        run: |
          for ARCH in x86_64 aarch64 armv7h; do
            # upstream uses armv7hl in filenames for armv7h
            FILE_ARCH="$ARCH"
            [ "$ARCH" = "armv7h" ] && FILE_ARCH="armv7hl"
            FILE="sing-box_${VERSION}_linux_${FILE_ARCH}.pkg.tar.zst"
            URL="$GIT_URL/releases/download/v${VERSION}/$FILE"
            wget -q "$URL" -O "$FILE"
            SUM=$(sha256sum "$FILE" | awk '{print $1}')
            echo "sum_${ARCH}=$SUM" >> "$GITHUB_OUTPUT"
            rm "$FILE"
          done

      - name: Update PKGBUILD
        if: steps.check.outputs.skip == 'false'
        env:
          VERSION: ${{ steps.version.outputs.version }}
          SUM_X86_64: ${{ steps.sums.outputs.sum_x86_64 }}
          SUM_ARMV7H: ${{ steps.sums.outputs.sum_armv7h }}
          SUM_AARCH64: ${{ steps.sums.outputs.sum_aarch64 }}
        run: |
          sed -i "s/^_pkgver=.*/_pkgver=\"${VERSION}\"/" repo/sing-box-beta-bin/PKGBUILD
          sed -i "s/^pkgrel=.*/pkgrel=\"1\"/" repo/sing-box-beta-bin/PKGBUILD
          sed -i "s/^sha256sums_x86_64=.*/sha256sums_x86_64=(\"${SUM_X86_64}\")/" repo/sing-box-beta-bin/PKGBUILD
          sed -i "s/^sha256sums_armv7h=.*/sha256sums_armv7h=(\"${SUM_ARMV7H}\")/" repo/sing-box-beta-bin/PKGBUILD
          sed -i "s/^sha256sums_aarch64=.*/sha256sums_aarch64=(\"${SUM_AARCH64}\")/" repo/sing-box-beta-bin/PKGBUILD

      - name: Commit and push
        if: steps.check.outputs.skip == 'false'
        env:
          VERSION: ${{ steps.version.outputs.version }}
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add repo/sing-box-beta-bin/PKGBUILD
          git commit -m "feat(pkg): Update sing-box-beta-bin to ${VERSION}"
          git push || (git pull --rebase && git push)

  update-telegram-bot-api:
    name: Update telegram-bot-api
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v6

      - name: Get latest version from CMakeLists.txt
        id: version
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          VERSION=$(curl -sf "https://raw.githubusercontent.com/tdlib/telegram-bot-api/master/CMakeLists.txt" \
            | grep -oP 'project\(TelegramBotApi VERSION \K[0-9]+\.[0-9]+')
          COMMIT=$(gh api repos/tdlib/telegram-bot-api/commits/master --jq '.sha')
          echo "version=$VERSION" >> "$GITHUB_OUTPUT"
          echo "commit=$COMMIT" >> "$GITHUB_OUTPUT"

      - name: Check current version
        id: check
        run: |
          CURRENT=$(grep '^pkgver=' repo/telegram-bot-api/PKGBUILD | cut -d'=' -f2)
          echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
          if [ "$CURRENT" = "${{ steps.version.outputs.version }}" ]; then
            echo "skip=true" >> "$GITHUB_OUTPUT"
          else
            echo "skip=false" >> "$GITHUB_OUTPUT"
          fi

      - name: Update PKGBUILD
        if: steps.check.outputs.skip == 'false'
        env:
          VERSION: ${{ steps.version.outputs.version }}
          COMMIT: ${{ steps.version.outputs.commit }}
        run: |
          sed -i "s/^pkgver=.*/pkgver=${VERSION}/" repo/telegram-bot-api/PKGBUILD
          sed -i "s/^pkgrel=.*/pkgrel=1/" repo/telegram-bot-api/PKGBUILD
          sed -i "s/#commit=[0-9a-f]*/#commit=${COMMIT}/" repo/telegram-bot-api/PKGBUILD

      - name: Commit and push
        if: steps.check.outputs.skip == 'false'
        env:
          VERSION: ${{ steps.version.outputs.version }}
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add repo/telegram-bot-api/PKGBUILD
          git commit -m "feat(pkg): Update telegram-bot-api to ${VERSION}"
          git push || (git pull --rebase && git push)

  update-acme-sh-letsencrypt:
    name: Update acme.sh-letsencrypt
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v6

      - name: Get latest release version
        id: version
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          VERSION=$(gh api repos/acmesh-official/acme.sh/releases/latest \
            --jq '.tag_name | ltrimstr("v")')
          echo "version=$VERSION" >> "$GITHUB_OUTPUT"

      - name: Check current version
        id: check
        run: |
          CURRENT=$(grep '^pkgver=' repo/acme.sh-letsencrypt/PKGBUILD | cut -d'=' -f2)
          echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
          if [ "$CURRENT" = "${{ steps.version.outputs.version }}" ]; then
            echo "skip=true" >> "$GITHUB_OUTPUT"
          else
            echo "skip=false" >> "$GITHUB_OUTPUT"
          fi

      - name: Compute sha512sum
        if: steps.check.outputs.skip == 'false'
        id: sums
        env:
          VERSION: ${{ steps.version.outputs.version }}
          GIT_URL: https://github.com/acmesh-official/acme.sh
        run: |
          FILE="acme.sh-${VERSION}.tar.gz"
          wget -q "$GIT_URL/archive/refs/tags/${VERSION}.tar.gz" -O "$FILE"
          SUM=$(sha512sum "$FILE" | awk '{print $1}')
          echo "sha512=$SUM" >> "$GITHUB_OUTPUT"
          rm "$FILE"

      - name: Update PKGBUILD
        if: steps.check.outputs.skip == 'false'
        env:
          VERSION: ${{ steps.version.outputs.version }}
          SHA512: ${{ steps.sums.outputs.sha512 }}
        run: |
          sed -i "s/^pkgver=.*/pkgver=${VERSION}/" repo/acme.sh-letsencrypt/PKGBUILD
          sed -i "s/^pkgrel=.*/pkgrel=1/" repo/acme.sh-letsencrypt/PKGBUILD
          sed -i "s/^sha512sums=.*/sha512sums=('${SHA512}')/" repo/acme.sh-letsencrypt/PKGBUILD

      - name: Commit and push
        if: steps.check.outputs.skip == 'false'
        env:
          VERSION: ${{ steps.version.outputs.version }}
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add repo/acme.sh-letsencrypt/PKGBUILD
          git commit -m "feat(pkg): Update acme.sh-letsencrypt to ${VERSION}"
          git push || (git pull --rebase && git push)

  update-ksutils-teamspeak-management-tools:
    name: Update ksutils-teamspeak-management-tools
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v6

      - name: Get latest release version
        id: version
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          VERSION=$(gh api repos/KunoiSayami/teamspeak-management-tools.rs/releases/latest \
            --jq '.tag_name | ltrimstr("v")')
          echo "version=$VERSION" >> "$GITHUB_OUTPUT"

      - name: Check current version
        id: check
        run: |
          CURRENT=$(grep '^pkgver=' repo/ksutils-teamspeak-management-tools/PKGBUILD | cut -d'=' -f2)
          echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
          if [ "$CURRENT" = "${{ steps.version.outputs.version }}" ]; then
            echo "skip=true" >> "$GITHUB_OUTPUT"
          else
            echo "skip=false" >> "$GITHUB_OUTPUT"
          fi

      - name: Update PKGBUILD
        if: steps.check.outputs.skip == 'false'
        env:
          VERSION: ${{ steps.version.outputs.version }}
        run: |
          sed -i "s/^pkgver=.*/pkgver=${VERSION}/" repo/ksutils-teamspeak-management-tools/PKGBUILD
          sed -i "s/^pkgrel=.*/pkgrel=1/" repo/ksutils-teamspeak-management-tools/PKGBUILD

      - name: Commit and push
        if: steps.check.outputs.skip == 'false'
        env:
          VERSION: ${{ steps.version.outputs.version }}
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add repo/ksutils-teamspeak-management-tools/PKGBUILD
          git commit -m "feat(pkg): Update ksutils-teamspeak-management-tools to ${VERSION}"
          git push || (git pull --rebase && git push)