-
Notifications
You must be signed in to change notification settings - Fork 2
95 lines (86 loc) · 3.67 KB
/
Copy pathauto-update-convox.yml
File metadata and controls
95 lines (86 loc) · 3.67 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
95
name: Auto-update Convox CLI
on:
schedule:
- cron: "0 8 * * *" # Daily at 8 AM UTC
workflow_dispatch: # Allow manual trigger
permissions:
contents: write
jobs:
check-and-update:
runs-on: ubuntu-latest
outputs:
update: ${{ steps.check.outputs.update }}
version: ${{ steps.version.outputs.new_version }}
convox_version: ${{ steps.convox.outputs.version }}
convox_sha256: ${{ steps.checksum.outputs.sha256 }}
steps:
- name: Get latest Convox release
id: convox
run: |
LATEST=$(curl -sf https://api.github.com/repos/convox/convox/releases/latest | jq -r '.tag_name')
if [ -z "$LATEST" ] || [ "$LATEST" = "null" ]; then
echo "::error::Failed to fetch latest Convox release"
exit 1
fi
echo "version=$LATEST" >> "$GITHUB_OUTPUT"
echo "Latest Convox release: $LATEST"
- name: Compute checksum for new release
id: checksum
run: |
LATEST="${{ steps.convox.outputs.version }}"
SHA=$(curl -fsSL --retry 3 "https://github.com/convox/convox/releases/download/${LATEST}/convox-linux" | sha256sum | awk '{print $1}')
if ! echo "$SHA" | grep -qE '^[0-9a-f]{64}$'; then
echo "::error::Failed to compute checksum for convox ${LATEST}"
exit 1
fi
echo "sha256=$SHA" >> "$GITHUB_OUTPUT"
- name: Checkout
uses: actions/checkout@v4
- name: Check if update needed
id: check
run: |
CURRENT=$(cat CONVOX_VERSION 2>/dev/null | tr -d '[:space:]' || echo "none")
LATEST="${{ steps.convox.outputs.version }}"
echo "Current tracked version: $CURRENT"
echo "Latest Convox version: $LATEST"
if [ "$CURRENT" = "$LATEST" ]; then
echo "Already up to date."
echo "update=false" >> "$GITHUB_OUTPUT"
else
echo "New version available!"
echo "update=true" >> "$GITHUB_OUTPUT"
fi
- name: Bump patch version
if: steps.check.outputs.update == 'true'
id: version
run: |
CURRENT_VERSION=$(cat VERSION | tr -d '[:space:]')
VERSION_NUM="${CURRENT_VERSION#v}"
BASE_VERSION=$(echo "$VERSION_NUM" | grep -oE '^[0-9]+\.[0-9]+\.[0-9]+')
MAJOR=$(echo "$BASE_VERSION" | cut -d. -f1)
MINOR=$(echo "$BASE_VERSION" | cut -d. -f2)
PATCH=$(echo "$BASE_VERSION" | cut -d. -f3)
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="v${MAJOR}.${MINOR}.${NEW_PATCH}"
echo "Bumping $CURRENT_VERSION -> $NEW_VERSION"
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
release:
needs: check-and-update
if: needs.check-and-update.outputs.update == 'true'
uses: ./.github/workflows/build-and-release.yml
with:
version: ${{ needs.check-and-update.outputs.version }}
commit-message: "Auto-update Convox CLI to ${{ needs.check-and-update.outputs.convox_version }} (${{ needs.check-and-update.outputs.version }})"
convox-version: ${{ needs.check-and-update.outputs.convox_version }}
convox-sha256: ${{ needs.check-and-update.outputs.convox_sha256 }}
summary:
needs: [check-and-update, release]
if: needs.check-and-update.outputs.update == 'true'
runs-on: ubuntu-latest
steps:
- name: Summary
run: |
echo "### Convox CLI Auto-Update" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "- **Convox version:** ${{ needs.check-and-update.outputs.convox_version }}" >> "$GITHUB_STEP_SUMMARY"
echo "- **Action version:** ${{ needs.check-and-update.outputs.version }}" >> "$GITHUB_STEP_SUMMARY"