forked from longhorn/longhorn
-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (64 loc) · 2.72 KB
/
mark-stable-version.yaml
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
name: Update Releases
on:
workflow_dispatch:
inputs:
stable_version:
description: 'Version to mark as stable (e.g., 1.7.2)'
required: false
inactive_release:
description: 'Version to mark as inactive (e.g., 1.5)'
required: false
jobs:
update-releases:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Packages
run: sudo apt-get update && sudo apt-get install -y jq
- name: Get Releases
id: get_releases
run: |
curl -sSL https://api.github.com/repos/longhorn/longhorn/releases | jq '.[]' > releases.json
- name: Mark Stable Version
if: github.event.inputs.stable_version != ''
run: |
stable_version="${{ github.event.inputs.stable_version }}"
echo "Input stable version: $stable_version"
# Check if the FULL version exists in README.md
if grep -q "| ${stable_version} |" README.md; then #Match full version
echo "Found full version in README.md: ${stable_version}"
# Use sed to add "(Stable)" to the correct cell in the table
if sed -i "s/| ${stable_version} |/| ${stable_version} (Stable) |/" README.md; then
echo "Successfully marked ${stable_version} as stable."
grep "| ${stable_version} (Stable) |" README.md # Verify the change
else
echo "Failed to mark ${stable_version} as stable! Check the sed command."
exit 1
fi
else
echo "Full version ${stable_version} not found in README.md, cannot mark as stable."
exit 1
fi
- name: Mark Inactive Release
if: github.event.inputs.inactive_release != ''
run: |
inactive_release="${{ github.event.inputs.inactive_release }}"
echo "Input inactive version: $inactive_release"
if grep -q "| ${inactive_release} |" README.md; then
echo "Found version number in README.md: ${inactive_release}"
if sed -i "s/| ${inactive_release} |.*| ✅ |/| ${inactive_release} |.*| |/" README.md; then
echo "Successfully marked ${inactive_release} as inactive."
grep "| ${inactive_release} |.*| |" README.md
else
echo "Failed to mark ${inactive_release} as inactive! Check the sed command."
exit 1
fi
else
echo "Version number ${inactive_release} not found in README.md, cannot mark as inactive."
exit 1
fi
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Update Releases information"
branch: ${{ github.ref }}