-
Notifications
You must be signed in to change notification settings - Fork 13
71 lines (61 loc) · 2.43 KB
/
ui.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
name: Update UI
on:
# Run daily
schedule:
- cron: '0 0 * * *'
# Enable manual trigger
workflow_dispatch:
jobs:
update-ui:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: stable
- name: Check for new hostd tag in SiaFoundation/web
id: check-tag
env:
GH_TOKEN: ${{ github.token }}
run: |
# Fetch tags with pagination
TAGS_JSON=$(gh api --paginate repos/SiaFoundation/web/tags)
# Extract tags that start with "hostd/", sort them in version order, and pick the highest version
LATEST_HOSTD_GO_TAG=$(echo "$TAGS_JSON" | jq -r '.[] | select(.name | startswith("hostd/")).name' | sort -Vr | head -n 1)
LATEST_HOSTD_VERSION=$(echo "$LATEST_HOSTD_GO_TAG" | sed 's/hostd\///')
echo "Latest hostd tag is $LATEST_HOSTD_GO_TAG"
echo "GO_TAG=$LATEST_HOSTD_GO_TAG" >> $GITHUB_ENV
echo "VERSION=$LATEST_HOSTD_VERSION" >> $GITHUB_ENV
- name: Fetch release notes for the release
id: release-notes
env:
GH_TOKEN: ${{ github.token }}
if: env.GO_TAG != 'null'
run: |
RELEASE_TAG_FORMATTED=$(echo "$GO_TAG" | sed 's/\/v/@/')
RELEASES_JSON=$(gh api --paginate repos/SiaFoundation/web/releases)
RELEASE_NOTES=$(echo "$RELEASES_JSON" | jq -r --arg TAG_NAME "$RELEASE_TAG_FORMATTED" '.[] | select(.name == $TAG_NAME).body')
echo "Release notes for $RELEASE_TAG_FORMATTED: $RELEASE_NOTES"
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
echo "$RELEASE_NOTES" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Update go.mod with latest module
if: env.GO_TAG != 'null'
run: |
GO_MODULE_FORMATTED=$(echo "$GO_TAG" | sed 's/\//@/')
echo "Updating go.mod to use $GO_MODULE_FORMATTED"
go clean -modcache
go get go.sia.tech/web/$GO_MODULE_FORMATTED
go mod tidy
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
if: env.GO_TAG != 'null'
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "ui: ${{ env.VERSION }}"
title: "ui: ${{ env.VERSION }}"
body: ${{ env.RELEASE_NOTES }}
branch: "ui/update"
delete-branch: true