-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add workflow for updating duckdb refs #24
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
fetch_latest_ref() { | ||
local REPO=$1 | ||
local REF_TYPE=$2 | ||
|
||
if [ "$REF_TYPE" = "release" ]; then | ||
local TAG=$(gh release -R "$REPO" list --json tagName,isLatest --jq '.[] | select(.isLatest).tagName') | ||
local LATEST_REF=$(gh api repos/"$REPO"/git/ref/tags/"$TAG" --jq '.object.sha') | ||
else | ||
local LATEST_REF=$(gh api repos/"$REPO"/git/refs/heads/main --jq '.object.sha') | ||
fi | ||
|
||
echo "$LATEST_REF" | ||
} | ||
|
||
update_makefile() { | ||
local REF_VAR_NAME="$1" | ||
local LATEST_REF="$2" | ||
|
||
if grep -q "^.*${REF_VAR_NAME} *= *${LATEST_REF}" Makefile; then | ||
return | ||
fi | ||
|
||
if [[ "$(uname)" == "Darwin" ]]; then | ||
sed -i '' "s|^\\(.*${REF_VAR_NAME} *\\)=.*|\\1=${LATEST_REF}|" Makefile | ||
else | ||
sed -i "s|^\\(.*${REF_VAR_NAME} *\\)=.*|\\1=${LATEST_REF}|" Makefile | ||
fi | ||
|
||
echo "\\n-Updated ${REF_VAR_NAME} to ${LATEST_REF}" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: duckdb-ref-update | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 4 * * 6' # Every Saturday at 4 AM US time (America/New_York) | ||
|
||
concurrency: | ||
group: "${{ github.workflow }}-${{ github.run_started_at }}" | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
update-duckdb-refs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Fetch and Update All Refs | ||
id: fetch-update-refs | ||
shell: bash | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
source ./.github/scripts/duckdb-ref-update.sh | ||
COMMIT_DETAILS="" | ||
|
||
repos='[ | ||
{"repository": "duckdb/duckdb", "ref_var": "DUCKDB_REF", "ref_type": "release"}, | ||
{"repository": "duckdb/duckdb-aws", "ref_var": "DUCKDB_AWS_REF", "ref_type": "tip"}, | ||
{"repository": "duckdb/duckdb-httpfs", "ref_var": "DUCKDB_HTTPFS_REF", "ref_type": "tip"}, | ||
{"repository": "substrait-io/duckdb-substrait-extension", "ref_var": "DUCKDB_SUBSTRAIT_REF", "ref_type": "tip"}, | ||
{"repository": "duckdb/duckdb-iceberg", "ref_var": "DUCKDB_ICEBERG_REF", "ref_type": "tip"} | ||
]' | ||
|
||
echo "$repos" | jq -c '.[]' | while read -r repo; do | ||
REPO=$(echo "$repo" | jq -r '.repository') | ||
REF_VAR=$(echo "$repo" | jq -r '.ref_var') | ||
REF_TYPE=$(echo "$repo" | jq -r '.ref_type') | ||
|
||
echo "Processing $REPO with $REF_VAR and $REF_TYPE" | ||
LATEST_REF=$(fetch_latest_ref "$REPO" "$REF_TYPE") | ||
echo "Latest ref: $LATEST_REF" | ||
UPDATE_OUTPUT=$(update_makefile "$REF_VAR" "$LATEST_REF") | ||
if [[ -n "$UPDATE_OUTPUT" ]]; then | ||
COMMIT_DETAILS+=$'\n'"$UPDATE_OUTPUT" | ||
fi | ||
done | ||
|
||
echo "COMMIT_DETAILS=$COMMIT_DETAILS" >> "$GITHUB_ENV" | ||
- name: Commit and Push Updates | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rymurr I couldn't test this step as it doesn't find the branch Or I could test this once it merges to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I checked the diff as well, only part I didn't check is the final commit that gets raised. I put a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is goign to commit to main if run on main, I think rather than commit you want to create a PR |
||
commit_message: | | ||
Update DuckDB references:${{ env.COMMIT_DETAILS }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to skip the update if the duckdb ref hasn't updated. I don't think we want to update the extensions if we aren't updating dudckdb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree that is better approach as it saves cycles but just to confirm, I think we might lose one corner case.
We might miss a chance to pull that commit B. @rymurr Thoughts?