Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 34 additions & 7 deletions .github/workflows/image.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# SPDX-License-Identifier: Unlicense
# Every push: the image built on amd64 and arm64, its tools checked and its scripts' tests run in it.
# A tag (YYYY.MM.DD, or YYYY.MM.DD.N for a second one that day) publishes both as one multi-arch
# image, ghcr.io/overpressure/builder:TAG, and a release naming its digest, with each variant's
# packages and versions.
# Every pull request, push to main and tag: the image on amd64 and arm64, its tools checked and its
# scripts' tests run in it. Each variant is built once per content of image/: the build is kept as
# ghcr.io/overpressure/builder:ci-<image/'s tree>-<arch>, and a later run (main after the merge, the tag)
# pulls it instead of building it again. A tag (YYYY.MM.DD, or YYYY.MM.DD.N for a second one that day)
# publishes the tested variants as one multi-arch image, ghcr.io/overpressure/builder:TAG, and a release
# naming its digest, with each variant's packages and versions.
name: Image

on:
push:
branches: ["**"]
branches: [main]
tags: ["[0-9][0-9][0-9][0-9].[0-9][0-9].[0-9][0-9]*"]
pull_request:
workflow_dispatch:
Expand Down Expand Up @@ -39,7 +41,26 @@ jobs:
packages: write # a tag's variant
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: The variant's content
id: content
run: echo "candidate=$IMAGE:ci-$(git rev-parse HEAD:image)-${{ matrix.arch }}" >> "$GITHUB_OUTPUT"
- name: The registry
id: registry
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
run: |
echo "${{ github.token }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
echo "push=true" >> "$GITHUB_OUTPUT"
- name: An earlier build of the same content
id: earlier
env:
CANDIDATE: ${{ steps.content.outputs.candidate }}
run: |
if docker pull "$CANDIDATE"; then
docker tag "$CANDIDATE" builder:test
echo "found=true" >> "$GITHUB_OUTPUT"
fi
- name: The image
if: steps.earlier.outputs.found != 'true'
run: docker build --pull -t builder:test image
- name: Its tools
run: |
Expand Down Expand Up @@ -68,10 +89,16 @@ jobs:
python3 -m unittest -v'
- name: Its packages
run: docker run --rm --entrypoint cat builder:test /usr/share/overpressure-packages.txt > packages-${{ matrix.arch }}.txt
- name: Kept for the next run
if: steps.earlier.outputs.found != 'true' && steps.registry.outputs.push == 'true'
env:
CANDIDATE: ${{ steps.content.outputs.candidate }}
run: |
docker tag builder:test "$CANDIDATE"
docker push "$CANDIDATE"
- name: The variant
if: startsWith(github.ref, 'refs/tags/')
run: |
echo "${{ github.token }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
docker tag builder:test "$IMAGE:$GITHUB_REF_NAME-${{ matrix.arch }}"
docker push "$IMAGE:$GITHUB_REF_NAME-${{ matrix.arch }}"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
Expand Down Expand Up @@ -114,7 +141,7 @@ jobs:
echo "$IMAGE:$GITHUB_REF_NAME@$DIGEST"
echo '```'
echo
echo "Built from ${GITHUB_SHA}; the packages of each variant are attached."
echo "Built from image/ as of ${GITHUB_SHA}, tested and published as it was built; the packages of each variant are attached."
} > notes.md
gh release create "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --verify-tag \
--title "$GITHUB_REF_NAME" --notes-file notes.md packages-amd64.txt packages-arm64.txt
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ consumers pin on purpose.

## Publishing

Every push builds both variants, checks their tools and runs the scripts' tests in them
([image.yml](.github/workflows/image.yml)). A tag `YYYY.MM.DD` (or `YYYY.MM.DD.N`) publishes them as one
multi-arch image under that tag, with a release that names its digest and lists each variant's packages.
Every pull request, push to `main` and tag checks both variants' tools and runs the scripts' tests in them
([image.yml](.github/workflows/image.yml)). Each variant is built once per content of `image/` and kept as
`ghcr.io/overpressure/builder:ci-<tree>-<arch>`; later runs pull it instead of building it again. A tag
`YYYY.MM.DD` (or `YYYY.MM.DD.N`) publishes the tested variants as one multi-arch image under that tag, with a
release that names its digest and lists each variant's packages. `main` changes only by pull request.
Published images are kept: an old pin keeps working.

```sh
Expand Down
Loading