From 840c38c71ab2d349d256785779c01512bacb842f Mon Sep 17 00:00:00 2001 From: iTrooz Date: Sat, 24 Oct 2026 01:40:52 +0200 Subject: [PATCH 1/3] ci: add CI to create OCI image on release --- .github/workflows/container.yml | 61 +++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/container.yml diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml new file mode 100644 index 0000000..0505649 --- /dev/null +++ b/.github/workflows/container.yml @@ -0,0 +1,61 @@ +name: Container + +on: + push: + branches: + - master + tags: + - 'v*' + pull_request: + +permissions: + contents: read + +jobs: + container: + name: Build and publish container + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + + - name: Set image name + id: image + run: echo "name=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT" + + - uses: docker/setup-qemu-action@v4 + with: + platforms: arm64 + + - uses: docker/setup-buildx-action@v4 + + - name: Log in to GHCR + if: github.ref_type == 'tag' + uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Container metadata + id: metadata + if: github.ref_type == 'tag' + uses: docker/metadata-action@v6 + with: + images: ${{ steps.image.outputs.name }} + tags: | + type=raw,value=latest + type=ref,event=tag + + - name: Build and publish image + uses: docker/build-push-action@v7 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: ${{ github.ref_type == 'tag' }} + tags: ${{ steps.metadata.outputs.tags }} + labels: ${{ steps.metadata.outputs.labels }} From 2f3197741d6cf38e99a108284f9cb0854f8345dd Mon Sep 17 00:00:00 2001 From: iTrooz Date: Sat, 24 Oct 2026 19:41:10 +0200 Subject: [PATCH 2/3] ci: delete old image build job --- .github/workflows/build.yml | 14 -------------- .github/workflows/container.yml | 9 +++++++-- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4bdc253..72b4c86 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,17 +28,3 @@ jobs: - name: Test run: go test ./... - - docker: - name: Docker build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7 - with: - fetch-depth: 0 - - - name: Build image - run: docker build -t librespeed-cli . - - - name: Smoke test image - run: docker run --rm librespeed-cli --version diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml index 0505649..b21d488 100644 --- a/.github/workflows/container.yml +++ b/.github/workflows/container.yml @@ -55,7 +55,12 @@ jobs: uses: docker/build-push-action@v7 with: context: . - platforms: linux/amd64,linux/arm64 + platforms: ${{ github.ref_type == 'tag' && 'linux/amd64,linux/arm64' || 'linux/amd64' }} + load: ${{ github.ref_type != 'tag' }} push: ${{ github.ref_type == 'tag' }} - tags: ${{ steps.metadata.outputs.tags }} + tags: ${{ steps.metadata.outputs.tags || 'librespeed-cli:ci' }} labels: ${{ steps.metadata.outputs.labels }} + + - name: Smoke test image + if: github.ref_type != 'tag' + run: docker run --rm librespeed-cli:ci --version From dd02e4c486915af149ee7c18cd12b31ad8ec12e0 Mon Sep 17 00:00:00 2001 From: iTrooz Date: Wed, 18 Nov 2026 16:20:10 +0100 Subject: [PATCH 3/3] Address review message Assisted-by: GPT-6.1 Terra --- .github/workflows/container-publish.yml | 73 +++++++++++++++++++++++++ .github/workflows/container.yml | 52 +++--------------- 2 files changed, 81 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/container-publish.yml diff --git a/.github/workflows/container-publish.yml b/.github/workflows/container-publish.yml new file mode 100644 index 0000000..8952cb7 --- /dev/null +++ b/.github/workflows/container-publish.yml @@ -0,0 +1,73 @@ +name: Publish container + +on: + push: + tags: + - 'v*' + +permissions: + contents: read + packages: write + +concurrency: + group: container-publish + cancel-in-progress: false + +jobs: + publish: + name: Publish container + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + with: + fetch-depth: 0 + + - name: Set image name + id: image + run: echo "name=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT" + + - uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4 + with: + platforms: arm64 + + - uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4 + + - name: Log in to GHCR + uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Check latest stable release + id: latest + env: + RELEASE_TAG: ${{ github.ref_name }} + run: | + latest=$(git tag -l 'v*' | grep -E '^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$' | sort -V | tail -n 1) + if [ -n "$latest" ] && [ "$RELEASE_TAG" = "$latest" ]; then + echo "enabled=true" >> "$GITHUB_OUTPUT" + fi + + - name: Container metadata + id: metadata + uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6 + with: + images: ${{ steps.image.outputs.name }} + flavor: latest=false + tags: | + type=ref,event=tag + type=raw,value=latest,enable=${{ steps.latest.outputs.enabled == 'true' }} + + - name: Build and publish image + id: build + uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.metadata.outputs.tags }} + labels: ${{ steps.metadata.outputs.labels }} + + - name: Smoke test published image + run: docker run --rm "${{ steps.image.outputs.name }}@${{ steps.build.outputs.digest }}" --version diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml index b21d488..2309c12 100644 --- a/.github/workflows/container.yml +++ b/.github/workflows/container.yml @@ -4,8 +4,6 @@ on: push: branches: - master - tags: - - 'v*' pull_request: permissions: @@ -13,54 +11,20 @@ permissions: jobs: container: - name: Build and publish container + name: Build container runs-on: ubuntu-latest - permissions: - contents: read - packages: write steps: - - uses: actions/checkout@v7 - with: - fetch-depth: 0 - - - name: Set image name - id: image - run: echo "name=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT" - - - uses: docker/setup-qemu-action@v4 - with: - platforms: arm64 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 - - uses: docker/setup-buildx-action@v4 - - - name: Log in to GHCR - if: github.ref_type == 'tag' - uses: docker/login-action@v4 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Container metadata - id: metadata - if: github.ref_type == 'tag' - uses: docker/metadata-action@v6 - with: - images: ${{ steps.image.outputs.name }} - tags: | - type=raw,value=latest - type=ref,event=tag + - uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4 - - name: Build and publish image - uses: docker/build-push-action@v7 + - name: Build image + uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7 with: context: . - platforms: ${{ github.ref_type == 'tag' && 'linux/amd64,linux/arm64' || 'linux/amd64' }} - load: ${{ github.ref_type != 'tag' }} - push: ${{ github.ref_type == 'tag' }} - tags: ${{ steps.metadata.outputs.tags || 'librespeed-cli:ci' }} - labels: ${{ steps.metadata.outputs.labels }} + platforms: linux/amd64 + load: true + tags: librespeed-cli:ci - name: Smoke test image - if: github.ref_type != 'tag' run: docker run --rm librespeed-cli:ci --version