-
Notifications
You must be signed in to change notification settings - Fork 4
140 lines (116 loc) · 5.4 KB
/
Copy pathupdate.yml
File metadata and controls
140 lines (116 loc) · 5.4 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
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
name: Update Google Antigravity PKGBUILD
on:
workflow_dispatch:
schedule:
- cron: "0 */4 * * *" # Run every 4 hours
permissions:
contents: write
pull-requests: write
jobs:
check-version:
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.check_version.outputs.changed }}
version: ${{ steps.get_version.outputs.version }}
sha256sum: ${{ steps.get_version.outputs.sha256sum }}
deb_url: ${{ steps.get_version.outputs.deb_url }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y curl gnupg apt-transport-https coreutils
- name: Get latest version
id: get_version
run: |
chmod +x ./scripts/check-antigravity-version.sh
# Run the check script (it needs sudo for apt configuration if running on a fresh runner, but the script uses tee/etc so it might need sudo)
# However, check-antigravity-version.sh writes to /etc/apt/sources.list.d/, so it needs sudo.
# But it outputs to stdout.
OUTPUT=$(sudo ./scripts/check-antigravity-version.sh)
# The script outputs: VERSION SHA256SUM URL
VERSION=$(echo "$OUTPUT" | cut -d' ' -f1)
SHA256SUM=$(echo "$OUTPUT" | cut -d' ' -f2)
# URL might be the 3rd argument, or we can parse it differently if spaces are involved, but usually URL has no spaces.
DEB_URL=$(echo "$OUTPUT" | cut -d' ' -f3)
echo "Detected version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "sha256sum=$SHA256SUM" >> $GITHUB_OUTPUT
echo "deb_url=$DEB_URL" >> $GITHUB_OUTPUT
- name: Check if version changed
id: check_version
run: |
CURRENT_VERSION=$(grep -oP 'pkgver=\K[^"]+' package/PKGBUILD || true)
# If extraction fails (e.g. assumes quotes or not), try fallback
if [ -z "$CURRENT_VERSION" ]; then
CURRENT_VERSION=$(grep '^pkgver=' package/PKGBUILD | cut -d'=' -f2)
fi
NEW_VERSION="${{ steps.get_version.outputs.version }}"
echo "Current version: $CURRENT_VERSION"
echo "New version: $NEW_VERSION"
if [ "$CURRENT_VERSION" != "$NEW_VERSION" ] && [ -n "$NEW_VERSION" ]; then
echo "Version changed!"
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "Version unchanged or failed to detect."
echo "changed=false" >> $GITHUB_OUTPUT
fi
update-package:
needs: check-version
if: needs.check-version.outputs.changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Update PKGBUILD and README
run: |
VERSION="${{ needs.check-version.outputs.version }}"
SHA256SUM="${{ needs.check-version.outputs.sha256sum }}"
DEB_URL="${{ needs.check-version.outputs.deb_url }}"
PKGBUILD_PATH="package/PKGBUILD"
README_PATH="README.md"
# --- Update PKGBUILD ---
# Update pkgver
sed -i "s/^pkgver=.*/pkgver=$VERSION/" "$PKGBUILD_PATH"
# Update pkgrel to 1
sed -i "s/^pkgrel=.*/pkgrel=1/" "$PKGBUILD_PATH"
# Update source URL (escape slashes in URL for sed)
# Using different delimiter |
sed -i "s|source=(\"[^\"]*\"|source=(\"$DEB_URL\"|" "$PKGBUILD_PATH"
# Update checksum
# Replaces the first hash found in sha256sums array
sed -i "/^sha256sums=('/s/'[^']*'/'$SHA256SUM'/" "$PKGBUILD_PATH"
cat "$PKGBUILD_PATH"
# --- Update README.md ---
# Update the text "Latest Version Available: `X.Y.Z`"
sed -i "s/\*\*Latest Version Available:\*\* \`.*\`/**Latest Version Available:** \`$VERSION\`/" "$README_PATH"
# Update the badge "version-X.Y.Z-blue"
sed -i "s/badge\/version-.*-blue/badge\/version-$VERSION-blue/" "$README_PATH"
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore: update google-antigravity to ${{ needs.check-version.outputs.version }}"
title: "Update google-antigravity to ${{ needs.check-version.outputs.version }}"
body: |
This PR updates the google-antigravity package to version ${{ needs.check-version.outputs.version }}.
- Updated PKGBUILD version, checksum, and URL.
- Updated README.md with the new version number and badge.
This is an automated PR created by the version check workflow.
branch: "update-antigravity-${{ needs.check-version.outputs.version }}"
base: "main"
labels: "automated pr"
delete-branch: true
- name: Merge Pull Request
if: ${{ steps.cpr.outputs.pull-request-operation == 'created' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.cpr.outputs.pull-request-number }}
run: |
echo "Attempting to merge PR #${PR_NUMBER}"
gh pr merge "$PR_NUMBER" --merge --delete-branch --repo "${{ github.repository }}"
echo "PR #${PR_NUMBER} merged."