-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0a4f306
Showing
91 changed files
with
7,213 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
|
||
- package-ecosystem: "gomod" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: ci | ||
|
||
on: | ||
push: | ||
branches: | ||
- "*" | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
ci: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: '^1.21' | ||
|
||
- run: go mod download -x | ||
- run: make release | ||
env: | ||
GH_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea/ | ||
.build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 octohelm | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
PIPER = go run ./cmd/piper | ||
|
||
DEBUG = 0 | ||
ifeq ($(DEBUG),1) | ||
PIPER := $(PIPER) --log-level=debug | ||
endif | ||
|
||
build: | ||
$(PIPER) do go build | ||
|
||
archive: | ||
$(PIPER) do go archive | ||
|
||
release: | ||
$(PIPER) do release | ||
|
||
gen: | ||
go run ./internal/cmd/tool gen ./cmd/piper | ||
|
||
install: | ||
go install ./cmd/piper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Piper | ||
|
||
Similar as [`cue/tool`](https://pkg.go.dev/cuelang.org/go/pkg/tool), but not just on current host. | ||
|
||
## Install | ||
|
||
```shell | ||
curl -sSLf https://raw.githubusercontent.com/octohelm/piper/main/install.sh | sudo sh | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/innoai-tech/infra/pkg/cli" | ||
"github.com/octohelm/piper/pkg/engine" | ||
) | ||
|
||
func init() { | ||
cli.AddTo(App, &Do{}) | ||
} | ||
|
||
type Do struct { | ||
cli.C | ||
engine.Logger | ||
engine.Pipeline | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"os" | ||
|
||
"github.com/innoai-tech/infra/pkg/cli" | ||
|
||
"github.com/octohelm/piper/internal/version" | ||
) | ||
|
||
var App = cli.NewApp("piper", version.Version()) | ||
|
||
func main() { | ||
if err := cli.Execute(context.Background(), App, os.Args[1:]); err != nil { | ||
os.Exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Package main GENERATED BY gengo:runtimedoc | ||
DON'T EDIT THIS FILE | ||
*/ | ||
package main | ||
|
||
// nolint:deadcode,unused | ||
func runtimeDoc(v any, names ...string) ([]string, bool) { | ||
if c, ok := v.(interface { | ||
RuntimeDoc(names ...string) ([]string, bool) | ||
}); ok { | ||
return c.RuntimeDoc(names...) | ||
} | ||
return nil, false | ||
} | ||
|
||
func (v Do) RuntimeDoc(names ...string) ([]string, bool) { | ||
if len(names) > 0 { | ||
switch names[0] { | ||
case "Logger": | ||
return []string{}, true | ||
case "Pipeline": | ||
return []string{}, true | ||
|
||
} | ||
if doc, ok := runtimeDoc(v.Logger, names...); ok { | ||
return doc, ok | ||
} | ||
if doc, ok := runtimeDoc(v.Pipeline, names...); ok { | ||
return doc, ok | ||
} | ||
|
||
return nil, false | ||
} | ||
return []string{}, true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
gen/ | ||
pkg/ | ||
module.sum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module: "github.com/octohelm/piper" | ||
|
||
require: { | ||
"piper.octohelm.tech": "v0.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
package github | ||
|
||
import ( | ||
"path" | ||
"strings" | ||
"strconv" | ||
"encoding/json" | ||
|
||
"piper.octohelm.tech/http" | ||
"piper.octohelm.tech/file" | ||
"piper.octohelm.tech/client" | ||
"piper.octohelm.tech/flow" | ||
) | ||
|
||
#GithubAPI: { | ||
core: "https://api.github.com" | ||
uploads: "https://uploads.github.com" | ||
} | ||
|
||
#Release: { | ||
token: client.#Secret | ||
|
||
owner: string | ||
repo: string | ||
|
||
name: string | *"latest" | ||
notes: string | *"" | ||
prerelease: bool | *true | ||
draft: bool | *false | ||
|
||
assets: [...file.#File] | ||
|
||
_client: #Client & {"token": token} | ||
|
||
_get_or_create_release: { | ||
_ret: flow.#Some & { | ||
steps: [ | ||
_client.#Do & { | ||
method: "GET" | ||
url: "\(#GithubAPI.core)/repos/\(owner)/\(repo)/releases/tags/\(name)" | ||
}, | ||
_client.#Do & { | ||
"method": "POST" | ||
"url": "\(#GithubAPI.core)/repos/\(owner)/\(repo)/releases" | ||
"header": { | ||
"Content-Type": "application/json" | ||
} | ||
"body": json.Marshal({ | ||
"tag_name": name | ||
"name": name | ||
"body": notes | ||
"prerelease": prerelease | ||
"draft": draft | ||
}) | ||
}, | ||
] | ||
} | ||
|
||
id: _ret.result.data.id | ||
} | ||
|
||
_list_assets: { | ||
_req: _client.#Do & { | ||
method: "GET" | ||
url: "\(#GithubAPI.core)/repos/\(owner)/\(repo)/releases/\(_get_or_create_release.id)/assets" | ||
} | ||
|
||
assets: { | ||
for asset in _req.result.data { | ||
"\(asset.name)": strconv.FormatFloat(asset.id, strings.ByteAt("f", 0), 0, 64) | ||
} | ||
} | ||
} | ||
|
||
_upload_assets: flow.#Every & { | ||
steps: [ | ||
for f in assets { | ||
let assetName = path.Base(f.filename) | ||
|
||
flow.#Every & { | ||
steps: [ | ||
// if asset name exists, delete first | ||
if _list_assets.assets[assetName] != _|_ { | ||
_client.#Do & { | ||
"method": "DELETE" | ||
"url": "\(#GithubAPI.core)/repos/\(owner)/\(repo)/releases/assets/\(_list_assets.assets[assetName])" | ||
} | ||
}, | ||
// then upload | ||
_client.#Do & { | ||
"method": "POST" | ||
"url": "\(#GithubAPI.uploads)/repos/\(owner)/\(repo)/releases/\(_get_or_create_release.id)/assets" | ||
"header": { | ||
"Content-Type": "application/octet-stream" | ||
} | ||
"query": { | ||
"name": "\(assetName)" | ||
} | ||
"body": f | ||
}, | ||
] | ||
} | ||
}, | ||
] | ||
} | ||
result: _upload_assets.result | ||
} | ||
|
||
#Client: { | ||
token: client.#Secret | ||
|
||
_token: client.#ReadSecret & { | ||
secret: token | ||
} | ||
|
||
#Do: { | ||
method: string | ||
url: string | ||
body?: file.#StringOrFile | ||
header: [Name=string]: string | [...string] | ||
query: [Name=string]: string | [...string] | ||
|
||
_default_header: { | ||
"Accept": "application/vnd.github+json" | ||
"Authorization": "Bearer \(_token.value)" | ||
"X-GitHub-Api-Version": "2022-11-28" | ||
} | ||
|
||
_req: http.#Do & { | ||
"method": method | ||
"url": url | ||
"header": { | ||
for k, vv in header { | ||
"\(k)": vv | ||
} | ||
for k, vv in _default_header if header[k] == _|_ { | ||
"\(k)": vv | ||
} | ||
} | ||
"query": query | ||
if body != _|_ { | ||
"body": body | ||
} | ||
} | ||
|
||
result: _req.result | ||
} | ||
} |
Oops, something went wrong.