forked from AOSSIE-Org/PictoPy
-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (89 loc) · 3.43 KB
/
Copy pathaur-publish.yml
File metadata and controls
99 lines (89 loc) · 3.43 KB
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
name: Publish to AUR - pictopy-bin
on:
# schedule:
# - cron: '0 0 * * *'
workflow_dispatch:
permissions:
contents: write
jobs:
update_version:
runs-on: ubuntu-latest
outputs:
need_update: ${{ steps.check_version.outputs.need_update }}
latest_version: ${{ steps.check_version.outputs.latest_version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Git
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Check if update is needed
id: check_version
run: |
cd publishing
LATEST_VERSION=$(curl -fsSL https://api.github.com/repos/AOSSIE-Org/PictoPy/releases/latest \
| grep -oP '(?<="tag_name": ")[^"]+')
echo "Latest version: $LATEST_VERSION"
CURRENT_VERSION=$(grep -oP '(?<=pkgver=)[0-9.]+' PKGBUILD)
echo "Current version: $CURRENT_VERSION"
if [ "$LATEST_VERSION" != "$CURRENT_VERSION" ]; then
echo "need_update=true" >> "$GITHUB_OUTPUT"
else
echo "need_update=false" >> "$GITHUB_OUTPUT"
fi
echo "latest_version=$LATEST_VERSION" >> "$GITHUB_OUTPUT"
- name: Compute sha256 of new deb
if: steps.check_version.outputs.need_update == 'true'
id: sha
run: |
VERSION="${{ steps.check_version.outputs.latest_version }}"
DEB_URL="https://github.com/AOSSIE-Org/PictoPy/releases/download/${VERSION}/PictoPy_${VERSION}_amd64.deb"
SHA=$(curl -fsSL "$DEB_URL" | sha256sum | cut -d' ' -f1)
if ! echo "$SHA" | grep -qP '^[a-f0-9]{64}$'; then
echo "ERROR: Invalid SHA256 — deb download may have failed"
exit 1
fi
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
- name: Update PKGBUILD
if: steps.check_version.outputs.need_update == 'true'
run: |
VERSION="${{ steps.check_version.outputs.latest_version }}"
SHA="${{ steps.sha.outputs.sha }}"
cd publishing
sed -i "s/^pkgver=.*/pkgver=$VERSION/" PKGBUILD
sed -i "s/^pkgrel=.*/pkgrel=1/" PKGBUILD
sed -i "s/sha256sums=.*/sha256sums=('$SHA')/" PKGBUILD
git add PKGBUILD
git commit -m "upgpkg: pictopy-bin $VERSION"
git push
- name: Upload artifacts for publish job
if: steps.check_version.outputs.need_update == 'true'
uses: actions/upload-artifact@v4
with:
name: PKGBUILD
path: |
publishing/PKGBUILD
publishing/pictopy-bin.install
publish_aur:
runs-on: ubuntu-latest
needs: update_version
if: needs.update_version.outputs.need_update == 'true'
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: PKGBUILD
path: publishing/
- name: Publish to AUR
uses: KSXGitHub/github-actions-deploy-aur@v4.1.3
with:
pkgname: pictopy-bin
pkgbuild: ./publishing/PKGBUILD
commit_username: ${{ secrets.AUR_USERNAME }}
commit_email: ${{ secrets.AUR_EMAIL }}
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: ${{ needs.update_version.outputs.latest_version }}
ssh_keyscan_types: rsa,ecdsa,ed25519
updpkgsums: false
allow_empty_commits: false