|
| 1 | +name: Sync Boost Release |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # 05:00 UTC = midnight EST (UTC-5); shifts to 01:00 EDT in summer — acceptable |
| 6 | + - cron: '0 5 * * *' |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + sync: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Detect latest Boost production release |
| 21 | + id: detect |
| 22 | + env: |
| 23 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 24 | + run: | |
| 25 | + # GitHub Tags API — most-recently-created tags first. |
| 26 | + # 50 entries is more than enough: Boost ships ~4 tags/year |
| 27 | + # (one beta + one production per release cycle). |
| 28 | + TAGS=$(curl -fsSL \ |
| 29 | + -H "Authorization: Bearer $GH_TOKEN" \ |
| 30 | + -H "Accept: application/vnd.github+json" \ |
| 31 | + "https://api.github.com/repos/boostorg/boost/tags?per_page=50") |
| 32 | +
|
| 33 | + # Keep only clean production tags: boost-X.Y.Z (no .betaN or .rcN suffix) |
| 34 | + LATEST_TAG=$(echo "$TAGS" | jq -r \ |
| 35 | + '[.[] | select(.name | test("^boost-[0-9]+\\.[0-9]+\\.[0-9]+$"))] | .[0].name') |
| 36 | +
|
| 37 | + if [ -z "$LATEST_TAG" ] || [ "$LATEST_TAG" = "null" ]; then |
| 38 | + echo "ERROR: Could not determine latest Boost production tag." >&2 |
| 39 | + exit 1 |
| 40 | + fi |
| 41 | +
|
| 42 | + echo "Latest production tag: $LATEST_TAG" |
| 43 | +
|
| 44 | + # Convert boost-1.90.0 → v1.90 |
| 45 | + # Pattern: boost-<major>.<minor>.<patch> → v<major>.<minor> |
| 46 | + DIR=$(echo "$LATEST_TAG" | sed -E 's/^boost-([0-9]+)\.([0-9]+)\.[0-9]+$/v\1.\2/') |
| 47 | +
|
| 48 | + echo "Mapped directory name: $DIR" |
| 49 | + echo "dir=$DIR" >> "$GITHUB_OUTPUT" |
| 50 | +
|
| 51 | + if [ -d "$DIR" ]; then |
| 52 | + echo "Directory '$DIR' already exists — no action needed." |
| 53 | + echo "is_new=false" >> "$GITHUB_OUTPUT" |
| 54 | + else |
| 55 | + echo "New release detected — will create '$DIR'." |
| 56 | + echo "is_new=true" >> "$GITHUB_OUTPUT" |
| 57 | + fi |
| 58 | +
|
| 59 | + - name: Copy develop/ to versioned directory |
| 60 | + if: steps.detect.outputs.is_new == 'true' |
| 61 | + run: | |
| 62 | + DIR="${{ steps.detect.outputs.dir }}" |
| 63 | + cp -r develop/ "$DIR/" |
| 64 | + echo "Copied develop/ → $DIR/" |
| 65 | +
|
| 66 | + - name: Commit and push |
| 67 | + if: steps.detect.outputs.is_new == 'true' |
| 68 | + run: | |
| 69 | + DIR="${{ steps.detect.outputs.dir }}" |
| 70 | + git config user.name "github-actions[bot]" |
| 71 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 72 | + git add "$DIR/" |
| 73 | + git commit -m "Add $DIR (snapshot from develop)" |
| 74 | + git push |
0 commit comments