Skip to content

Commit 3990342

Browse files
Merge pull request #2 from javaBin/feat/rename-register-team
updated to match new format
2 parents 702619a + 33803d8 commit 3990342

File tree

4 files changed

+64
-22
lines changed

4 files changed

+64
-22
lines changed

.github/workflows/release.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- uses: actions/setup-go@v5
20+
with:
21+
go-version-file: go.mod
22+
23+
- uses: goreleaser/goreleaser-action@v6
24+
with:
25+
version: latest
26+
args: release --clean
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

cmd/init.go

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package cmd
22

33
import (
44
"bufio"
5+
"encoding/json"
56
"fmt"
7+
"net/http"
68
"os"
79
"os/exec"
810
"path/filepath"
@@ -18,7 +20,7 @@ const templateRepo = "app-template"
1820
var initCmd = &cobra.Command{
1921
Use: "init",
2022
Short: "Scaffold a new app repo from the Javabin app template",
21-
Long: "Interactive wizard that creates a new repo under javaBin/ from the app-template, customizes it for your runtime, and optionally registers it with the platform.",
23+
Long: "Interactive wizard that creates a new repo under javaBin/ from the app-template and customizes it for your runtime.",
2224
RunE: runInit,
2325
}
2426

@@ -265,26 +267,38 @@ jobs:
265267
}
266268
fmt.Println("done")
267269

268-
// Optionally register
269-
doRegister := prompt("\nRegister with platform now? (y/n)", "y")
270-
if strings.ToLower(doRegister) == "y" {
271-
filePath := fmt.Sprintf("apps/%s.yaml", name)
272-
branchName := fmt.Sprintf("register-%s", name)
273-
prTitle := fmt.Sprintf("Register %s", name)
274-
prBody := fmt.Sprintf("Register `javaBin/%s` with team `%s`.\n\nCreated by `javabin init`.", name, team)
275-
regYaml := fmt.Sprintf("name: %s\nteam: %s\nrepo: javaBin/%s\n", name, team, name)
276-
277-
prURL, err := gh.CreateRegistrationPR(token, branchName, filePath, regYaml, prTitle, prBody)
278-
if err != nil {
279-
fmt.Printf(" Could not create registration PR: %v\n", err)
280-
fmt.Println(" You can register later with: javabin register")
281-
} else {
282-
fmt.Printf(" Registration PR: %s\n", prURL)
283-
}
284-
}
285-
286270
fmt.Printf("\nRepo ready: https://github.com/javaBin/%s\n", name)
287-
fmt.Printf("Next: cd %s && start coding!\n", name)
271+
fmt.Println("\nNext steps:")
272+
fmt.Println(" 1. Add this repo to your GitHub team:")
273+
fmt.Printf(" gh api orgs/javaBin/teams/%s/repos -f owner=javaBin -f repo=%s -f permission=push\n", team, name)
274+
fmt.Println(" 2. Push to main — the platform CI takes over")
288275

289276
return nil
290277
}
278+
279+
func listTeams(token string) ([]string, error) {
280+
url := "https://api.github.com/repos/javaBin/registry/contents/teams"
281+
req, _ := http.NewRequest("GET", url, nil)
282+
req.Header.Set("Authorization", "Bearer "+token)
283+
resp, err := http.DefaultClient.Do(req)
284+
if err != nil {
285+
return nil, err
286+
}
287+
defer resp.Body.Close()
288+
if resp.StatusCode != 200 {
289+
return nil, fmt.Errorf("HTTP %d", resp.StatusCode)
290+
}
291+
var items []struct {
292+
Name string `json:"name"`
293+
}
294+
if err := json.NewDecoder(resp.Body).Decode(&items); err != nil {
295+
return nil, err
296+
}
297+
var teams []string
298+
for _, item := range items {
299+
if strings.HasSuffix(item.Name, ".yaml") {
300+
teams = append(teams, strings.TrimSuffix(item.Name, ".yaml"))
301+
}
302+
}
303+
return teams, nil
304+
}

internal/github/github.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ func CreateRegistrationPR(token, branch, filePath, content, title, body string)
5353
return "", fmt.Errorf("create branch: %w", err)
5454
}
5555

56-
// Create/update file on branch
57-
if err := createFile(token, branch, filePath, content, "Register "+strings.TrimPrefix(filePath, "apps/")); err != nil {
56+
// Create/update file on branch — use PR title as commit message
57+
if err := createFile(token, branch, filePath, content, title); err != nil {
5858
return "", fmt.Errorf("create file: %w", err)
5959
}
6060

javabin

15.3 MB
Binary file not shown.

0 commit comments

Comments
 (0)