diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..57a7cabf --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,41 @@ +name: Build Docker Images + +on: + push: + branches: + - main + workflow_dispatch: + schedule: + - cron: "0 0 * * *" + +jobs: + Dockerhub: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: checkout sources + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + push: true + platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 + tags: | + ghcr.io/firefart/hijagger:latest diff --git a/go.mod b/go.mod index 4884f7a5..a512eaae 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/firefart/hijagger -go 1.19 +go 1.21 require ( github.com/jpillora/go-tld v1.2.1 diff --git a/helper.go b/helper.go index 1283c491..a71297b9 100644 --- a/helper.go +++ b/helper.go @@ -15,13 +15,3 @@ func getRootDomain(domain string) (string, error) { rootDomain := fmt.Sprintf("%s.%s", u.Domain, u.TLD) return rootDomain, nil } - -func keysFromMap[V any](m map[string]V) []string { - ret := make([]string, len(m)) - i := 0 - for k := range m { - ret[i] = k - i += 1 - } - return ret -} diff --git a/npm.go b/npm.go index 8c7834f8..447f6a65 100644 --- a/npm.go +++ b/npm.go @@ -5,6 +5,8 @@ import ( "fmt" "net/mail" "os" + + "golang.org/x/exp/maps" ) type npmAll struct { @@ -68,7 +70,7 @@ func (a *app) npmGetPackageMaintainer(name string) ([]string, error) { } } - return keysFromMap(maintainers), nil + return maps.Keys(maintainers), nil } func (a *app) npmGetAllPackageNames(local string) ([]string, error) { diff --git a/pypi.go b/pypi.go index 1a23a641..4d985250 100644 --- a/pypi.go +++ b/pypi.go @@ -6,6 +6,8 @@ import ( "net/mail" "regexp" "strings" + + "golang.org/x/exp/maps" ) func (a *app) pypiGetAllPackageNames(local string) ([]string, error) { @@ -66,7 +68,7 @@ func (a *app) pypiGetPackageMaintainer(name string) ([]string, error) { } } - return keysFromMap(maintainers), nil + return maps.Keys(maintainers), nil } func getPypiLink(name string) string {