Skip to content

Commit

Permalink
Foo
Browse files Browse the repository at this point in the history
  • Loading branch information
Earlopain committed Nov 15, 2024
1 parent 2571d61 commit 8d5ee2a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 143 deletions.
145 changes: 10 additions & 135 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,141 +39,16 @@ jobs:
- id: fetch-matrix
run: echo "images=$(./images.rb)" >> "$GITHUB_OUTPUT"

build:
needs: set-up-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image: ${{ fromJson(needs.set-up-matrix.outputs.images) }}
name: ${{ matrix.image.variant }} - ${{ matrix.image.platform }}
steps:
- uses: actions/checkout@v4
- run: echo '${{ needs.set-up-matrix.outputs.json }}' > versions.json
- run: ./apply-templates.sh

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
${{ matrix.image.variant }}-nightly-${{ needs.set-up-matrix.outputs.date }}
${{ matrix.image.variant }}-nightly
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}

- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: ./master/${{ matrix.image.variant }}
platforms: ${{ matrix.image.platform }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
# linux/amd64 => linux-amd64
- run: |
platform=${{ matrix.image.platform }}
echo "platform_safe=${platform//\//-}" >> $GITHUB_ENV
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.image.variant }}-${{ env.platform_safe }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
needs:
- build
- set-up-matrix
if: success() || failure()

strategy:
fail-fast: false
matrix:
variant: ${{ fromJson(needs.set-up-matrix.outputs.variants) }}
name: Merge - ${{ matrix.variant }}

steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-${{ matrix.variant }}-*
merge-multiple: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
- name: Download source
run: curl -O https://cache.ruby-lang.org/pub/ruby/snapshot/snapshot-master.tar.xz
- uses: actions/upload-artifact@v4
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
${{ matrix.variant }}-nightly-${{ needs.set-up-matrix.outputs.date }}
${{ matrix.variant }}-nightly
name: snapshot-master
path: snapshot-master.tar.xz

- name: Login to Github Container Registry
uses: docker/login-action@v3
- uses: actions/download-artifact@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}

- name: Create manifest list and push
if: github.event_name == 'schedule' || inputs.push == true
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
release:
runs-on: ubuntu-latest
needs:
- set-up-matrix
- build
- merge
if: success() || failure()

steps:
- uses: actions/checkout@v4
- name: Create release notes
run: |
cat <<EOT >> notes.txt
${{ needs.build.result != 'success' && 'There were one or more build failures' || '' }}
See more at https://github.com/docker-ruby-nightly/ruby/pkgs/container/ruby/versions?filters[version_type]=tagged
EOT
- id: latest-release
env:
GH_TOKEN: ${{ github.token }}
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
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
name: my-artifact
path: /snapshot-master
- name: Display structure of downloaded files
run: ls -R //snapshot-master
15 changes: 7 additions & 8 deletions nightly-versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
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!({
upstream = JSON.parse(res.body).first
master = donor.slice("variants", "rust", "rustup")
master.merge!(
"version" => "master",
"variants" => donor["variants"],
"rust" => donor["rust"],
"rustup" => donor["rustup"],
})
"date" => upstream["date"],
"url" => { "xz" => "file:///snapshot-master/snapshot-master.tar.xz" }
"sha256" => { "xz" => upstream["sha256"]["xz"] }
)
result = { "master" => master }.to_json
# For step output
puts result
Expand Down

0 comments on commit 8d5ee2a

Please sign in to comment.