Initial Automation
This commit is contained in:
4
.bundle/config
Normal file
4
.bundle/config
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
BUNDLE_PATH: "/home/runner/work/release-data/release-data/vendor/bundle"
|
||||||
|
BUNDLE_DEPLOYMENT: "true"
|
||||||
|
BUNDLE_JOBS: "4"
|
||||||
19
.github/workflows/update.yml
vendored
19
.github/workflows/update.yml
vendored
@@ -10,11 +10,18 @@ jobs:
|
|||||||
name: Update data
|
name: Update data
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
- name: Get current week
|
||||||
|
uses: josStorer/get-current-time@v2
|
||||||
|
id: current-time
|
||||||
|
with:
|
||||||
|
# 2022-01 to 2022-52 for eg
|
||||||
|
format: YYYY-ww
|
||||||
- name: Cache Repositories
|
- name: Cache Repositories
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ~/.cache
|
path: ~/.cache
|
||||||
key: cache
|
# The cache is reset on the first build of every week this way.
|
||||||
|
key: "${{ steps.current-time.outputs.formattedTime }}"
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
name: Clone self repository
|
name: Clone self repository
|
||||||
with:
|
with:
|
||||||
@@ -25,10 +32,16 @@ jobs:
|
|||||||
repository: endoflife-date/endoflife.date
|
repository: endoflife-date/endoflife.date
|
||||||
path: website
|
path: website
|
||||||
submodules: false
|
submodules: false
|
||||||
|
- uses: ruby/setup-ruby@v1
|
||||||
|
with:
|
||||||
|
ruby-version: 3.1
|
||||||
|
bundler-cache: true
|
||||||
- name: Update Release data
|
- name: Update Release data
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.cache/{npm,git,oci} releases/{npm,git,oci}
|
mkdir -p ~/.cache/{npm,git,oci} releases/{npm,git,oci} && \
|
||||||
ruby update.rb website ~/.cache releases
|
git config --global init.defaultBranch main
|
||||||
|
git config --global extensions.partialClone true
|
||||||
|
bundle exec ruby update.rb ./website ~/.cache releases
|
||||||
- uses: stefanzweifel/git-auto-commit-action@v4
|
- uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
name: Commit and update new releases
|
name: Commit and update new releases
|
||||||
with:
|
with:
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
website
|
website
|
||||||
|
vendor
|
||||||
|
|||||||
7
Gemfile
Normal file
7
Gemfile
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
source "https://rubygems.org"
|
||||||
|
|
||||||
|
# gem "rails"
|
||||||
|
|
||||||
|
gem "rugged", "~> 1.4"
|
||||||
13
Gemfile.lock
Normal file
13
Gemfile.lock
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
GEM
|
||||||
|
remote: https://rubygems.org/
|
||||||
|
specs:
|
||||||
|
rugged (1.4.2)
|
||||||
|
|
||||||
|
PLATFORMS
|
||||||
|
x86_64-linux
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
rugged (~> 1.4)
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
2.3.5
|
||||||
34
update.rb
34
update.rb
@@ -1,30 +1,52 @@
|
|||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'date'
|
require 'date'
|
||||||
|
require 'json'
|
||||||
|
require 'rugged'
|
||||||
|
|
||||||
WEBSITE_DIR=ARGV[0]
|
WEBSITE_DIR=ARGV[0]
|
||||||
CACHE_DIR=ARGV[1]
|
CACHE_DIR=ARGV[1]
|
||||||
OUTPUT_DIR=ARGV[2]
|
OUTPUT_DIR=ARGV[2]
|
||||||
|
|
||||||
def update_git_releases(product, url)
|
def fetch_git_releases(repo_dir, url)
|
||||||
pwd = Dir.pwd
|
pwd = Dir.pwd
|
||||||
repo_dir = "#{CACHE_DIR}/git/#{product}"
|
|
||||||
puts "Fetching #{url}"
|
puts "Fetching #{url}"
|
||||||
unless Dir.exist? repo_dir
|
unless Dir.exist? repo_dir
|
||||||
`git init --bare #{repo_dir}`
|
`git init --bare #{repo_dir}`
|
||||||
end
|
end
|
||||||
Dir.chdir repo_dir
|
Dir.chdir repo_dir
|
||||||
`git config extensions.partialClone true`
|
`git fetch --quiet --tags --filter=blob:none "#{url}"`
|
||||||
`git fetch --auto-gc --auto-maintenance --progress --prune --prune-tags --quiet --tags --filter=blob:none "#{url}"`
|
|
||||||
Dir.chdir pwd
|
Dir.chdir pwd
|
||||||
end
|
end
|
||||||
|
|
||||||
Dir.glob("#{WEBSITE_DIR}products/*.md").each do |product_file|
|
def update_git_releases(repo_dir, output_file)
|
||||||
|
data = {}
|
||||||
|
repo = Rugged::Repository.bare repo_dir
|
||||||
|
repo.tags.each do |tag|
|
||||||
|
if tag.target.is_a? Rugged::Tag::Annotation
|
||||||
|
data[tag.name] = tag.target.tagger[:time].strftime('%F')
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
data[tag.name] = tag.target.time.strftime('%F')
|
||||||
|
rescue
|
||||||
|
puts "[WARN] No timestamp for #{tag.name}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
File.open(output_file, 'w') do |file|
|
||||||
|
file.write(JSON.pretty_generate data)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Dir.glob("#{WEBSITE_DIR}/products/*.md").each do |product_file|
|
||||||
data = YAML.load_file product_file, permitted_classes: [Date]
|
data = YAML.load_file product_file, permitted_classes: [Date]
|
||||||
data['auto'].each_entry do |ecosystem, url|
|
data['auto'].each_entry do |ecosystem, url|
|
||||||
product = File.basename product_file, ".md"
|
product = File.basename product_file, ".md"
|
||||||
|
cache_dir = "#{CACHE_DIR}/#{ecosystem}/#{product}"
|
||||||
|
output_file = "#{OUTPUT_DIR}/#{ecosystem}/#{product}.json"
|
||||||
case ecosystem
|
case ecosystem
|
||||||
when 'git'
|
when 'git'
|
||||||
update_git_releases(product, url)
|
fetch_git_releases(cache_dir, url)
|
||||||
|
update_git_releases(cache_dir, output_file)
|
||||||
else
|
else
|
||||||
puts "No support for #{ecosystem} yet (#{url})"
|
puts "No support for #{ecosystem} yet (#{url})"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user