Skip to content

Commit

Permalink
Github Actions Resource Workflow (#4)
Browse files Browse the repository at this point in the history
Publishes Docker images to GHCR and binary tarballs to the pages
instance of this repo providing resources that Spack requires for
bootstrapping/basic functionality.
This currently includes:
| Package | Reason |
|-------------
|----------------------------------------------------------------------------
|
| mingw64-w64 | cross compiler Linux->Windows binaries, used for
compiling other resources |
| GnuPG | Required for signing binaries/buildcache entries |
| file | Required for file introspection, relocation, buildcaches |

Each resources is built via a docker image and uploaded to the GHCR
under the namespace `ghcr.io/spack/windows-resources/<pkg-name>`. Images
are tagged by the revision hash of the updating commit, with the most
recent receiving the `latest` tag.

Those resources are additionally extracted from the docker images, and
published to the pages instance for this repository, where they are
downloadable via in-browser links, or basic web requests.
Only the most recently updated resources are available on the pages
instance to minimize the space consumed by the resources.
  • Loading branch information
johnwparent authored May 28, 2024
1 parent 785c1e9 commit 635f5a3
Show file tree
Hide file tree
Showing 11 changed files with 487 additions and 63 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/build-file.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on:
workflow_call:

env:
REGISTRY: ghcr.io
IMAGE_NAME: file4win
PR_NUMBER: ${{ github.event.number }}

jobs:
build-file:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Docker Tag Metadata
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=pr
- name: Docker Build
run: docker build -f Dockerfiles/file/Dockerfile.file --build-arg MINGW_VERSION=pr-${{ env.PR_NUMBER }} -t ${{ steps.meta.outputs.tags }} --cache-from type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest --cache-from type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:main --cache-from type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:pr-${{ env.PR_NUMBER }} .
- name: Docker Push
run: docker push ${{ steps.meta.outputs.tags }}
32 changes: 32 additions & 0 deletions .github/workflows/build-gpg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on:
workflow_call:

env:
REGISTRY: ghcr.io
IMAGE_NAME: gpg4win
PR_NUMBER: ${{ github.event.number }}

jobs:
build-gpg:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Docker Tag Metadata
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=pr
- name: Docker Build
run: docker build -f Dockerfiles/gpg/Dockerfile.gpg --build-arg MINGW_VERSION=pr-${{ env.PR_NUMBER }} -t ${{ steps.meta.outputs.tags }} --cache-from type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest --cache-from type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:main --cache-from type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:pr-${{ env.PR_NUMBER }} .
- name: Docker Push
run: docker push ${{ steps.meta.outputs.tags }}
32 changes: 32 additions & 0 deletions .github/workflows/build-mingw.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on:
workflow_call:

env:
REGISTRY: ghcr.io
IMAGE_NAME: mingw-w64
PR_NUMBER: ${{ github.event.number }}

jobs:
build-mingw-w64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Docker Tag Metadata
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=pr
- name: Docker Build
run: docker build -f Dockerfiles/mingw-w64/Dockerfile.mingw-w64 -t ${{ steps.meta.outputs.tags }} --cache-from type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest --cache-from type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:main --cache-from type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:pr-${{ env.PR_NUMBER }} .
- name: Docker Push
run: docker push ${{ steps.meta.outputs.tags }}
54 changes: 54 additions & 0 deletions .github/workflows/test-resources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Test Build Resources"

on:
pull_request:
branches:
- main

concurrency:
group: ci-${{github.ref}}-${{github.event.pull_request.number || github.run_number}}
cancel-in-progress: true

jobs:
changed:
name: "Build and Upload Resources"
runs-on: ubuntu-latest
outputs:
mingw: ${{ steps.changes.outputs.mingw }}
file: ${{ steps.changes.outputs.file }}
gpg: ${{ steps.changes.outputs.gpg }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
mingw:
- 'Dockerfiles/mingw-w64/**'
file:
- 'Dockerfiles/file/**'
gpg:
- 'Dockerfiles/gpg/**'
build-mingw:
name: "Mingw-w64 build"
if: ${{ needs.changed.outputs.mingw }}
needs: [changed]
uses: ./.github/workflows/build-mingw.yml

build-gpg:
name: "Gpg x-build for Windows"
if: |
always() &&
needs.changed.outputs.gpg &&
(needs.build-mingw.result == 'success' || needs.build-mingw.result == 'skipped')
needs: [build-mingw, changed]
uses: ./.github/workflows/build-gpg.yml

build-file:
name: "File x-build for Windows"
if: |
always() &&
needs.changed.outputs.file &&
(needs.build-mingw.result == 'success' || needs.build-mingw.result == 'skipped')
needs: [build-mingw, changed]
uses: ./.github/workflows/build-file.yml
65 changes: 65 additions & 0 deletions .github/workflows/update-file.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
on:
workflow_call:

env:
REGISTRY: ghcr.io
IMAGE_NAME: file

jobs:
build-file:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
tags: |
type=refs,event=push
type=sha
flavor: |
latest=true
- name: Docker Build
run: docker build -f Dockerfiles/file/Dockerfile.file -t ${{ steps.meta.outputs.tags }} --cache-from type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest --cache-from type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:main .
- name: Docker Push
run: docker push ${{ steps.meta.outputs.tags }}
push-file:
runs-on: ubuntu-latest
needs: [build-file]
steps:
- uses: actions/checkout@v4
with:
fetch_depth: 0
- name: Extract file binary tree + archive
run: |
mkdir -p tmp/resources/file
export CONTAINER_ID=$(docker create ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest)
docker cp $CONTAINER_ID:/opt/file tmp/resources/file/file
docker cp $CONTAINER_ID:/opt/mingw64-w64/x86_64-w64-mingw32/bin/libgnurx-0.dll tmp/resource/file/file/bin
cd tmp/resources/file
tar -cz file > file.tar.gz
- name: Checkout pages
run: |
git fetch --all
git checkout -f -B pages --track origin/pages
- name: Config git user
run: |
git config --local user.email "[email protected]"
git config --local user.name "Github Actions from commit ${{ github.sha }}"
- name: Upload
run: |
rm -rf resources/file/*
mv tmp/resources/file/file.tar.gz resources/file/file.tar.gz
git add resources/file/file.tar.gz && git commit -m"Update file binary" && git push -f
63 changes: 63 additions & 0 deletions .github/workflows/update-gpg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
on:
workflow_call:

env:
REGISTRY: ghcr.io
IMAGE_NAME: gpg

jobs:
build-gpg:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
tags: |
type=refs,event=push
type=sha
flavor: |
latest=true
- name: Docker Build
run: docker build -f Dockerfiles/gpg/Dockerfile.gpg -t ${{ steps.meta.outputs.tags }} --cache-from type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest --cache-from type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:main .
- name: Docker Push
run: docker push ${{ steps.meta.outputs.tags }}
push-gpg:
runs-on: ubuntu-latest
needs: [build-gpg]
steps:
- uses: actions/checkout@v4
with:
fetch_depth: 0
- name: Extract gpg binary tree + archive
run: |
mkdir -p tmp/resources/gpg
docker cp $(docker create ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest):/opt/gpg tmp/resources/gpg/gpg
cd tmp/resources/gpg
tar -cz gpg > gpg.tar.gz
- name: Checkout pages
run: |
git fetch --all
git checkout -f -B pages --track origin/pages
- name: Config git user
run: |
git config --local user.email "[email protected]"
git config --local user.name "Github Actions from commit ${{ github.sha }}"
- name: Upload
run: |
rm -rf resources/gpg/*
mv tmp/resources/gpg/gpg.tar.gz resources/gpg/gpg.tar.gz
git add resources/gpg/gpg.tar.gz && git commit -m"Update gpg binary" && git push -f
64 changes: 64 additions & 0 deletions .github/workflows/update-mingw.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
on:
workflow_call:

env:
REGISTRY: ghcr.io
IMAGE_NAME: mingw-w64

jobs:
build-mingw-w64:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
tags: |
type=refs,event=push
type=sha
flavor: |
latest=true
- name: Docker Build
run: docker build -f Dockerfiles/mingw-w64/Dockerfile.mingw-w64 -t ${{ steps.meta.outputs.tags }} --cache-from type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest --cache-from type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:main .
- name: Docker Push
run: docker push ${{ steps.meta.outputs.tags }}

push-mingw-w64:
runs-on: ubuntu-latest
needs: [build-mingw-w64]
steps:
- uses: actions/checkout@v4
with:
fetch_depth: 0
- name: Extract mingw-w64 binary tree + archive
run: |
mkdir -p tmp/resources/mingw_w64
docker cp $(docker create ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest):/opt/mingw64-w64 tmp/resources/mingw_w64/mingw_w64
cd tmp/resources/mingw_w64
tar -cz mingw_w64 > mingw_w64.tar.gz
- name: Checkout pages
run: |
git fetch --all
git checkout -f -B pages --track origin/pages
- name: Config git user
run: |
git config --local user.email "[email protected]"
git config --local user.name "Github Actions from commit ${{ github.sha }}"
- name: Upload
run: |
rm -rf resources/mingw_w64/*
mv tmp/resources/mingw_w64/mingw_w64.tar.gz resources/mingw_w64/mingw_w64.tar.gz
git add resources/mingw_w64/mingw_w64.tar.gz && git commit -m"Update mingw_w64 binary" && git push -f
Loading

0 comments on commit 635f5a3

Please sign in to comment.