Skip to content

Commit f516820

Browse files
test github action
1 parent 49ae7c4 commit f516820

File tree

8 files changed

+298
-1
lines changed

8 files changed

+298
-1
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM docker.io/library/archlinux:base-devel
2+
3+
RUN pacman -Syu --needed --noconfirm pacman-contrib namcap git sudo npm && \
4+
useradd -m builder && \
5+
echo 'builder ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
6+
7+
WORKDIR /home/builder
8+
USER builder
9+
10+
COPY entrypoint.sh /entrypoint.sh
11+
12+
ENTRYPOINT [ "/entrypoint.sh" ]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: 'Update AUR Package Checksums'
2+
description: 'Update PKGBUILD checksums and generate .SRCINFO using real Arch Linux environment'
3+
author: 'Your Name'
4+
5+
runs:
6+
using: docker
7+
image: 'Dockerfile'
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
echo "::group::Updating system"
5+
sudo pacman -Syu --noconfirm
6+
echo "::endgroup::"
7+
8+
# Set paths
9+
WORKPATH=$GITHUB_WORKSPACE
10+
HOME=/home/builder
11+
12+
echo "::group::Copying files from $WORKPATH to $HOME/work"
13+
cd $HOME
14+
mkdir -p work
15+
cd work
16+
cp -fv "$WORKPATH"/PKGBUILD .
17+
if [ -f "$WORKPATH"/.SRCINFO ]; then
18+
cp -fv "$WORKPATH"/.SRCINFO .
19+
fi
20+
echo "::endgroup::"
21+
22+
echo "::group::Getting version info"
23+
source PKGBUILD
24+
npmver=$(echo "$_npmver" | cut -d' ' -f1)
25+
pkgver_new=$(echo "$npmver" | sed 's/-/_/g')
26+
echo "Current npmver: $npmver"
27+
echo "Current pkgver: $pkgver"
28+
echo "New pkgver should be: $pkgver_new"
29+
30+
# Test if URL exists
31+
test_url="https://registry.npmjs.org/@sourcegraph/amp/-/amp-$npmver.tgz"
32+
echo "Testing URL: $test_url"
33+
if curl -I "$test_url" 2>/dev/null | grep -q "200 OK"; then
34+
echo "✅ URL is accessible"
35+
else
36+
echo "❌ URL test failed - this might cause issues"
37+
fi
38+
echo "::endgroup::"
39+
40+
echo "::group::Updating pkgver and pkgrel"
41+
sed -i "s/^pkgver=.*/pkgver=$pkgver_new/" PKGBUILD
42+
sed -i "s/^pkgrel=.*/pkgrel=1/" PKGBUILD
43+
git diff PKGBUILD || true
44+
echo "::endgroup::"
45+
46+
echo "::group::Updating checksums"
47+
updpkgsums
48+
git diff PKGBUILD || true
49+
echo "::endgroup::"
50+
51+
echo "::group::Installing dependencies"
52+
source PKGBUILD
53+
if [ ${#depends[@]} -gt 0 ]; then
54+
sudo pacman -S --needed --noconfirm "${depends[@]}" || true
55+
fi
56+
if [ ${#makedepends[@]} -gt 0 ]; then
57+
sudo pacman -S --needed --noconfirm "${makedepends[@]}" || true
58+
fi
59+
echo "::endgroup::"
60+
61+
echo "::group::Testing build"
62+
makepkg --nobuild --nodeps
63+
echo "::endgroup::"
64+
65+
echo "::group::Generating .SRCINFO"
66+
makepkg --printsrcinfo > .SRCINFO
67+
git diff .SRCINFO || true
68+
echo "::endgroup::"
69+
70+
echo "::group::Copying files back"
71+
sudo cp -fv PKGBUILD "$WORKPATH"/PKGBUILD
72+
sudo cp -fv .SRCINFO "$WORKPATH"/.SRCINFO
73+
echo "::endgroup::"

.github/workflows/publish-aur.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Publish to AUR
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- github-action-test
8+
paths:
9+
- 'PKGBUILD'
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Find updated package
21+
run: |
22+
#!/usr/bin/env bash
23+
set -euxo pipefail
24+
25+
echo "pkgbuild=$(git diff --name-only HEAD HEAD~1 "*/.SRCINFO" | head -1 | xargs dirname)" >> $GITHUB_ENV
26+
27+
- name: Deploy to AUR
28+
uses: KSXGitHub/github-actions-deploy-aur@2ac5a4c1d7035885d46b10e3193393be8460b6f1 # v4.1.1
29+
if: ${{ env.pkgbuild != '' && github.ref == 'refs/heads/master' }}
30+
with:
31+
pkgname: sourcegraph-amp
32+
pkgbuild: ./PKGBUILD
33+
commit_username: ${{ secrets.AUR_USERNAME }}
34+
commit_email: ${{ secrets.AUR_EMAIL }}
35+
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
36+
37+
- name: Test Mode (Skip AUR Deploy)
38+
if: ${{ env.pkgbuild != '' && github.ref == 'refs/heads/github-action-test' }}
39+
run: |
40+
echo "🧪 TEST MODE: Would deploy to AUR with:"
41+
echo "Package: sourcegraph-amp"
42+
echo "PKGBUILD: ./PKGBUILD"
43+
echo "Files that would be deployed:"
44+
ls -la PKGBUILD .SRCINFO
45+
echo ""
46+
echo "PKGBUILD content:"
47+
cat PKGBUILD

.github/workflows/test-update.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Test Update (No Deploy)
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [test-*]
7+
8+
jobs:
9+
check-version:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
needs-update: ${{ steps.check.outputs.needs-update }}
13+
new-version: ${{ steps.check.outputs.new-version }}
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Check for new npm version
19+
id: check
20+
run: |
21+
# Get current version from PKGBUILD
22+
current_version=$(grep "^_npmver=" PKGBUILD | cut -d'=' -f2 | cut -d' ' -f1)
23+
echo "Current version: $current_version"
24+
25+
# Get latest version from npm
26+
latest_version=$(npm view @sourcegraph/amp version)
27+
echo "Latest version: $latest_version"
28+
29+
if [ "$current_version" != "$latest_version" ]; then
30+
echo "needs-update=true" >> $GITHUB_OUTPUT
31+
echo "new-version=$latest_version" >> $GITHUB_OUTPUT
32+
echo "Update needed: $current_version -> $latest_version"
33+
else
34+
echo "needs-update=false" >> $GITHUB_OUTPUT
35+
echo "No update needed"
36+
fi
37+
38+
test-update-process:
39+
needs: check-version
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v4
44+
45+
- name: Simulate update (if needed)
46+
if: needs.check-version.outputs.needs-update == 'true'
47+
run: |
48+
new_version="${{ needs.check-version.outputs.new-version }}"
49+
echo "Would update to: $new_version"
50+
51+
# Show what the new PKGBUILD would look like
52+
cp PKGBUILD PKGBUILD.new
53+
sed -i "s/^_npmver=.*/_npmver=$new_version # renovate: datasource=npm depName=@sourcegraph\/amp/" PKGBUILD.new
54+
55+
pkgver=$(echo "$new_version" | sed 's/-/_/g')
56+
sed -i "s/^pkgver=.*/pkgver=$pkgver/" PKGBUILD.new
57+
sed -i "s/^pkgrel=.*/pkgrel=1/" PKGBUILD.new
58+
59+
echo "=== NEW PKGBUILD WOULD BE ==="
60+
cat PKGBUILD.new
61+
62+
- name: Test checksum update
63+
if: needs.check-version.outputs.needs-update == 'true'
64+
run: |
65+
new_version="${{ needs.check-version.outputs.new-version }}"
66+
url="https://registry.npmjs.org/@sourcegraph/amp/-/amp-$new_version.tgz"
67+
68+
echo "Testing download: $url"
69+
if curl -L --fail "$url" -o temp.tgz; then
70+
new_checksum=$(sha1sum temp.tgz | cut -d' ' -f1)
71+
echo "New checksum would be: $new_checksum"
72+
rm temp.tgz
73+
else
74+
echo "ERROR: Could not download new version"
75+
exit 1
76+
fi
77+
78+
- name: Show results
79+
run: |
80+
echo "=== TEST RESULTS ==="
81+
echo "Needs update: ${{ needs.check-version.outputs.needs-update }}"
82+
echo "Current workflow working: ✅"
83+
if [ "${{ needs.check-version.outputs.needs-update }}" = "true" ]; then
84+
echo "Ready for real deployment!"
85+
else
86+
echo "No update needed right now"
87+
fi

.github/workflows/update-aur.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Update Checksums and .SRCINFO
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
branches:
9+
- master
10+
- github-action-test
11+
12+
jobs:
13+
updpkgsums:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
18+
with:
19+
fetch-depth: 0
20+
ref: ${{ github.ref }}
21+
22+
- name: Find updated package
23+
run: |
24+
#!/usr/bin/env bash
25+
set -euxo pipefail
26+
27+
# Detect base branch dynamically
28+
if [[ "${{ github.base_ref }}" == "github-action-test" ]]; then
29+
base_branch="origin/github-action-test"
30+
else
31+
base_branch="origin/master"
32+
fi
33+
34+
echo "Base branch: $base_branch"
35+
echo "Head branch: origin/${GITHUB_HEAD_REF}"
36+
37+
pkgbuild_path=$(git diff --name-only $base_branch origin/${GITHUB_HEAD_REF} "*PKGBUILD" | head -1 | xargs dirname)
38+
echo "Found package path: $pkgbuild_path"
39+
echo "pkgbuild=$pkgbuild_path" >> $GITHUB_ENV
40+
41+
- name: Update checksums and .SRCINFO
42+
if: ${{ env.pkgbuild != '' }}
43+
uses: ./.github/actions/aur-update
44+
45+
- name: Commit changes
46+
if: ${{ env.pkgbuild != '' }}
47+
uses: stefanzweifel/git-auto-commit-action@b863ae1933cb653a53c021fe36dbb774e1fb9403 # v5.2.0
48+
with:
49+
file_pattern: 'PKGBUILD .SRCINFO'

PKGBUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Maintainer: Anirudh Konduru <anirudhmkonduru@gmail.com>
22

33
_npmname=@sourcegraph/amp
4-
_npmver=0.0.1749182771-gb19aef
4+
_npmver=0.0.1749182771-gb19aef # renovate: datasource=npm depName=@sourcegraph/amp
55
_basename=amp
66
pkgname=sourcegraph-amp # All lowercase
77
pkgver=0.0.1749182771_gb19aef

renovate.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"config:recommended",
5+
":rebaseStalePrs",
6+
":semanticCommits",
7+
":semanticCommitScope(deps)",
8+
"helpers:pinGitHubActionDigests"
9+
],
10+
"baseBranches": ["master", "github-action-test"],
11+
"customManagers": [
12+
{
13+
"customType": "regex",
14+
"fileMatch": ["^PKGBUILD$"],
15+
"matchStrings": [
16+
"_npmver=(?<currentValue>.*) # renovate: datasource=(?<datasource>.*) depName=(?<depName>.*)"
17+
],
18+
"extractVersionTemplate": "^v?(?<version>.*)$",
19+
"autoReplaceStringTemplate": "_npmver={{{newValue}}} # renovate: datasource={{{datasource}}} depName={{{depName}}}"
20+
}
21+
]
22+
}

0 commit comments

Comments
 (0)