Compare commits
No commits in common. "088fdf16d9181aa84409a5fe5d37a04ffe868aef" and "14c175d7af6d97182e64889b466ff52661438073" have entirely different histories.
088fdf16d9
...
14c175d7af
|
@ -1,5 +0,0 @@
|
||||||
FROM alpine
|
|
||||||
ADD aptly-publisher /bin/
|
|
||||||
RUN chmod +x /bin/aptly-publisher
|
|
||||||
RUN apk -Uuv add ca-certificates libc6-compat
|
|
||||||
ENTRYPOINT /bin/aptly-publisher
|
|
BIN
aptly-publisher
BIN
aptly-publisher
Binary file not shown.
7
go.mod
7
go.mod
|
@ -1,7 +0,0 @@
|
||||||
module aptly-publisher
|
|
||||||
|
|
||||||
go 1.18
|
|
||||||
|
|
||||||
require github.com/go-resty/resty/v2 v2.7.0
|
|
||||||
|
|
||||||
require golang.org/x/net v0.0.0-20211029224645-99673261e6eb // indirect
|
|
69
main.go
69
main.go
|
@ -1,69 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
const APT_SERVICE_API = "https://apt.lumeweb.com"
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
err := run()
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("%s", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func run() error {
|
|
||||||
client := resty.New()
|
|
||||||
files, _ := filepath.Glob("*.deb")
|
|
||||||
pkg := files[0]
|
|
||||||
pkg_name := strings.TrimSuffix(pkg, filepath.Ext(pkg))
|
|
||||||
pkg_parts := strings.Split(pkg_name, "_")
|
|
||||||
pkg_parts = pkg_parts[:len(pkg_parts)-1]
|
|
||||||
pkg_name = strings.Join(pkg_parts, "-")
|
|
||||||
|
|
||||||
repo := os.Getenv("PLUGIN_REPO")
|
|
||||||
gpg_pass := os.Getenv("PLUGIN_GPG_PASSWORD")
|
|
||||||
distro := os.Getenv("PLUGIN_DISTRO")
|
|
||||||
folder := os.Getenv("PLUGIN_FOLDER")
|
|
||||||
|
|
||||||
client.SetBasicAuth(os.Getenv("PLUGIN_APT_USERNAME"), os.Getenv("PLUGIN_APT_PASSWORD")).SetBaseURL(APT_SERVICE_API)
|
|
||||||
|
|
||||||
resp, err := client.R().
|
|
||||||
SetFile("file", pkg).
|
|
||||||
Post("/api/files/" + pkg_name)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err = client.R().
|
|
||||||
Post("/api/repos/" + repo + "/file/" + pkg_name)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
resp, err = client.R().
|
|
||||||
SetBody(map[string]interface{}{
|
|
||||||
"Architectures": []string{"amd64"},
|
|
||||||
"Passphrase": gpg_pass,
|
|
||||||
"SourceKind": "local",
|
|
||||||
"Signing": map[string]interface{}{
|
|
||||||
"Batch": true,
|
|
||||||
"Passphrase": gpg_pass,
|
|
||||||
},
|
|
||||||
}).
|
|
||||||
Put(fmt.Sprintf("/api/publish/s3:%s:%s/%s", repo, folder, distro))
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
_ = resp
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
Loading…
Reference in New Issue