-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (106 loc) · 4.89 KB
/
version-update.yaml
File metadata and controls
129 lines (106 loc) · 4.89 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Update NATS Tool Versions
on:
schedule:
# Run daily at 14:00 UTC
- cron: "0 14 * * *"
workflow_dispatch:
# Allow manual triggering
permissions: {}
concurrency:
# Intent: scheduled jobs stomp on each other, but manual runs are mostly independent.
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.triggering_actor }}
cancel-in-progress: true
jobs:
check_versions:
name: Update
runs-on: ubuntu-latest
permissions:
contents: write # we create a branch with updated code, for review
pull-requests: write # we create a PR
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
# Need credentials preserved, to push a branch with changes
persist-credentials: true
- name: Get latest releases
id: get_releases
# We use gh rather than curl, so that our requests can be authenticated and avoid anonymous rate limits
run: |
latest() { gh release --repo "$1" view --json tagName --jq .tagName; }
# Get latest natscli release
RELEASE_NATSCLI="$(latest nats-io/natscli)"
echo >> "$GITHUB_OUTPUT" "release_natscli=$RELEASE_NATSCLI"
# Get latest nsc release
RELEASE_NSC="$(latest nats-io/nsc)"
echo >> "$GITHUB_OUTPUT" "release_nsc=$RELEASE_NSC"
echo "Latest natscli release: $RELEASE_NATSCLI"
echo "Latest nsc release: $RELEASE_NSC"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check current versions
id: check_current
run: |
CURRENT_NATSCLI=$(sed -n 's/^VERSION_stable_nats=//p' < synadia-nats-channels.conf)
CURRENT_NSC=$(sed -n 's/^VERSION_stable_nsc=//p' < synadia-nats-channels.conf)
echo >> "$GITHUB_OUTPUT" "current_natscli=$CURRENT_NATSCLI"
echo >> "$GITHUB_OUTPUT" "current_nsc=$CURRENT_NSC"
echo "Current natscli version: $CURRENT_NATSCLI"
echo "Current nsc version: $CURRENT_NSC"
- name: Update versions if needed
id: update_versions
env:
RELEASE_NATSCLI: ${{ steps.get_releases.outputs.release_natscli }}
RELEASE_NSC: ${{ steps.get_releases.outputs.release_nsc }}
CURRENT_NATSCLI: ${{ steps.check_current.outputs.current_natscli }}
CURRENT_NSC: ${{ steps.check_current.outputs.current_nsc }}
shell: bash
run: |
UPDATED=false
NL=$'\n'
declare -a which_updated=()
commit_message="Update NATS tool versions${NL}${NL}" # paragraph, title vs body
pr_body_table=""
update_one() {
local toolname="$1" config_name="$2" latest="$3" prior="$4"
if [[ "$latest" == "$prior" ]]; then
pr_body_table+="| ${toolname} | \`${prior}\` | (unchanged) |$NL"
return
fi
echo "Updating $toolname from $prior to $latest"
sed -i "s/^VERSION_stable_${config_name}=.*/VERSION_stable_${config_name}=${latest}/" synadia-nats-channels.conf
UPDATED=true
which_updated+=("$toolname")
commit_message+="- ${toolname}: ${prior} → ${latest}$NL"
pr_body_table+="| ${toolname} | \`${prior}\` | \`${latest}\` |$NL"
}
update_one natscli nats "$RELEASE_NATSCLI" "$CURRENT_NATSCLI"
update_one nsc nsc "$RELEASE_NSC" "$CURRENT_NSC"
echo >> "$GITHUB_OUTPUT" "updated=$UPDATED"
echo >> "$GITHUB_OUTPUT" "which_tools=${which_updated[*]}"
echo >> "$GITHUB_OUTPUT" "commit=$(jq -Mcnr --arg cm "$commit_message" --arg table "$pr_body_table" '.message=$cm | .pr_body_table=$table')"
- name: Create Pull Request
if: steps.update_versions.outputs.updated == 'true'
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: |
${{ fromJSON(steps.update_versions.outputs.commit).message }}
title: "Update NATS tool versions: ${{ steps.update_versions.outputs.which_updated }}"
body: |
This PR updates the NATS tool versions in `synadia-nats-channels.conf` to the latest stable releases:
| Tool | Current | New |
|------|---------|-----|
${{ fromJSON(steps.update_versions.outputs.commit).pr_body_table }}
**Release Notes:**
- [natscli releases](https://github.com/nats-io/natscli/releases)
- [nsc releases](https://github.com/nats-io/nsc/releases)
This PR was automatically created by the version update workflow.
branch: auto/update-tool-versions
base: main
delete-branch: true
reviewers: |-2
philpennock
ripienaar
aricart