-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automate update version list periodically
- Loading branch information
Showing
3 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require "http/client" | ||
require "json" | ||
require "option_parser" | ||
|
||
def fetchVersionList | ||
response = HTTP::Client.get "https://github.com/version-fox/vfox-clang/releases/manifest" | ||
versionJson = response.body.match!(/<code>([\s\S]+)<\/code>/)[1] | ||
versionList = Hash(String, Array(String)).from_json versionJson | ||
end | ||
|
||
output = "manifest.md" | ||
|
||
OptionParser.parse do |parser| | ||
parser.banner = "Usage: #{Path[Process.executable_path.not_nil!].stem} [options]" | ||
parser.on("-o PATH", "--output PATH", "Specify the output path") { |path| output = path } | ||
parser.on("-h", "--help", "Show this help") do | ||
puts parser | ||
exit | ||
end | ||
parser.invalid_option do |flag| | ||
STDERR.puts "ERROR: #{flag} is not a valid option." | ||
STDERR.puts parser | ||
exit(1) | ||
end | ||
end | ||
|
||
vlist = fetchVersionList | ||
resp = HTTP::Client.get "https://anaconda.org/conda-forge/clang/labels" | ||
latestClangVersion = resp.body.match!(/\d\d\.\d\.\d/)[0] | ||
|
||
if vlist["conda-forge"][0] != latestClangVersion | ||
vlist["conda-forge"].unshift(latestClangVersion) | ||
puts "Clang has an updated version: #{latestClangVersion}" | ||
File.open(output, "a") do |file| | ||
file.puts "```" | ||
file.puts vlist.to_pretty_json(indent = " ") | ||
file.puts "```" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Check Updates Periodically | ||
|
||
on: | ||
schedule: | ||
- cron: "0 16 * * 1,4" | ||
push: | ||
branches: ["main"] | ||
|
||
jobs: | ||
update-version-list: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Download source | ||
uses: actions/checkout@v4 | ||
|
||
- name: Check updates | ||
id: check_updates | ||
run: | | ||
chmod +x ./.github/UpdateVersionList | ||
./.github/UpdateVersionList -o manifest.md | ||
if [ -s manifest.md ]; then | ||
HAS_UPDATES=true | ||
echo "Updates found" | ||
else | ||
HAS_UPDATES=false | ||
echo "Already up to date" | ||
fi | ||
echo "HAS_UPDATES=$HAS_UPDATES" >> $GITHUB_OUTPUT | ||
- name: Update manifest body | ||
if: ${{ steps.check_updates.outputs.HAS_UPDATES == 'true' }} | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
name: "manifest" | ||
tag: "manifest" | ||
allowUpdates: true | ||
bodyFile: "manifest.md" | ||
omitNameDuringUpdate: true | ||
omitPrereleaseDuringUpdate: true |