-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (84 loc) · 3.46 KB
/
bun-version-check.yml
File metadata and controls
94 lines (84 loc) · 3.46 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
name: bun-version-check
on:
schedule:
- cron: "0 6 * * *" # Daily at 06:00 UTC
workflow_dispatch:
inputs:
version:
description: "Bun version to build (e.g., 1.3.13). Leave empty to auto-detect latest."
required: false
type: string
jobs:
check-version:
name: Check for new Bun release
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
new_version: ${{ steps.resolve.outputs.new_version }}
should_build: ${{ steps.resolve.outputs.should_build }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Resolve version
id: resolve
env:
GH_TOKEN: ${{ github.token }}
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ inputs.version }}" ]; then
VERSION="${{ inputs.version }}"
echo "Manual dispatch with version: $VERSION"
# Validate semver format: positive_integer.non_negative_integer.non_negative_integer
if ! echo "$VERSION" | grep -qE '^[1-9][0-9]*\.[0-9]+\.[0-9]+$'; then
echo "::error::Invalid version format: $VERSION. Expected semver (e.g., 1.3.13). First segment must be a positive integer."
exit 1
fi
echo "new_version=$VERSION" >> "$GITHUB_OUTPUT"
echo "should_build=true" >> "$GITHUB_OUTPUT"
else
echo "Scheduled run: fetching latest stable Bun release..."
# Fetch latest stable release (non-prerelease, non-draft) from oven-sh/bun
LATEST_RELEASE=$(gh api repos/oven-sh/bun/releases \
--jq '[.[] | select(.prerelease == false and .draft == false and (.tag_name | test("canary") | not))][0].tag_name')
if [ -z "$LATEST_RELEASE" ]; then
echo "::error::Failed to fetch latest Bun release from GitHub API"
exit 1
fi
# Strip "bun-v" prefix to get version number
LATEST_VERSION="${LATEST_RELEASE#bun-v}"
echo "Latest stable Bun release: $LATEST_VERSION"
# Read current version from .bun-version file (if it exists)
CURRENT_VERSION=""
if [ -f .bun-version ]; then
CURRENT_VERSION=$(cat .bun-version)
echo "Current version in repo: $CURRENT_VERSION"
else
echo "No .bun-version file found, treating as new"
fi
if [ "$LATEST_VERSION" = "$CURRENT_VERSION" ]; then
echo "Already up to date (v$CURRENT_VERSION). No build needed."
echo "should_build=false" >> "$GITHUB_OUTPUT"
else
echo "New version detected: $LATEST_VERSION (current: ${CURRENT_VERSION:-none})"
echo "new_version=$LATEST_VERSION" >> "$GITHUB_OUTPUT"
echo "should_build=true" >> "$GITHUB_OUTPUT"
fi
fi
trigger-build:
name: Trigger build-layer workflow
needs: check-version
if: needs.check-version.outputs.should_build == 'true'
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
steps:
- name: Trigger build-layer workflow
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION="${{ needs.check-version.outputs.new_version }}"
echo "Triggering build-layer workflow with version: $VERSION"
gh workflow run build-layer.yml \
--repo "${{ github.repository }}" \
-f version="$VERSION"