mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-21 21:33:22 +01:00
ci: use bake matrix subaction
This commit is contained in:
73
.github/workflows/build.yml
vendored
73
.github/workflows/build.yml
vendored
@@ -27,8 +27,8 @@ jobs:
|
|||||||
prepare:
|
prepare:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
validate-includes: ${{ steps.validate.outputs.includes }}
|
validate-includes: ${{ steps.validate.outputs.matrix }}
|
||||||
artifact-platforms: ${{ steps.artifact.outputs.platforms }}
|
artifact-includes: ${{ steps.artifact.outputs.matrix }}
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
@@ -36,66 +36,19 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Validate matrix
|
name: Validate matrix
|
||||||
id: validate
|
id: validate
|
||||||
uses: actions/github-script@v7
|
uses: docker/bake-action/subaction/matrix@v6
|
||||||
|
with:
|
||||||
|
target: validate
|
||||||
|
fields: platforms
|
||||||
env:
|
env:
|
||||||
GOLANGCI_LINT_MULTIPLATFORM: 1
|
GOLANGCI_LINT_MULTIPLATFORM: 1
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
let def = {};
|
|
||||||
await core.group(`Parsing definition`, async () => {
|
|
||||||
const resPrint = await exec.getExecOutput('docker', ['buildx', 'bake', 'validate', '--print'], {
|
|
||||||
ignoreReturnCode: true
|
|
||||||
});
|
|
||||||
if (resPrint.stderr.length > 0 && resPrint.exitCode != 0) {
|
|
||||||
throw new Error(res.stderr);
|
|
||||||
}
|
|
||||||
def = JSON.parse(resPrint.stdout.trim());
|
|
||||||
});
|
|
||||||
await core.group(`Generating matrix`, async () => {
|
|
||||||
const includes = [];
|
|
||||||
for (const targetName of Object.keys(def.target)) {
|
|
||||||
const target = def.target[targetName];
|
|
||||||
if (target.platforms && target.platforms.length > 0) {
|
|
||||||
target.platforms.forEach(platform => {
|
|
||||||
includes.push({
|
|
||||||
target: targetName,
|
|
||||||
platform: platform
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
includes.push({
|
|
||||||
target: targetName
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
core.info(JSON.stringify(includes, null, 2));
|
|
||||||
core.setOutput('includes', JSON.stringify(includes));
|
|
||||||
});
|
|
||||||
-
|
-
|
||||||
name: Artifact matrix
|
name: Artifact matrix
|
||||||
id: artifact
|
id: artifact
|
||||||
uses: actions/github-script@v7
|
uses: docker/bake-action/subaction/matrix@v6
|
||||||
with:
|
with:
|
||||||
script: |
|
target: artifact-all
|
||||||
const targetName = 'artifact-all';
|
fields: platforms
|
||||||
let def = {};
|
|
||||||
await core.group(`Parsing definition`, async () => {
|
|
||||||
const resPrint = await exec.getExecOutput('docker', ['buildx', 'bake', targetName, '--print'], {
|
|
||||||
ignoreReturnCode: true
|
|
||||||
});
|
|
||||||
if (resPrint.stderr.length > 0 && resPrint.exitCode != 0) {
|
|
||||||
throw new Error(res.stderr);
|
|
||||||
}
|
|
||||||
def = JSON.parse(resPrint.stdout.trim());
|
|
||||||
});
|
|
||||||
await core.group(`Generating matrix`, async () => {
|
|
||||||
const platforms = def.target?.[targetName]?.platforms ?? [];
|
|
||||||
if (platforms.length === 0) {
|
|
||||||
throw new Error(`No platforms found for ${targetName} target`);
|
|
||||||
}
|
|
||||||
core.info(JSON.stringify(platforms, null, 2));
|
|
||||||
core.setOutput('platforms', JSON.stringify(platforms));
|
|
||||||
});
|
|
||||||
|
|
||||||
validate:
|
validate:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -119,7 +72,7 @@ jobs:
|
|||||||
source: .
|
source: .
|
||||||
targets: ${{ matrix.target }}
|
targets: ${{ matrix.target }}
|
||||||
set: |
|
set: |
|
||||||
*.platform=${{ matrix.platform }}
|
*.platform=${{ matrix.platforms }}
|
||||||
|
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -183,12 +136,12 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
platform: ${{ fromJson(needs.prepare.outputs.artifact-platforms) }}
|
include: ${{ fromJson(needs.prepare.outputs.artifact-includes) }}
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Prepare
|
name: Prepare
|
||||||
run: |
|
run: |
|
||||||
platform=${{ matrix.platform }}
|
platform=${{ matrix.platforms }}
|
||||||
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
@@ -211,7 +164,7 @@ jobs:
|
|||||||
sbom: true
|
sbom: true
|
||||||
pull: true
|
pull: true
|
||||||
set: |
|
set: |
|
||||||
*.platform=${{ matrix.platform }}
|
*.platform=${{ matrix.platforms }}
|
||||||
-
|
-
|
||||||
name: Rename provenance and sbom
|
name: Rename provenance and sbom
|
||||||
working-directory: ${{ env.DESTDIR }}/artifact
|
working-directory: ${{ env.DESTDIR }}/artifact
|
||||||
|
|||||||
Reference in New Issue
Block a user