From 23d43bdb5d0c79f7f9b50f50ec7d26007e4043e6 Mon Sep 17 00:00:00 2001 From: RainrainWu Date: Thu, 1 Dec 2022 20:54:27 +0800 Subject: [PATCH 01/16] Create tag.yml --- .github/workflows/tag.yml | 63 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/tag.yml diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml new file mode 100644 index 0000000..7bdbb83 --- /dev/null +++ b/.github/workflows/tag.yml @@ -0,0 +1,63 @@ +name: "Release Tags" +on: + push: + tags: + - v* + +jobs: + release-dockerhub: + runs-on: ubuntu-latest + strategy: + matrix: + target: + - Dockerfile: Dockerfile + steps: + - uses: actions/checkout@v3 + + - name: Install Go + uses: actions/setup-go@v3 + with: + go-version: 1.19 + + - name: Unshallow + run: git fetch --prune --unshallow + + - name: Prepare + id: prepare + run: | + TAG=${GITHUB_REF#refs/tags/} + MAJOR=${TAG%.*} + SHORT_COMMIT=${GITHUB_SHA::8} + DATE=$(date '+%Y-%m-%dT%H:%M:%SZ') + echo ::set-output name=tag_name::${TAG} + echo ::set-output name=major_tag::${MAJOR} + echo ::set-output name=short_commit::${SHORT_COMMIT} + echo ::set-output name=date::${DATE} + echo ::set-output name=full_tag_name::${TAG} + echo ::set-output name=full_major_tag::${MAJOR} + echo ::set-output name=latest_tag::latest + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login do docker.io + run: docker login -u r41nwu -p ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} + + - name: Build and publish ${{ matrix.target.Dockerfile }} + uses: docker/build-push-action@v3 + with: + context: . + file: ${{ matrix.target.Dockerfile }} + platforms: linux/amd64,linux/arm64 + push: true + build-args: | + VERSION=${{ steps.prepare.outputs.tag_name }} + SHORT_COMMIT=${{ steps.prepare.outputs.short_commit }} + DATE=${{ steps.prepare.outputs.date }} + tags: | + r41nwu/telescope:${{ steps.prepare.outputs.full_tag_name }} + r41nwu/telescope:${{ steps.prepare.outputs.full_major_tag }} + r41nwu/telescope:${{ steps.prepare.outputs.latest_tag }} From 87fe51011ac25dbd8ad90bf09ef82dd68c83b799 Mon Sep 17 00:00:00 2001 From: RainrainWu Date: Thu, 1 Dec 2022 20:56:33 +0800 Subject: [PATCH 02/16] Update and rename dockerized_ci.yml to pull_request.yml --- .github/workflows/{dockerized_ci.yml => pull_request.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{dockerized_ci.yml => pull_request.yml} (94%) diff --git a/.github/workflows/dockerized_ci.yml b/.github/workflows/pull_request.yml similarity index 94% rename from .github/workflows/dockerized_ci.yml rename to .github/workflows/pull_request.yml index 30ee89a..455df71 100644 --- a/.github/workflows/dockerized_ci.yml +++ b/.github/workflows/pull_request.yml @@ -1,4 +1,4 @@ -name: Dockerized CI +name: Pull Request on: push: From a6bbf12e06a6384dd11eb7aa4ef74bc622679093 Mon Sep 17 00:00:00 2001 From: RainrainWu Date: Thu, 1 Dec 2022 20:57:27 +0800 Subject: [PATCH 03/16] Update tag.yml --- .github/workflows/tag.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index 7bdbb83..e2f4bc5 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -1,8 +1,8 @@ -name: "Release Tags" +name: Release Tags + on: push: - tags: - - v* + tags: [ "v*" ] jobs: release-dockerhub: From ddf820759d01894f5495eb2539f44688ad27ac46 Mon Sep 17 00:00:00 2001 From: RainrainWu Date: Thu, 1 Dec 2022 20:59:43 +0800 Subject: [PATCH 04/16] Update tag.yml --- .github/workflows/tag.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index e2f4bc5..0b7d7d1 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -5,12 +5,10 @@ on: tags: [ "v*" ] jobs: + release-dockerhub: + runs-on: ubuntu-latest - strategy: - matrix: - target: - - Dockerfile: Dockerfile steps: - uses: actions/checkout@v3 @@ -43,14 +41,14 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Login do docker.io + - name: Login to docker.io run: docker login -u r41nwu -p ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} - - name: Build and publish ${{ matrix.target.Dockerfile }} + - name: Build and publish image uses: docker/build-push-action@v3 with: context: . - file: ${{ matrix.target.Dockerfile }} + file: "Dockerfile" platforms: linux/amd64,linux/arm64 push: true build-args: | From 20f223f0aadc60ff3c14f00f400550ab35a9a9fb Mon Sep 17 00:00:00 2001 From: RainrainWu Date: Thu, 1 Dec 2022 21:17:19 +0800 Subject: [PATCH 05/16] Update pull_request.yml --- .github/workflows/pull_request.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 455df71..ca1a0fa 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -20,3 +20,7 @@ jobs: - name: Build run: make build + + - name: Check Outdated Dependencies + uses: r41nwu/telescope@latest + run: telescope --strict-semver -c "major:*" From b74881d19e6fa6e0006bc26b87df181fd9c39558 Mon Sep 17 00:00:00 2001 From: RainrainWu Date: Thu, 1 Dec 2022 21:36:30 +0800 Subject: [PATCH 06/16] Update pull_request.yml --- .github/workflows/pull_request.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index ca1a0fa..7974b79 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -21,6 +21,11 @@ jobs: - name: Build run: make build - - name: Check Outdated Dependencies - uses: r41nwu/telescope@latest - run: telescope --strict-semver -c "major:*" + scan: + runs-on: ubuntu-latest + container: r41nwu/telescope:latest + steps: + + - name: Scan Outdated Dependencies + run: | + telescope --strict-semver From 98ce0b28785a4e5f557b914eb238312637958c73 Mon Sep 17 00:00:00 2001 From: Rain Wu Date: Thu, 1 Dec 2022 21:51:13 +0800 Subject: [PATCH 07/16] fix($creative): fix dockerfile Signed-off-by: Rain Wu --- Dockerfile | 2 +- main.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index a9f98a6..c3af3ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ WORKDIR /src RUN apk add --update --no-cache ca-certificates && \ CGO_ENABLED=0 go build -o /src/bin/telescope . -FROM scratch +FROM alpine:latest ENV PATH=/ COPY --from=builder /src/bin/ / diff --git a/main.go b/main.go index acb45df..88e583c 100644 --- a/main.go +++ b/main.go @@ -68,7 +68,7 @@ var ( skipUnknown bool strictSemVer bool ignoredDependencies IgnoredDependencies = make(map[string]bool) - criticalDependencies CriticalDependencies = make(map[string]telescope.OutdatedScope) + criticalDependencies CriticalDependencies = map[string]telescope.OutdatedScope{"*": telescope.MAJOR} ) func init() { From 279bc596aa6556bcfc757686b228d055b97b68ad Mon Sep 17 00:00:00 2001 From: Rain Wu Date: Thu, 1 Dec 2022 22:02:15 +0800 Subject: [PATCH 08/16] feat($build): fis docker file Signed-off-by: Rain Wu --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c3af3ef..4fbbfea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ RUN apk add --update --no-cache ca-certificates && \ FROM alpine:latest -ENV PATH=/ +ENV PATH=$PATH:/ COPY --from=builder /src/bin/ / COPY --from=builder /etc/ssl/certs /etc/ssl/certs From 5f59b62beb771f9aefb047c0c8a561dc5d13d118 Mon Sep 17 00:00:00 2001 From: RainrainWu Date: Thu, 1 Dec 2022 22:09:57 +0800 Subject: [PATCH 09/16] Update pull_request.yml --- .github/workflows/pull_request.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 7974b79..bd623f9 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -23,9 +23,12 @@ jobs: scan: runs-on: ubuntu-latest - container: r41nwu/telescope:latest - steps: - + container: + image: r41nwu/telescope:latest + volumes: + - ${PWD}/go.mod:/go.mod + + steps: - name: Scan Outdated Dependencies run: | telescope --strict-semver From 337159aeef5362ce74fa0603646bac513caace3b Mon Sep 17 00:00:00 2001 From: RainrainWu Date: Thu, 1 Dec 2022 22:11:18 +0800 Subject: [PATCH 10/16] Update pull_request.yml --- .github/workflows/pull_request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index bd623f9..8cc96da 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -26,7 +26,7 @@ jobs: container: image: r41nwu/telescope:latest volumes: - - ${PWD}/go.mod:/go.mod + - $PWD/go.mod:/go.mod steps: - name: Scan Outdated Dependencies From 540d63aa106a812f7ac6bb1f0329d48e344e7d5f Mon Sep 17 00:00:00 2001 From: RainrainWu Date: Thu, 1 Dec 2022 22:13:25 +0800 Subject: [PATCH 11/16] Update pull_request.yml --- .github/workflows/pull_request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 8cc96da..fae2652 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -26,7 +26,7 @@ jobs: container: image: r41nwu/telescope:latest volumes: - - $PWD/go.mod:/go.mod + - ${GITHUB_WORKSPACE}/go.mod:/go.mod steps: - name: Scan Outdated Dependencies From 50bd7ed1d561f037c48a51c8c7a76de9e04e2bb9 Mon Sep 17 00:00:00 2001 From: RainrainWu Date: Thu, 1 Dec 2022 22:16:19 +0800 Subject: [PATCH 12/16] Update pull_request.yml --- .github/workflows/pull_request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index fae2652..116a83b 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -26,7 +26,7 @@ jobs: container: image: r41nwu/telescope:latest volumes: - - ${GITHUB_WORKSPACE}/go.mod:/go.mod + - ${{ github.workspace }}/go.mod:/go.mod steps: - name: Scan Outdated Dependencies From 714e76bfa3b6ef811e47a86696c03cb957d6d1a6 Mon Sep 17 00:00:00 2001 From: Rain Wu Date: Thu, 1 Dec 2022 22:29:02 +0800 Subject: [PATCH 13/16] fix($dep): fix err handling Signed-off-by: Rain Wu --- telescope/dependency.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/telescope/dependency.go b/telescope/dependency.go index 0f07e77..01d4129 100644 --- a/telescope/dependency.go +++ b/telescope/dependency.go @@ -49,8 +49,11 @@ func NewSematicVersion(version string, strict bool) (*semver.Version, error) { // truncate rc, alpha, and beta flags return strings.ContainsRune("rc a b", r) }, - )[0] - return semver.NewVersion(truncatedVersion) + ) + if len(truncatedVersion) == 0 { + return nil, fmt.Errorf("invalid version string %s", version) + } + return semver.NewVersion(truncatedVersion[0]) } func NewDependency(name, version string, strictSemVer bool) IDependable { From 9e4069dcdf50fc68c48395e0b6d079ea4853d7dc Mon Sep 17 00:00:00 2001 From: RainrainWu Date: Thu, 1 Dec 2022 22:33:12 +0800 Subject: [PATCH 14/16] Update pull_request.yml --- .github/workflows/pull_request.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 116a83b..df2d4e4 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -26,9 +26,9 @@ jobs: container: image: r41nwu/telescope:latest volumes: - - ${{ github.workspace }}/go.mod:/go.mod + - ${{ github.workspace }}:/src steps: - name: Scan Outdated Dependencies run: | - telescope --strict-semver + telescope -f "/src/go.mod" --strict-semver From 081d2bb38af6f0f01626024a7ada1715c0993e0d Mon Sep 17 00:00:00 2001 From: RainrainWu Date: Thu, 1 Dec 2022 22:35:17 +0800 Subject: [PATCH 15/16] Update pull_request.yml --- .github/workflows/pull_request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index df2d4e4..d4c3636 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -26,7 +26,7 @@ jobs: container: image: r41nwu/telescope:latest volumes: - - ${{ github.workspace }}:/src + - ${{ github.workspace }}/go.mod:/src/go.mod steps: - name: Scan Outdated Dependencies From 4a7c2f3df9d57b021e79013c920c29d0bfa25e88 Mon Sep 17 00:00:00 2001 From: RainrainWu Date: Thu, 1 Dec 2022 22:40:34 +0800 Subject: [PATCH 16/16] Update pull_request.yml --- .github/workflows/pull_request.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index d4c3636..455df71 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -20,15 +20,3 @@ jobs: - name: Build run: make build - - scan: - runs-on: ubuntu-latest - container: - image: r41nwu/telescope:latest - volumes: - - ${{ github.workspace }}/go.mod:/src/go.mod - - steps: - - name: Scan Outdated Dependencies - run: | - telescope -f "/src/go.mod" --strict-semver