Skip to content

Commit

Permalink
Foo
Browse files Browse the repository at this point in the history
  • Loading branch information
Earlopain committed Nov 14, 2024
1 parent 2571d61 commit 6592f1c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
23 changes: 19 additions & 4 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,29 @@ jobs:
variants: ${{ steps.fetch-variants.outputs.variants }}
json: ${{ steps.fetch-json.outputs.json }}
steps:
- name: Download source code
shell: bash
run: |
commit=$(curl https://api.github.com/repos/ruby/ruby/commits/master | jq -r '.sha')
curl -Lo snapshot-master.tar.gz https://github.com/ruby/ruby/archive/$commit.tar.gz
mkdir snapshot-master && tar -xzf snapshot-master.tar.gz -C snapshot-master --strip-components=1
tar c snapshot-master/ | xz -z - > snapshot-master-${commit:0:10}.tar.xz
- uses: actions/upload-artifact@v4
id: snapshot-upload-step
with:
name: snapshot-master
path: snapshot-master-*.tar.xz
retention-days: 1
- uses: actions/checkout@v4
- id: fetch-variants
run: echo "variants=$(./variants.rb)" >> "$GITHUB_OUTPUT"
- id: fetch-json
run: echo "json=$(./nightly-versions.rb)" >> "$GITHUB_OUTPUT"
shell: bash
run: |
hash=$(find . -name snapshot-master-* -exec sha256sum {} \; | cut -d ' ' -f 1)
echo "json=$(./nightly-versions.rb ${{ steps.snapshot-upload-step.outputs.artifact-url }} $hash)" >> "$GITHUB_OUTPUT"
- id: fetch-date
run: echo "date=$(jq -r .master.date versions.json)" >> $GITHUB_OUTPUT
run: echo "date=$(date +%F)" >> $GITHUB_OUTPUT
- run: ./apply-templates.sh

- id: fetch-matrix
Expand Down Expand Up @@ -172,8 +188,7 @@ jobs:
run: echo "latest_release=$(gh release list --limit 1 --json name --jq '.[].name')" >> $GITHUB_OUTPUT

- name: Create release
# https://github.com/ruby/actions/actions/workflows/snapshot-master.yml
if: (github.event_name == 'schedule' || inputs.push == true) && steps.latest-release.outputs.latest_release != needs.set-up-matrix.outputs.date
if: github.event_name == 'schedule' || inputs.push == true
env:
GH_TOKEN: ${{ github.token }}
run: gh release create ${{ needs.set-up-matrix.outputs.date }} --title="${{ needs.set-up-matrix.outputs.date }}" --notes-file=notes.txt
1 change: 1 addition & 0 deletions images.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
platforms = manifest_inspect["manifests"].filter_map do |manifest|
platform = manifest["platform"]
next unless platform["os"] == "linux"
next unless platform['architecture'] == "linux/amd64"

optional_variant = "/#{platform['variant']}" if platform['variant']
"#{platform['os']}/#{platform['architecture']}#{optional_variant}"
Expand Down
17 changes: 5 additions & 12 deletions nightly-versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,12 @@
latest_release = current_json.compact.keys.max_by(&:to_f)
donor = current_json[latest_release]

uri = URI("https://cache.ruby-lang.org/pub/ruby/snapshot/snapshot-master.json")
res = Net::HTTP.get_response(uri)
raise StandardError, "Got status code #{res.code}: #{res.body}" unless res.code == "200"

master = JSON.parse(res.body).first
master["url"] = master["filename"].transform_values { |file| "https://cache.ruby-lang.org/pub/ruby/snapshot/#{file}" }
master.delete("filename")
master.merge!({
master = donor.slice("variants", "rust", "rustup")
master.merge!(
"url" => { "xz" => ARGV[0] },
"sha256" => { "xz" => ARGV[1] },
"version" => "master",
"variants" => donor["variants"],
"rust" => donor["rust"],
"rustup" => donor["rustup"],
})
)
result = { "master" => master }.to_json
# For step output
puts result
Expand Down

0 comments on commit 6592f1c

Please sign in to comment.