-
Notifications
You must be signed in to change notification settings - Fork 82
93 lines (75 loc) · 3.69 KB
/
update-version.yml
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
name: Bump Lotus Version
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
push:
branches:
- main
permissions:
contents: write
pull-requests: write
jobs:
bump-version:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Get the latest release
id: get_release
run: |
REPO="filecoin-project/lotus"
RELEASES_TAGS=$(curl -s "https://api.github.com/repos/${REPO}/releases" | jq -r '.[] | select(.prerelease == false) | .tag_name')
get_latest_release() {
local TAG_PREFIX=$1
local RELEASES_TAGS_WITH_PREFIX=$(echo "$RELEASES_TAGS" | grep "${TAG_PREFIX}")
if [ -z "$RELEASES_TAGS_WITH_PREFIX" ]; then
exit 1
fi
local LATEST_RELEASE=$(echo "$RELEASES_TAGS_WITH_PREFIX" | sort -V | tail -n 1)
if [ -z "$LATEST_RELEASE" ]; then
exit 1
fi
echo "${LATEST_RELEASE#$TAG_PREFIX}"
}
latest_lotus=$(get_latest_release "v")
latest_miner=$(get_latest_release "miner/v")
echo "latest_lotus=$latest_lotus" >> $GITHUB_OUTPUT
echo "latest_miner=$latest_miner" >> $GITHUB_OUTPUT
- name: Get current Go version
id: get_go_version
run: |
REPO="filecoin-project/lotus"
LATEST_RELEASE=$(curl -s "https://api.github.com/repos/${REPO}/releases/latest" | jq -r .tag_name)
# Changed from go.mod to GO_VERSION_MIN
GO_MOD_URL="https://raw.githubusercontent.com/${REPO}/${LATEST_RELEASE}/GO_VERSION_MIN"
GO_VERSION=$(curl -s $GO_MOD_URL | awk 'NR==1 {print $1}')
if [ -z "$GO_VERSION" ]; then
echo "Error: Could not find Go version in GO_VERSION_MIN"
exit 1
fi
echo "Found Go version: $GO_VERSION"
echo "current_go_version=$GO_VERSION" >> $GITHUB_OUTPUT
- name: Update version.json
run: |
jq --arg lotus "$LATEST_LOTUS" --arg miner "$LATEST_MINER" --arg go "$CURRENT_GO_VERSION" '.lotus = $lotus | .miner = $miner | .go = $go' data/version.json > data/version.tmp && mv data/version.tmp data/version.json
env:
LATEST_LOTUS: ${{ steps.get_release.outputs.latest_lotus }}
LATEST_MINER: ${{ steps.get_release.outputs.latest_miner }}
CURRENT_GO_VERSION: ${{ steps.get_go_version.outputs.current_go_version }}
- name: Check if changes exist
id: git_diff
run: |
git diff --exit-code || echo "has_changes=true" >> $GITHUB_OUTPUT
- name: Create Pull Request
if: steps.git_diff.outputs.has_changes == 'true'
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: bump-lotus-version
title: "Bump Lotus versions (node=${{ steps.get_release.outputs.latest_lotus }}, miner=${{ steps.get_release.outputs.latest_miner }}, go=${{ steps.get_go_version.outputs.current_go_version }})"
body: "This PR bumps the Lotus versions to node=${{ steps.get_release.outputs.latest_lotus }}, miner=${{ steps.get_release.outputs.latest_miner }}, and updates the Go version to ${{ steps.get_go_version.outputs.current_go_version }}."
commit-message: "Bump Lotus versions to node=${{ steps.get_release.outputs.latest_lotus }}, miner=${{ steps.get_release.outputs.latest_miner }}, go=${{ steps.get_go_version.outputs.current_go_version }}"
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
add-paths: |
data/version.json