Skip to content

Commit

Permalink
Release GitHub Actions (#24)
Browse files Browse the repository at this point in the history
* Create tag.yml

Signed-off-by: Rain Wu <[email protected]>
  • Loading branch information
RainrainWu authored Dec 1, 2022
1 parent e270c01 commit 58d1fae
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Dockerized CI
name: Pull Request

on:
push:
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -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 }}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
7 changes: 5 additions & 2 deletions telescope/dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 58d1fae

Please sign in to comment.