99env :
1010 REGISTRY : ghcr.io
1111 IMAGE_NAME : ${{ github.repository }}
12+ DEFAULT_TAG : latest
13+ GH_TOKEN : ${{ github.token }}
1214
1315jobs :
1416 wait-for-hydra-eval :
@@ -22,70 +24,100 @@ jobs:
2224 with :
2325 check : ci/hydra-build:required
2426
25- upload :
27+ discover :
2628 needs : wait-for-hydra-eval
29+ name : Discover
30+ runs-on : ubuntu-latest
31+ outputs :
32+ matrix : ${{ steps.set-matrix.outputs.matrix }}
33+ steps :
34+ - name : fetch all ci/hydra-build jobs
35+ id : set-matrix
36+ run : |
37+ BUILDS=$(gh api "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/check-runs" --paginate \
38+ --jq '.check_runs[] | \
39+ select(.name | startswith("ci/hydra-build")) | select(.name | endswith("-env")) | \
40+ { "config": (.name | sub("ci/hydra-build:"; "")), "build_path": .output.text }' | \
41+ jq --slurp 'reduce .[] as $item ({}; . + $item)' | jq --slurp '{"matrix": .}')
42+ echo "matrix=$BUILDS" >> $GITHUB_OUTPUT
43+
44+ ghcr-upload :
45+ needs : discover
2746 name : Container Upload
2847 strategy :
2948 fail-fast : false
30- matrix :
31- platform :
32- - x86_64-darwin
33- - x86_64-linux
34- - aarch64-darwin
35- # Currently broken
36- # - aarch64-linux
37- compiler-nix-name :
38- - ghc810
39- - ghc92
40- - ghc96
41- - ghc98
42- - ghc910
43- target-platform :
44- - " "
45- - " -static"
46- - " -js"
47- - " -windows"
48- variant :
49- - " "
50- - " -minimal"
51- iog :
52- - " "
53- - " -iog"
54- - " -iog-full"
55- exclude :
56- # Just cross compiling javascript with ghc 9.6.2 for now
57- - compiler-nix-name : ghc810
58- target-platform : " -js"
59- - compiler-nix-name : ghc92
60- target-platform : " -js"
61- # Static builds not working for darwin yet
62- - platform : x86_64-darwin
63- target-platform : " -static"
64- # Static tools not working right now (so just building "-static-minimal" for now)
65- - target-platform : " -static"
66- variant : " "
67- # Windows cross compilation only works on x86_64-linux right now.
68- - platform : aarch64-darwin
69- target-platform : " -windows"
70- - platform : aarch64-linux
71- target-platform : " -windows"
72- - platform : x86_64-darwin
73- target-platform : " -windows"
74- # It does not makes sense to build minimal image that include IOG extra tooling ...
75- # ... "-minimal" and "-iog" are mutually exclusive options!
76- - variant : " -minimal"
77- iog : " -iog"
78- # On darwin the `-js` target require `-minimal` to be set:
79- - target-platform : " -js"
80- platform : aarch64-darwin
81- variant : " "
82- - target-platform : " -js"
83- platform : x86_64-darwin
84- variant : " "
85- uses : ./.github/workflows/wait-and-upload.yml
86- with :
87- platform : ${{ matrix.platform }}
88- target-platform : ${{ matrix.target-platform }}
89- compiler-nix-name : ${{ matrix.compiler-nix-name }}
90- variant : ${{ matrix.variant }}
91- iog : ${{ matrix.iog }}
49+ matrix : ${{ fromJson(needs.discover.outputs.matrix) }}
50+ runs-on : ubuntu-latest
51+ permissions :
52+ contents : read
53+ packages : write
54+ steps :
55+ - name : Free Disk Space (Ubuntu)
56+ uses : jlumbroso/free-disk-space@main
57+
58+ - name : Install Nix with good defaults
59+ uses : cachix/install-nix-action@v20
60+ with :
61+ extra_nix_config : |
62+ trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= loony-tools:pr9m4BkM/5/eSTZlkQyRt57Jz7OMBxNSUiMC4FkcNfk=
63+ substituters = https://cache.iog.io/ https://cache.zw3rk.com/ https://cache.nixos.org/
64+ nix_path : nixpkgs=channel:nixos-unstable
65+ - name : Checkout repository
66+ uses : actions/checkout@v4
67+ - name : Log in to the Container registry
68+ 69+ with :
70+ registry : ${{ env.REGISTRY }}
71+ username : ${{ github.actor }}
72+ password : ${{ secrets.GITHUB_TOKEN }}
73+ - name : Compute and upload closure and developer environment to ghcr.io
74+ env :
75+ DEV_SHELL : ${{ matrix.config }}
76+ SHELL_NIX_PATH : ${{ matrix.build_path }}
77+ NIX_STORE_SECRET_KEY : ${{ secrets.SECRET_KEY }}
78+ run : ./extra/ghcr-upload.sh
79+
80+ # codespace-upload:
81+ # env:
82+ # IMAGE_NAME: input-output-hk/devx-devcontainer
83+ # needs: ghcr-upload
84+ # permissions:
85+ # packages: write
86+ # runs-on: ubuntu-latest
87+ # # We want a GitHub Codespace image for each combination of devx developer shell option.
88+ # # But, since the purpose of GitHub Codespace is to serve a complete development environment,
89+ # # the user is likely to always expect HLS (I don't see the point otherwise).
90+ # # Therefore, it doesn't seem useful to build an image on the `-minimal` flavor (without HLS),
91+ # # or the `-static` one (especially since the latter currently requires `-minimal` to work).
92+ # # Likely, we consider using `-iog` as the default and do not generate other images.
93+ # # Then the user choices left would be between native, `-windows` or `-js` target platforms,
94+ # # and the GHC version (currently `ghc810` and `ghc96`).
95+ # if: false
96+ # steps:
97+ # - name: Checkout repository
98+ # uses: actions/checkout@v4
99+
100+ # - name: Log in to the Container registry
101+ 102+ # with:
103+ # registry: ${{ env.REGISTRY }}
104+ # username: ${{ github.actor }}
105+ # password: ${{ secrets.GITHUB_TOKEN }}
106+
107+ # - name: Build and push Docker image
108+ # uses: docker/build-push-action@v4
109+ # with:
110+ # context: .
111+ # push: true
112+ # tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.platform }}.${{ inputs.compiler-nix-name }}${{ inputs.target-platform }}${{ inputs.variant }}${{ inputs.iog }}
113+ # build-args: |
114+ # PLATFORM=${{ inputs.platform }}
115+ # TARGET_PLATFORM=${{ inputs.target-platform }}
116+ # COMPILER_NIX_NAME=${{ inputs.compiler-nix-name }}
117+ # VARIANT=${{ inputs.variant }}
118+ # IOG=${{ inputs.iog }}
119+
120+ # - name: Run test command inside the Dev Container
121+ # run: |
122+ # docker run --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.platform }}.${{ inputs.compiler-nix-name }}${{ inputs.target-platform }}${{ inputs.variant }}${{ inputs.iog }} \
123+ # bash -ic "cabal update && cabal unpack hello && cd hello-* && cabal build"
0 commit comments