Skip to content

Update Package Version #17

Update Package Version

Update Package Version #17

Workflow file for this run

name: Update Package Version
on:
schedule:
- cron: '0 */6 * * *' # Every 6 hours
workflow_dispatch: # Allow manual trigger
pull_request:
paths:
- 'sourcegraph-amp/PKGBUILD'
types: [opened, synchronize]
jobs:
check-and-update:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3
- name: Build and run update in Arch container
run: |
# Build the container with caching
docker buildx build \
--load \
--cache-from type=gha \
--cache-to type=gha,mode=max \
-t arch-builder \
-f .github/Dockerfile \
.github
# Run the container with workspace mounted
docker run --rm \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
arch-builder \
bash -c "
chown -R builder:builder /workspace &&
su - builder -c 'cd /workspace && chmod +x update-package.sh && ./update-package.sh --ci'
"
- name: Fix file permissions
run: |
# Restore ownership to the GitHub Actions user
sudo chown -R $(whoami):$(whoami) ${{ github.workspace }}
- name: Show changes
run: |
echo "=== Git status ==="
git status
echo "=== PKGBUILD changes ==="
git diff sourcegraph-amp/PKGBUILD || echo "No PKGBUILD changes"
echo "=== .SRCINFO changes ==="
git diff sourcegraph-amp/.SRCINFO || echo "No .SRCINFO changes"
- name: Check for new commits
id: update
run: |
# Check if there are any new commits (indicating an update was made)
if [ -n "$(git log --oneline HEAD ^origin/${{ github.ref_name }} 2>/dev/null)" ]; then
# New commit exists, get version from latest commit
updated_ver=$(awk -F'=' '/^_npmver=/ {print $2}' sourcegraph-amp/PKGBUILD | cut -d' ' -f1)
echo "updated_version=$updated_ver" >> $GITHUB_OUTPUT
echo "needs_update=true" >> $GITHUB_OUTPUT
echo "✅ Update committed for version $updated_ver"
else
# No new commits, no update needed
echo "needs_update=false" >> $GITHUB_OUTPUT
echo "ℹ️ No update needed"
fi
# Handle updates to existing PRs (renovate, manual PRs)
- name: Push updates to existing PR
if: github.event_name == 'pull_request' && steps.update.outputs.needs_update == 'true'
run: git push
# Handle scheduled/manual runs - create new PR and auto-merge
- name: Create and auto-merge new PR
if: github.event_name != 'pull_request' && steps.update.outputs.needs_update == 'true'
run: |
# Create PR
PR_URL=$(gh pr create \
--title "Update @sourcegraph/amp to ${{ steps.update.outputs.updated_version }}" \
--body "🤖 **Automated package update**
Updates \`@sourcegraph/amp\` to \`${{ steps.update.outputs.updated_version }}\`
**Changes:**
- Updated \`_npmver\` to \`${{ steps.update.outputs.updated_version }}\`
- Reset \`pkgrel\` to \`1\`
- Updated checksums
- Regenerated \`.SRCINFO\`
Auto-generated by GitHub Actions 🚀" \
--head "update/amp-${{ steps.update.outputs.updated_version }}")
# Extract PR number and auto-merge
PR_NUMBER=$(echo "$PR_URL" | grep -o '[0-9]\+$')
gh pr merge $PR_NUMBER --rebase --auto
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}