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: diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml new file mode 100644 index 0000000..0b7d7d1 --- /dev/null +++ b/.github/workflows/tag.yml @@ -0,0 +1,61 @@ +name: Release Tags + +on: + push: + tags: [ "v*" ] + +jobs: + + release-dockerhub: + + runs-on: ubuntu-latest + 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 to docker.io + run: docker login -u r41nwu -p ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} + + - name: Build and publish image + uses: docker/build-push-action@v3 + with: + context: . + file: "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 }} diff --git a/Dockerfile b/Dockerfile index a9f98a6..4fbbfea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,9 +5,9 @@ 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=/ +ENV PATH=$PATH:/ COPY --from=builder /src/bin/ / COPY --from=builder /etc/ssl/certs /etc/ssl/certs 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() { 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 {