Nix Manual #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Nix Manual | |
on: | |
workflow_dispatch: | |
inputs: | |
build-de: | |
type: boolean | |
default: false | |
required: false | |
build-ce: | |
type: boolean | |
default: false | |
required: false | |
build-ee: | |
type: boolean | |
default: false | |
required: false | |
container-tag: | |
type: string | |
required: false | |
container-tag-sha: | |
type: boolean | |
required: false | |
default: false | |
upload-de-package-to-github: | |
type: boolean | |
required: false | |
default: true | |
jobs: | |
configure: | |
name: Configure Inputs | |
runs-on: ubuntu-20.04 | |
outputs: | |
nix-matrix: ${{ steps.nix.outputs.nix-matrix }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Fetch Tags | |
run: git fetch origin +refs/tags/*:refs/tags/* | |
- name: Calculate Version | |
id: version | |
run: | | |
version="$(git describe --abbrev=10 --long --dirty --match='v[0-9]*')" | |
echo "version=${version}" >> "$GITHUB_OUTPUT" | |
- name: Assemble the Job Matrix | |
id: nix | |
run: | | |
echo '::notice inputs = ${{ toJSON(inputs) }}' | |
tags=() | |
if [[ '${{ inputs.container-tag }}' != "" ]]; then | |
tags+=('${{ inputs.container-tag }}') | |
fi | |
if [[ '${{ inputs.container-tag-sha }}' == 'true' ]]; then | |
tags+=('${{ github.sha }}') | |
fi | |
if [[ '${{ inputs.build }}' == 'true' ]]; then | |
tags+=('${{ github.sha }}') | |
fi | |
nix_config="$(jq -nc \ | |
'."editions" = [ | |
if ${{ inputs.build-de }} then | |
{ | |
"name": "tenzir", | |
"gha-runner-labels": ["ubuntu-latest"], | |
"static": true, | |
"upload-package-to-github": ${{ inputs.upload-de-package-to-github }}, | |
"package-stores": [ | |
"gcs:tenzir-dist-public/packages/manual" | |
], | |
"image-registries": [ | |
"ghcr.io", | |
"docker.io" | |
] | |
} | |
else | |
empty | |
end, | |
if ${{ inputs.build-ce }} then | |
{ | |
"name": "tenzir-ce", | |
"gha-runner-labels": ["ubuntu-latest"], | |
"static": true, | |
"upload-package-to-github": false, | |
"package-stores": [ | |
"gcs:tenzir-dist-private/packages/manual" | |
], | |
"image-registries": [ | |
"622024652768.dkr.ecr.eu-west-1.amazonaws.com" | |
] | |
} | |
else | |
empty | |
end, | |
if ${{ inputs.build-ee }} then | |
{ | |
"name": "tenzir-ee", | |
"gha-runner-labels": ["ubuntu-latest"], | |
"static": true, | |
"upload-package-to-github": false, | |
"package-stores": [ | |
"gcs:tenzir-dist-private/packages/manual" | |
], | |
"image-registries": [ | |
"622024652768.dkr.ecr.eu-west-1.amazonaws.com" | |
] | |
} | |
else | |
empty | |
end | |
] | ."version" = $v | ."tags" = $ARGS.positional' \ | |
--arg v "${{ steps.version.outputs.version }}" \ | |
--args -- "${tags[@]}")" | |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then | |
nix_config="$(jq -c --arg git_tag "${GITHUB_REF#refs/tags/}" \ | |
'."git-tag" = $git_tag' \ | |
<<< "${nix_config}")" | |
fi | |
# Reshape the config so that each edition is in a dedicated config. | |
# This will be supplied as a matrix to the nix job. | |
# We do this because the static editions that we build here are | |
# independent derivations, meaning there is no sharing of build | |
# products. | |
nix_matrix="$(jq -c '.aliases as $aliases | .tags as $tags | | |
.targets = (.editions | map(. as $e |{}| | |
.editions = [$e] | | |
.aliases = $aliases | | |
.tags = $tags) | |
) | .targets | map({"name": .editions[0].name, "config": .})' \ | |
<<< "${nix_config}")" | |
echo "nix-matrix=${nix_matrix}" >> "$GITHUB_OUTPUT" | |
echo "::notice nix-matrix = ${nix_matrix}" | |
nix-tenzir: | |
name: Nix (${{ matrix.config.name }}) | |
needs: | |
- configure | |
uses: ./.github/workflows/nix.yaml | |
strategy: | |
matrix: | |
config: ${{ fromJSON(needs.configure.outputs.nix-matrix) }} | |
with: | |
config: ${{ toJSON(matrix.config.config) }} | |
secrets: inherit |