From 173790720b5319d78638bb6294a5f1bd031aff76 Mon Sep 17 00:00:00 2001 From: Robert Wunderer Date: Fri, 20 Oct 2023 12:18:05 +0000 Subject: [PATCH 1/9] Add badges to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index af47ab0..e503296 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ [![GitHub license](https://img.shields.io/github/license/rwunderer/hcloud-cli.svg)](https://github.com/rwunderer/hcloud-cli/blob/main/LICENSE) +Renovate enabled +GitHub workflow status # hcloud-cli Minimal Docker image with Hetzner cli utility From 157aa52f623507797a0c00ca590775d1ffe4d742 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 20 Oct 2023 11:53:15 +0000 Subject: [PATCH 2/9] Add renovate.json --- .github/renovate.json | 7 +++++++ Dockerfile | 11 ++++++----- README.md | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 .github/renovate.json diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 0000000..a54bbe1 --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,7 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "github>rwunderer/renovate", + "regexManagers:dockerfileVersions" + ] +} diff --git a/Dockerfile b/Dockerfile index b565d05..dc7ae4e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,14 @@ FROM busybox:v1.36.1@sha256:3fbc632167424a6d997e74f52b878d7cc478225cffac6bc977eedfe51c7f4e79 -ARG _VERSION=1.38.3 -ARG _ARCH=amd64 +# renovate: datasource=github-releases depName=hcloud-cli lookupName=hetznercloud/cli +ARG HCLOUD_VERSION=v1.38.2 +ARG ARCH=amd64 WORKDIR /tmp -RUN wget https://github.com/hetznercloud/cli/releases/download/v${_VERSION}/hcloud-linux-${_ARCH}.tar.gz && \ - tar xzf hcloud-linux-${_ARCH}.tar.gz hcloud && \ +RUN wget https://github.com/hetznercloud/cli/releases/download/${HCLOUD_VERSION}/hcloud-linux-${ARCH}.tar.gz && \ + tar xzf hcloud-linux-${ARCH}.tar.gz hcloud && \ install hcloud /bin && \ - rm hcloud-linux-${_ARCH}.tar.gz hcloud + rm hcloud-linux-${ARCH}.tar.gz hcloud ENTRYPOINT ["/bin/hcloud"] diff --git a/README.md b/README.md index e503296..0e70f5a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![GitHub license](https://img.shields.io/github/license/rwunderer/hcloud-cli.svg)](https://github.com/rwunderer/hcloud-cli/blob/main/LICENSE) Renovate enabled -GitHub workflow status +GitHub workflow status # hcloud-cli Minimal Docker image with Hetzner cli utility From 367510fd946f3c01c403b513071d867d042801f3 Mon Sep 17 00:00:00 2001 From: Robert Wunderer Date: Fri, 20 Oct 2023 13:00:03 +0000 Subject: [PATCH 3/9] Add label to renovate PRs --- .github/renovate.json | 9 +++++++++ Dockerfile | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/renovate.json b/.github/renovate.json index a54bbe1..b5ed5bf 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -3,5 +3,14 @@ "extends": [ "github>rwunderer/renovate", "regexManagers:dockerfileVersions" + ], + + "packageRules": [ + { + "matchPackageNames": ["hcloud/cli"], + "addLabels": [ + "renovate_publish" + ] + } ] } diff --git a/Dockerfile b/Dockerfile index dc7ae4e..1a70b68 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM busybox:v1.36.1@sha256:3fbc632167424a6d997e74f52b878d7cc478225cffac6bc977eedfe51c7f4e79 -# renovate: datasource=github-releases depName=hcloud-cli lookupName=hetznercloud/cli +# renovate: datasource=github-releases depName=hcloud/cli lookupName=hetznercloud/cli ARG HCLOUD_VERSION=v1.38.2 ARG ARCH=amd64 From 4d47a6cf32341d8fc80aa848f7074cc3acc2dac2 Mon Sep 17 00:00:00 2001 From: Robert Wunderer Date: Fri, 20 Oct 2023 13:47:07 +0000 Subject: [PATCH 4/9] Automatically add tag after renovate merge --- .github/workflows/renovate-create-tag.yml | 39 +++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/renovate-create-tag.yml diff --git a/.github/workflows/renovate-create-tag.yml b/.github/workflows/renovate-create-tag.yml new file mode 100644 index 0000000..8f2cd2a --- /dev/null +++ b/.github/workflows/renovate-create-tag.yml @@ -0,0 +1,39 @@ +name: Auto-Tag + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + pull_request: + types: [ "closed" ] + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + + +jobs: + update_tag: + if: >- + github.event.pull_request.merged == true && + contains(github.event.pull_request.labels.*.name, 'renovate_publish') + + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - uses: butlerlogic/action-autotag@1.1.1 + env: + GITHUB_TOKEN: "${{ secrets.TAGGING_TOKEN }}" + with: + strategy: regex + root: "Dockerfile" + regex_pattern: "HCLOUD_VERSION=(v\\d+\\.\\d+\\.\\d+)" From 39eae7043b56008b2de3dc06f4ad43ab66ab6303 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 20 Oct 2023 12:50:41 +0000 Subject: [PATCH 5/9] Update dependency hcloud-cli to v1.38.3 --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1a70b68..8fbb9fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM busybox:v1.36.1@sha256:3fbc632167424a6d997e74f52b878d7cc478225cffac6bc977eedfe51c7f4e79 -# renovate: datasource=github-releases depName=hcloud/cli lookupName=hetznercloud/cli -ARG HCLOUD_VERSION=v1.38.2 +# renovate: datasource=github-releases depName=hcloud-cli lookupName=hetznercloud/cli +ARG HCLOUD_VERSION=v1.38.3 ARG ARCH=amd64 WORKDIR /tmp From ccab573d09e9416733c2c00958a3e0fa4364cba1 Mon Sep 17 00:00:00 2001 From: Robert Wunderer Date: Fri, 20 Oct 2023 14:22:21 +0000 Subject: [PATCH 6/9] Add additional badge --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e70f5a..37e31e5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,12 @@ [![GitHub license](https://img.shields.io/github/license/rwunderer/hcloud-cli.svg)](https://github.com/rwunderer/hcloud-cli/blob/main/LICENSE) Renovate enabled -GitHub workflow status # hcloud-cli Minimal Docker image with Hetzner cli utility + +## Workflows + +| Badge | Description +|------------|--------- +|[![Auto-Tag](https://github.com/rwunderer/hcloud-cli/actions/workflows/renovate-create-tag.yml/badge.svg)](https://github.com/rwunderer/hcloud-cli/actions/workflows/renovate-create-tag.yml) | Automatic Tagging of new hcloud releases +|[![Docker](https://github.com/rwunderer/hcloud-cli/actions/workflows/docker-publish.yml/badge.svg)](https://github.com/rwunderer/hcloud-cli/actions/workflows/docker-publish.yml) | Docker image build From 4e0b783b62eb7c412bf37f9ebcbc08ab97793bd6 Mon Sep 17 00:00:00 2001 From: Robert Wunderer Date: Mon, 23 Oct 2023 13:39:37 +0000 Subject: [PATCH 7/9] Add automatic creation of release for tags --- .github/workflows/release.yml | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e281c78 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,39 @@ +# see: https://localheinz.com/articles/2022/01/24/creating-releases-with-github-actions/ +name: "Create Release" + +on: + push: + # Publish semver tags as releases. + tags: [ 'v*.*.*' ] + +jobs: + release: + name: "Release" + + runs-on: ubuntu-latest + + steps: + - name: "Determine tag" + run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV" + + - name: "Create release" + uses: "actions/github-script@v6" + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + script: | + try { + const response = await github.rest.repos.createRelease({ + draft: false, + generate_release_notes: true, + name: process.env.RELEASE_TAG, + owner: context.repo.owner, + prerelease: false, + repo: context.repo.repo, + tag_name: process.env.RELEASE_TAG, + }); + + core.exportVariable('RELEASE_ID', response.data.id); + core.exportVariable('RELEASE_UPLOAD_URL', response.data.upload_url); + } catch (error) { + core.setFailed(error.message); + } From 291d3215697c511f6b0c991bc383b3bd9dcc7681 Mon Sep 17 00:00:00 2001 From: Robert Wunderer Date: Mon, 23 Oct 2023 14:07:43 +0000 Subject: [PATCH 8/9] Publish variants minimal and debug for three platforms --- .github/workflows/docker-publish.yml | 22 ++++++++++++++++++ .github/workflows/release.yml | 2 ++ Dockerfile | 34 +++++++++++++++++++++++----- 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index b3a6dd0..e9b7067 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -33,6 +33,24 @@ jobs: # with sigstore/fulcio when running outside of PRs. id-token: write + strategy: + fail-fast: false + matrix: + image: + - minimal + - debug + + include: + - image: minimal + target: hcloud-cli-minimal + platforms: linux/amd64,linux/arm64,linux/arm/v7 + #platforms: linux/arm64 + + - image: debug + target: hcloud-cli-debug + platforms: linux/amd64,linux/arm64,linux/arm/v7 + #platforms: linux/arm64 + steps: - name: Checkout repository uses: actions/checkout@v3 @@ -68,6 +86,8 @@ jobs: uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + flavor: | + suffix=-${{ matrix.image }} # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action @@ -77,6 +97,8 @@ jobs: with: context: . push: ${{ github.event_name != 'pull_request' }} + platforms: ${{ matrix.platforms }} + target: ${{ matrix.target }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e281c78..2a00c59 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,6 +11,8 @@ jobs: name: "Release" runs-on: ubuntu-latest + permissions: + contents: write steps: - name: "Determine tag" diff --git a/Dockerfile b/Dockerfile index 8fbb9fd..8462327 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,36 @@ -FROM busybox:v1.36.1@sha256:3fbc632167424a6d997e74f52b878d7cc478225cffac6bc977eedfe51c7f4e79 +#------------------- +# Download hcloud +#------------------- +FROM busybox:v1.36.1@sha256:3fbc632167424a6d997e74f52b878d7cc478225cffac6bc977eedfe51c7f4e79 as builder # renovate: datasource=github-releases depName=hcloud-cli lookupName=hetznercloud/cli ARG HCLOUD_VERSION=v1.38.3 -ARG ARCH=amd64 +ARG TARGETARCH +ARG TARGETOS +ARG TARGETVARIANT WORKDIR /tmp -RUN wget https://github.com/hetznercloud/cli/releases/download/${HCLOUD_VERSION}/hcloud-linux-${ARCH}.tar.gz && \ - tar xzf hcloud-linux-${ARCH}.tar.gz hcloud && \ - install hcloud /bin && \ - rm hcloud-linux-${ARCH}.tar.gz hcloud +#RUN wget https://github.com/hetznercloud/cli/releases/download/${HCLOUD_VERSION}/hcloud-${TARGETOS}-${TARGETARCH}${TARGETVARIANT}.tar.gz && \ +# tar xzf hcloud-${TARGETOS}-${TARGETARCH}${TARGETVARIANT}.tar.gz hcloud && \ +# install hcloud /bin && \ +# rm hcloud-${TARGETOS}-${TARGETARCH}${TARGETVARIANT}.tar.gz hcloud +RUN touch /bin/hcloud + +#------------------- +# Minimal image +#------------------- +FROM gcr.io/distroless/static-debian12@sha256:0c3d36f317d6335831765546ece49b60ad35933250dc14f43f0fd1402450532e as hcloud-cli-minimal + +COPY --from=builder /bin/hcloud /bin/hcloud + +ENTRYPOINT ["/bin/hcloud"] + +#------------------- +# Debug image +#------------------- +FROM gcr.io/distroless/static-debian12:debug@sha256:fab2e9501d6f4748474dc64d58225bca9508cb0c6f8b3a45fee7d633afd87c1a as hcloud-cli-debug + +COPY --from=builder /bin/hcloud /bin/hcloud ENTRYPOINT ["/bin/hcloud"] From 43b80e41a071e6192f70f1601603e33070316adc Mon Sep 17 00:00:00 2001 From: Robert Wunderer Date: Mon, 23 Oct 2023 15:57:16 +0000 Subject: [PATCH 9/9] Use alpine as builder see: https://github.com/mirror/busybox/issues/21 --- .github/workflows/docker-publish.yml | 2 -- Dockerfile | 15 +++++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index e9b7067..3674066 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -44,12 +44,10 @@ jobs: - image: minimal target: hcloud-cli-minimal platforms: linux/amd64,linux/arm64,linux/arm/v7 - #platforms: linux/arm64 - image: debug target: hcloud-cli-debug platforms: linux/amd64,linux/arm64,linux/arm/v7 - #platforms: linux/arm64 steps: - name: Checkout repository diff --git a/Dockerfile b/Dockerfile index 8462327..f8ed369 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ #------------------- # Download hcloud #------------------- -FROM busybox:v1.36.1@sha256:3fbc632167424a6d997e74f52b878d7cc478225cffac6bc977eedfe51c7f4e79 as builder +FROM alpine:3.8.5@sha256:2bb501e6173d9d006e56de5bce2720eb06396803300fe1687b58a7ff32bf4c14 as builder # renovate: datasource=github-releases depName=hcloud-cli lookupName=hetznercloud/cli ARG HCLOUD_VERSION=v1.38.3 @@ -11,11 +11,14 @@ ARG TARGETVARIANT WORKDIR /tmp -#RUN wget https://github.com/hetznercloud/cli/releases/download/${HCLOUD_VERSION}/hcloud-${TARGETOS}-${TARGETARCH}${TARGETVARIANT}.tar.gz && \ -# tar xzf hcloud-${TARGETOS}-${TARGETARCH}${TARGETVARIANT}.tar.gz hcloud && \ -# install hcloud /bin && \ -# rm hcloud-${TARGETOS}-${TARGETARCH}${TARGETVARIANT}.tar.gz hcloud -RUN touch /bin/hcloud +RUN apk --no-cache add --upgrade \ + curl + +RUN IMAGE=hcloud-${TARGETOS}-${TARGETARCH}${TARGETVARIANT}.tar.gz && \ + curl -SsL -o ${IMAGE} https://github.com/hetznercloud/cli/releases/download/${HCLOUD_VERSION}/${IMAGE} && \ + tar xzf ${IMAGE} hcloud && \ + install hcloud /bin && \ + rm ${IMAGE} hcloud #------------------- # Minimal image