From cf1e7a258282e034e8fd2cc0c8509eb50d95691c Mon Sep 17 00:00:00 2001 From: Valentin Flaux Date: Sat, 21 Jan 2023 01:24:00 +0100 Subject: [PATCH 01/12] test gihub action --- .github/workflows/build-and-publish.yml | 189 ++++++++++++------------ Dockerfile | 35 ++--- 2 files changed, 112 insertions(+), 112 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index b85c056..c079d4a 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -18,96 +18,101 @@ jobs: GOOS: "${{matrix.os}}" GOARCH: "${{matrix.arch}}" steps: - - uses: actions/checkout@v3 - - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: 1.19 - - - name: Setup Golang caches - uses: actions/cache@v3 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{runner.os}}-golang-${{matrix.os}}_${{matrix.arch}}-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{runner.os}}-golang-${{matrix.os}}_${{matrix.arch}}- - - - name: Vet - run: go vet -v ./... - - - name: Test - run: go test -v ./... - - - name: Build - run: go build -v -o 'bin/semver-tagger_${{matrix.os}}_${{matrix.arch}}' main.go - - - uses: actions/upload-artifact@v3 - with: - name: bin - path: bin/ - - publish-binaries: - name: Publish binaries to release - if: github.event_name == 'release' - runs-on: ubuntu-latest - needs: build-binary - steps: - - uses: actions/download-artifact@v3 - with: - name: bin - path: bin - - - name: Upload binaries to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: bin/* - file_glob: true - overwrite: true - - build-and-push-image: - name: Build image and push to repository - runs-on: ubuntu-latest - needs: build-binary - steps: - - name: Checkout - uses: actions/checkout@v3 - - - uses: actions/download-artifact@v3 - with: - name: bin - path: bin - - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: ghcr.io/vflaux/semver-tagger - tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=sha - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Build image - uses: docker/build-push-action@v3 + - uses: vflaux/semver-tagger-action@v1 with: - context: . - push: ${{ github.event_name != 'pull_request' }} - platforms: linux/amd64,linux/arm64 - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + image: vflaux/semver-tagger-action:0.1.0 + + # - uses: actions/checkout@v3 + + # - name: Set up Go + # uses: actions/setup-go@v3 + # with: + # go-version: 1.19 + + # - name: Setup Golang caches + # uses: actions/cache@v3 + # with: + # path: | + # ~/.cache/go-build + # ~/go/pkg/mod + # key: ${{runner.os}}-golang-${{matrix.os}}_${{matrix.arch}}-${{ hashFiles('**/go.sum') }} + # restore-keys: | + # ${{runner.os}}-golang-${{matrix.os}}_${{matrix.arch}}- + + # - name: Vet + # run: go vet -v ./... + + # - name: Test + # run: go test -v ./... + + # - name: Build + # run: go build -v -o 'bin/semver-tagger_${{matrix.os}}_${{matrix.arch}}' main.go + + # - uses: actions/upload-artifact@v3 + # with: + # name: bin + # path: bin/ + + # publish-binaries: + # name: Publish binaries to release + # if: github.event_name == 'release' + # runs-on: ubuntu-latest + # needs: build-binary + # steps: + # - uses: actions/download-artifact@v3 + # with: + # name: bin + # path: bin + + # - name: Upload binaries to release + # uses: svenstaro/upload-release-action@v2 + # with: + # repo_token: ${{ secrets.GITHUB_TOKEN }} + # file: bin/* + # file_glob: true + # overwrite: true + + # build-and-push-image: + # name: Build image and push to repository + # runs-on: ubuntu-latest + # needs: build-binary + # steps: + # - name: Checkout + # uses: actions/checkout@v3 + + # - uses: actions/download-artifact@v3 + # with: + # name: bin + # path: bin + + # - name: Docker meta + # id: meta + # uses: docker/metadata-action@v4 + # with: + # images: ghcr.io/vflaux/semver-tagger + # flavor: | + # latest=false + # tags: | + # type=semver,pattern={{version}} + # type=sha + # labels: | + # org.opencontainers.image.description=A tool to remotely tag an image if it is the latest version + + # - name: Login to GitHub Container Registry + # uses: docker/login-action@v2 + # with: + # registry: ghcr.io + # username: ${{ github.repository_owner }} + # password: ${{ secrets.GITHUB_TOKEN }} + + # - name: Set up Docker Buildx + # uses: docker/setup-buildx-action@v2 + + # - name: Build image + # uses: docker/build-push-action@v3 + # with: + # context: . + # push: ${{ github.event_name != 'pull_request' }} + # platforms: linux/amd64,linux/arm64 + # tags: ${{ steps.meta.outputs.tags }} + # labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index 9629100..c802c59 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,21 @@ -ARG ALPINE_VERSION=3.17 - -FROM alpine:${ALPINE_VERSION} - -RUN apk add make --no-cache +# syntax=docker.io/docker/dockerfile:1.4 +FROM scratch as base ARG TARGETOS ARG TARGETARCH - COPY bin/semver-tagger_${TARGETOS}_${TARGETARCH} /usr/local/bin/semver-tagger +ENTRYPOINT ["/usr/local/bin/semver-tagger"] + +FROM debian:bookworm-slim as debian +ARG TARGETOS +ARG TARGETARCH +COPY --link bin/semver-tagger_${TARGETOS}_${TARGETARCH} /usr/local/bin/semver-tagger -ARG VENDOR -ARG SOURCE -ARG VERSION -ARG REVISION -ARG TITLE -ARG CREATED +FROM debian as github-action +COPY --link semver-tagger-action/entrypoint.sh /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] -LABEL \ - org.opencontainers.image.description="A tool to remotely tag an image if it is the latest version" \ - org.opencontainers.image.vendor="$VENDOR" \ - org.opencontainers.image.source="$SOURCE" \ - org.opencontainers.image.version="$VERSION" \ - org.opencontainers.image.revision="$REVISION" \ - org.opencontainers.image.title="$TITLE" \ - org.opencontainers.image.created="$CREATED" +FROM alpine:3.17 as alpine +ARG TARGETOS +ARG TARGETARCH +COPY --link bin/semver-tagger_${TARGETOS}_${TARGETARCH} /usr/local/bin/semver-tagger \ No newline at end of file From dfaa10c453378a06f459ff00d51ee7f4f4d918dd Mon Sep 17 00:00:00 2001 From: Valentin Flaux Date: Sat, 21 Jan 2023 01:45:05 +0100 Subject: [PATCH 02/12] fixup! test gihub action --- .github/workflows/build-and-publish.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index c079d4a..73839a8 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -21,7 +21,14 @@ jobs: - uses: vflaux/semver-tagger-action@v1 with: image: vflaux/semver-tagger-action:0.1.0 - + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + # - uses: actions/checkout@v3 # - name: Set up Go From 40721c215f4cbab8ebee22560c4ac1eb88b0c5f5 Mon Sep 17 00:00:00 2001 From: Valentin Flaux Date: Sat, 21 Jan 2023 01:48:39 +0100 Subject: [PATCH 03/12] fixup! test gihub action --- .github/workflows/build-and-publish.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 73839a8..f7ddb0b 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -10,13 +10,13 @@ jobs: build-binary: name: Build ${{matrix.os}}/${{matrix.arch}} binary runs-on: ubuntu-latest - strategy: - matrix: - os: ["linux"] - arch: ["amd64", "arm64"] - env: - GOOS: "${{matrix.os}}" - GOARCH: "${{matrix.arch}}" + # strategy: + # matrix: + # os: ["linux"] + # arch: ["amd64", "arm64"] + # env: + # GOOS: "${{matrix.os}}" + # GOARCH: "${{matrix.arch}}" steps: - uses: vflaux/semver-tagger-action@v1 with: From fb2a29837f0699f0497c5d96e491541e0b691e51 Mon Sep 17 00:00:00 2001 From: Valentin Flaux Date: Sat, 21 Jan 2023 02:14:08 +0100 Subject: [PATCH 04/12] fixup! test gihub action --- .github/workflows/build-and-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index f7ddb0b..d3a9118 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -20,7 +20,7 @@ jobs: steps: - uses: vflaux/semver-tagger-action@v1 with: - image: vflaux/semver-tagger-action:0.1.0 + image: vflaux/semver-tagger-action:0.1.1 - name: Login to GitHub Container Registry uses: docker/login-action@v2 From 3fbb0d2801aa9c816dec01bd3d25a811e0e3b461 Mon Sep 17 00:00:00 2001 From: Valentin Flaux Date: Sat, 21 Jan 2023 02:22:34 +0100 Subject: [PATCH 05/12] fixup! test gihub action --- .github/workflows/build-and-publish.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index d3a9118..05d1266 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -18,16 +18,17 @@ jobs: # GOOS: "${{matrix.os}}" # GOARCH: "${{matrix.arch}}" steps: - - uses: vflaux/semver-tagger-action@v1 - with: - image: vflaux/semver-tagger-action:0.1.1 - - name: Login to GitHub Container Registry uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - uses: vflaux/semver-tagger-action@v1 + with: + image: vflaux/semver-tagger-action:0.1.1 + + # - uses: actions/checkout@v3 From 2b130411bfa1bbab377217f02b7eb49c906c2b1a Mon Sep 17 00:00:00 2001 From: Valentin Flaux Date: Sat, 21 Jan 2023 02:24:07 +0100 Subject: [PATCH 06/12] fixup! test gihub action --- .github/workflows/build-and-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 05d1266..218baec 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -26,7 +26,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - uses: vflaux/semver-tagger-action@v1 with: - image: vflaux/semver-tagger-action:0.1.1 + image: ghcr.io/vflaux/semver-tagger-action:0.1.1 From 4c90139b578e4d14c0780eaea7e24edea4111a56 Mon Sep 17 00:00:00 2001 From: Valentin Flaux Date: Sat, 21 Jan 2023 02:49:03 +0100 Subject: [PATCH 07/12] fixup! test gihub action --- .github/workflows/build-and-publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 218baec..7cd96ac 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -24,6 +24,7 @@ jobs: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - run: ls $HOME - uses: vflaux/semver-tagger-action@v1 with: image: ghcr.io/vflaux/semver-tagger-action:0.1.1 From 7e4c9dce4e564a016c7167657cf515cf9c9c25c7 Mon Sep 17 00:00:00 2001 From: Valentin Flaux Date: Sat, 21 Jan 2023 02:49:47 +0100 Subject: [PATCH 08/12] fixup! test gihub action --- .github/workflows/build-and-publish.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 7cd96ac..bbbd674 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -24,7 +24,8 @@ jobs: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - run: ls $HOME + - run: ls -l + - run: tree - uses: vflaux/semver-tagger-action@v1 with: image: ghcr.io/vflaux/semver-tagger-action:0.1.1 From d10fd253bec82923b01274b0a9c86234c53e218a Mon Sep 17 00:00:00 2001 From: Valentin Flaux Date: Sat, 21 Jan 2023 02:50:45 +0100 Subject: [PATCH 09/12] fixup! test gihub action --- .github/workflows/build-and-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index bbbd674..58a3cfe 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -24,8 +24,8 @@ jobs: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - run: ls -l - - run: tree + - run: ls -l $HOME + - run: tree / - uses: vflaux/semver-tagger-action@v1 with: image: ghcr.io/vflaux/semver-tagger-action:0.1.1 From c7d74bb7149daf20722279a4cf82cddfc37f1140 Mon Sep 17 00:00:00 2001 From: Valentin Flaux Date: Sat, 21 Jan 2023 02:52:30 +0100 Subject: [PATCH 10/12] fixup! test gihub action --- .github/workflows/build-and-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 58a3cfe..07531b9 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -24,8 +24,8 @@ jobs: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - run: ls -l $HOME - - run: tree / + - run: ls -la $HOME + - run: tree $HOME - uses: vflaux/semver-tagger-action@v1 with: image: ghcr.io/vflaux/semver-tagger-action:0.1.1 From 7cdd136c4107507370458fff508c8cd2d0bd5c63 Mon Sep 17 00:00:00 2001 From: Valentin Flaux Date: Sat, 21 Jan 2023 02:54:05 +0100 Subject: [PATCH 11/12] fixup! test gihub action --- .github/workflows/build-and-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 07531b9..b0e9eaf 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -25,7 +25,7 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - run: ls -la $HOME - - run: tree $HOME + - run: tree $HOME/.docker - uses: vflaux/semver-tagger-action@v1 with: image: ghcr.io/vflaux/semver-tagger-action:0.1.1 From e10e22478fbf81158f5eaa09620b97222e1e5ca9 Mon Sep 17 00:00:00 2001 From: Valentin Flaux Date: Sat, 21 Jan 2023 02:54:49 +0100 Subject: [PATCH 12/12] fixup! test gihub action --- .github/workflows/build-and-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index b0e9eaf..edceb20 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -24,8 +24,8 @@ jobs: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - run: ls -la $HOME - - run: tree $HOME/.docker + - run: echo $HOME + - run: cat $HOME/.docker/config.json - uses: vflaux/semver-tagger-action@v1 with: image: ghcr.io/vflaux/semver-tagger-action:0.1.1