Skip to content

Commit

Permalink
feat: add prompts for os & arch
Browse files Browse the repository at this point in the history
refactor: refactor pkg go code
ci: fix docker publish workflow
docs: move doc.go
build: upgrade go to latest
test: update the unit tests to accomodate the updated pkg code
  • Loading branch information
Nicconike committed Oct 15, 2024
1 parent 2756354 commit c47987b
Show file tree
Hide file tree
Showing 15 changed files with 334 additions and 151 deletions.
26 changes: 26 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ updates:
labels:
- dependencies
- dependabot
- go
rebase-strategy: auto
open-pull-requests-limit: 10
groups:
gomod:
patterns:
- "*"
reviewers:
- "nicconike"

Expand All @@ -24,6 +29,7 @@ updates:
labels:
- dependencies
- dependabot
- github_actions
rebase-strategy: auto
open-pull-requests-limit: 10
reviewers:
Expand All @@ -32,3 +38,23 @@ updates:
github-actions:
patterns:
- "*"

- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "build"
include: "scope"
labels:
- dependencies
- dependabot
- docker
rebase-strategy: auto
open-pull-requests-limit: 10
groups:
docker:
patterns:
- "*"
reviewers:
- "nicconike"
35 changes: 27 additions & 8 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Publish Packages

on:
push:
branches: master
paths:
- '.github/workflows/docker.yml'
tags:
Expand Down Expand Up @@ -34,7 +35,7 @@ jobs:
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@v3.7.0
uses: sigstore/cosign-installer@v3.6.0
with:
cosign-release: 'v2.4.0'

Expand Down Expand Up @@ -62,10 +63,10 @@ jobs:
${{ vars.DOCKER_USERNAME }}/automatedgo
ghcr.io/${{ github.repository_owner }}/AutomatedGo
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
skip-sha: true
- name: Build & Push Docker Images
id: push
Expand Down Expand Up @@ -98,8 +99,26 @@ jobs:
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

- name: Docker Scout Scan
uses: docker/[email protected]
with:
command: quickview, cves
image: ${{ vars.DOCKER_USERNAME }}/automatedgo:${{ steps.meta.outputs.tags }}
to: ${{ vars.DOCKER_USERNAME }}/automatedgo:master
write-comment: true
github-token: ${{ secrets.GITHUB_TOKEN }}
sarif-file: docker-scout-results.sarif

- name: Upload Scout Scan Results
if: always()
uses: actions/upload-artifact@v4
with:
name: docker-scout-results
path: docker-scout-results.sarif

cleanup:
runs-on: ubuntu-latest
name: Cleanup
needs: packages
permissions:
contents: read
Expand Down Expand Up @@ -127,13 +146,13 @@ jobs:
tags=$(curl -s "https://hub.docker.com/v2/repositories/${{ vars.DOCKER_USERNAME }}/automatedgo/tags" | jq -r '.results[].name')
echo "Tags found in Docker Hub:"
echo "$tags"
latest_tag=$(echo "$tags" | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -rV | head -n 1)
echo "Latest semantic version tag is $latest_tag"
for tag in $tags; do
if [[ ! "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ || "$tag" != "$latest_tag" ]]; then
if [[ "$tag" != "master" && ! "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Deleting tag $tag from Docker Hub"
curl -X DELETE "https://hub.docker.com/v2/repositories/${{ vars.DOCKER_USERNAME }}/automatedgo/tags/$tag/" \
-u "${{ vars.DOCKER_USERNAME }}:${{ secrets.DOCKER_TOKEN }}"
else
echo "Keeping tag $tag"
fi
done
Expand All @@ -145,12 +164,12 @@ jobs:
tags=$(gh api "repos/${{ github.repository_owner }}/packages/container/automatedgo/versions" | jq -r '.[].metadata.container.tags[]')
echo "Tags found in GHCR:"
echo "$tags"
latest_tag=$(echo "$tags" | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -rV | head -n 1)
echo "Latest semantic version tag is $latest_tag"
for tag in $tags; do
if [[ ! "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ || "$tag" != "$latest_tag" ]]; then
if [[ "$tag" != "master" && ! "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Deleting tag $tag from GHCR"
version_id=$(gh api "repos/${{ github.repository_owner }}/packages/container/automatedgo/versions" | jq -r ".[] | select(.metadata.container.tags[] == \"$tag\") | .id")
gh api --method DELETE "/user/packages/container/automatedgo/versions/$version_id"
else
echo "Keeping tag $tag"
fi
done
7 changes: 7 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@ output:
linters:
enable:
- errcheck
- gofmt
- staticcheck
- go_vet
- gocyclo
- ineffassign
- license
- misspell
7 changes: 5 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ archives:
format: zip

changelog:
disable: true
use: github
filters:
exclude:
- "^chore:"

release:
github:
Expand All @@ -29,7 +32,7 @@ release:
footer: |
## How to install
```
go get -u github.com/Nicconike/AutomatedGo
go install github.com/Nicconike/AutomatedGo/v2/cmd/[email protected]
```
For more information, please refer to the [documentation](https://github.com/Nicconike/AutomatedGo#readme).
Expand Down
61 changes: 61 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,59 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).

## 2.0.3 (2024-10-01)

#### 🐞 Bug Fixes

* update import paths for the Go code (49eb11f0)

#### 🔁 CI

* update index pkg.go.dev step (4857baec)

## 2.0.2 (2024-10-01)

#### 🐞 Bug Fixes

* update downloader code to correctly compile the filename (becbc2dc)

#### 📄 Documentation

* update readme (1d918457)

#### 🔎 Tests

* debug extracted tags & cleanup (ce8526b7)
* err check (eee63198)

#### 🔀 Code Refactoring

* add service.go (311148ad)

#### 🚧 Chores

* **deps:** bump github.com/schollz/progressbar/v3 (#6) (e7cd015a)
* **deps:** bump github.com/stretchr/testify from 1.5.1 to 1.9.0 (#5) (f5b5f3b9)

#### 🔁 CI

* fix credentials usage (b7f4ecfd)
* Update docker.yml (986e999c)
* update metadata tags (535f013a)
* update docker metadata tags (6b256d12)

## What's Changed
* **Update module path to v2 and fix import statements for v2.0.2**

## 2.0.1 (2024-09-19)

#### 🐞 Bug Fixes

* correct the unit tests code (203b7b7d)

## What's Changed
* **Update module path to v2 and fix import statements for v2.0.1**

## 2.0.0 (2024-09-19)

#### 📣 Breaking Changes
Expand Down Expand Up @@ -44,6 +97,14 @@ BREAKING CHANGE: Interfaces Implementation and now prompt for download with path
* update codeql for go (ad7cdb2b)
* Create codeql.yml (7682fcf1)

## What's Changed
* **Update module path to v2 and fix import statements for v2.0.0**
* ci: bump golangci/golangci-lint-action from 3 to 6 in the github-actions group by @dependabot in https://github.com/Nicconike/AutomatedGo/pull/3
* chore(deps): bump github.com/schollz/progressbar/v3 from 3.14.6 to 3.15.0 by @dependabot in https://github.com/Nicconike/AutomatedGo/pull/4


**Full Changelog**: https://github.com/Nicconike/AutomatedGo/compare/v1.2.0...v2.0.0


## 1.2.0 (2024-09-12)

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![codecov](https://codecov.io/gh/Nicconike/AutomatedGo/graph/badge.svg?token=MPIX1QLEYJ)](https://codecov.io/gh/Nicconike/AutomatedGo)
![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/nicconike/AutomatedGo)
![GitHub Release](https://img.shields.io/github/v/release/nicconike/AutomatedGo)
![Docker Image Size](https://img.shields.io/docker/image-size/nicconike/automatedgo?logo=docker&label=Docker%20Image)
![Docker Image Size](https://img.shields.io/docker/image-size/nicconike/automatedgo/master?sort=semver&logo=docker&label=Docker%20Image)
![Docker Pulls](https://img.shields.io/docker/pulls/nicconike/automatedgo?logo=docker&label=Docker%20Pulls)
[![Go Reference](https://pkg.go.dev/badge/github.com/Nicconike/AutomatedGo.svg)](https://pkg.go.dev/github.com/Nicconike/AutomatedGo)
![GitHub License](https://img.shields.io/github/license/nicconike/AutomatedGo)
Expand All @@ -28,7 +28,7 @@

To add **AutomatedGo** in your Go project, use the following command:
```sh
go get -u github.com/Nicconike/AutomatedGo
go get -u github.com/Nicconike/AutomatedGo/v2
```

To install **AutomatedGo** as a Go binary, use the following command:
Expand All @@ -49,7 +49,7 @@ This will check the specified file for the current Go version, compare it with t
> [!NOTE]
> If you don't specify the `os` and `arch` type, the tool will download the latest version for your current operating system and architecture.
>
> Minimum required Go version: 1.18
> Minimum required Go version: 1.22
### Command-line Options

Expand Down
2 changes: 1 addition & 1 deletion docs/doc.go → doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ Functions:
Calculates the SHA256 checksum of the specified file.
For more detailed information and advanced usage, refer to the README.md file
and the package documentation at https://pkg.go.dev/github.com/Nicconike/AutomatedGo.
and the package documentation at https://pkg.go.dev/github.com/Nicconike/AutomatedGo/v2.
*/
package AutomatedGo
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/Nicconike/AutomatedGo/v2

go 1.18
go 1.22

require (
github.com/schollz/progressbar/v3 v3.16.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
github.com/chengxilo/virtualterm v1.0.4 h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7mk9/PwM=
github.com/chengxilo/virtualterm v1.0.4/go.mod h1:DyxxBZz/x1iqJjFxTFcr6/x+jSpqN0iwWCOK1q10rlY=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ=
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down
Loading

0 comments on commit c47987b

Please sign in to comment.