Skip to content

Commit 4e43959

Browse files
feat: added upgrade command, and release
1 parent 54dafac commit 4e43959

9 files changed

Lines changed: 746 additions & 4 deletions

File tree

.github/workflows/nightly.yaml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: nightly
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *"
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
name: build (${{ matrix.goos }}-${{ matrix.goarch }})
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
include:
18+
- goos: darwin
19+
goarch: arm64
20+
- goos: darwin
21+
goarch: amd64
22+
- goos: linux
23+
goarch: amd64
24+
- goos: linux
25+
goarch: arm64
26+
- goos: windows
27+
goarch: amd64
28+
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- uses: actions/setup-go@v5
33+
with:
34+
go-version-file: go.mod
35+
cache: true
36+
37+
- name: Build
38+
env:
39+
GOOS: ${{ matrix.goos }}
40+
GOARCH: ${{ matrix.goarch }}
41+
CGO_ENABLED: "0"
42+
run: |
43+
VERSION="nightly-$(date -u +%Y-%m-%d)"
44+
PKG="github.com/NodeOps-app/createos-cli/internal/pkg/version"
45+
CFG="github.com/NodeOps-app/createos-cli/internal/config"
46+
LDFLAGS="-s -w -X ${PKG}.Version=${VERSION} -X ${PKG}.Channel=nightly -X ${CFG}.OAuthClientID=${{ secrets.OAUTH_CLIENT_ID }}"
47+
48+
if [ "${{ matrix.goos }}" = "windows" ]; then
49+
BINARY="createos-${{ matrix.goos }}-${{ matrix.goarch }}.exe"
50+
else
51+
BINARY="createos-${{ matrix.goos }}-${{ matrix.goarch }}"
52+
fi
53+
54+
go build -trimpath -ldflags="${LDFLAGS}" -o "${BINARY}" .
55+
sha256sum "${BINARY}" | awk '{print $1}' > "${BINARY}.sha256"
56+
57+
- uses: actions/upload-artifact@v4
58+
with:
59+
name: binary-${{ matrix.goos }}-${{ matrix.goarch }}
60+
path: createos-*
61+
retention-days: 1
62+
63+
release:
64+
needs: build
65+
runs-on: ubuntu-latest
66+
steps:
67+
- uses: actions/download-artifact@v4
68+
with:
69+
pattern: binary-*
70+
merge-multiple: true
71+
72+
- name: Delete existing nightly release
73+
env:
74+
GH_TOKEN: ${{ github.token }}
75+
run: |
76+
gh release delete nightly --repo ${{ github.repository }} --yes || true
77+
git push --delete origin nightly || true
78+
shell: bash
79+
80+
- name: Create nightly release
81+
uses: softprops/action-gh-release@v2
82+
with:
83+
tag_name: nightly
84+
name: "nightly ($(date -u +%Y-%m-%d))"
85+
prerelease: true
86+
body: "Automated nightly build from the latest commit on main."
87+
files: createos-*

.github/workflows/release.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
name: build (${{ matrix.goos }}-${{ matrix.goarch }})
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
include:
18+
- goos: darwin
19+
goarch: arm64
20+
- goos: darwin
21+
goarch: amd64
22+
- goos: linux
23+
goarch: amd64
24+
- goos: linux
25+
goarch: arm64
26+
- goos: windows
27+
goarch: amd64
28+
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- uses: actions/setup-go@v5
33+
with:
34+
go-version-file: go.mod
35+
cache: true
36+
37+
- name: Build
38+
env:
39+
GOOS: ${{ matrix.goos }}
40+
GOARCH: ${{ matrix.goarch }}
41+
CGO_ENABLED: "0"
42+
run: |
43+
VERSION="${{ github.ref_name }}"
44+
PKG="github.com/NodeOps-app/createos-cli/internal/pkg/version"
45+
CFG="github.com/NodeOps-app/createos-cli/internal/config"
46+
LDFLAGS="-s -w -X ${PKG}.Version=${VERSION} -X ${PKG}.Channel=stable -X ${CFG}.OAuthClientID=${{ secrets.OAUTH_CLIENT_ID }}"
47+
48+
if [ "${{ matrix.goos }}" = "windows" ]; then
49+
BINARY="createos-${{ matrix.goos }}-${{ matrix.goarch }}.exe"
50+
else
51+
BINARY="createos-${{ matrix.goos }}-${{ matrix.goarch }}"
52+
fi
53+
54+
go build -trimpath -ldflags="${LDFLAGS}" -o "${BINARY}" .
55+
sha256sum "${BINARY}" | awk '{print $1}' > "${BINARY}.sha256"
56+
57+
- uses: actions/upload-artifact@v4
58+
with:
59+
name: binary-${{ matrix.goos }}-${{ matrix.goarch }}
60+
path: createos-*
61+
retention-days: 1
62+
63+
release:
64+
needs: build
65+
runs-on: ubuntu-latest
66+
steps:
67+
- uses: actions/download-artifact@v4
68+
with:
69+
pattern: binary-*
70+
merge-multiple: true
71+
72+
- name: Create GitHub Release
73+
uses: softprops/action-gh-release@v2
74+
with:
75+
tag_name: ${{ github.ref_name }}
76+
name: ${{ github.ref_name }}
77+
generate_release_notes: true
78+
files: createos-*

cmd/root/root.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/NodeOps-app/createos-cli/cmd/skills"
2424
"github.com/NodeOps-app/createos-cli/cmd/status"
2525
"github.com/NodeOps-app/createos-cli/cmd/templates"
26+
"github.com/NodeOps-app/createos-cli/cmd/upgrade"
2627
"github.com/NodeOps-app/createos-cli/cmd/users"
2728
versioncmd "github.com/NodeOps-app/createos-cli/cmd/version"
2829
"github.com/NodeOps-app/createos-cli/cmd/vms"
@@ -81,7 +82,7 @@ func NewApp() *cli.App {
8182
}
8283

8384
cmd := c.Args().First()
84-
if cmd == "" || cmd == "login" || cmd == "logout" || cmd == "version" || cmd == "ask" || cmd == "init" {
85+
if cmd == "" || cmd == "login" || cmd == "logout" || cmd == "version" || cmd == "ask" || cmd == "init" || cmd == "upgrade" {
8586
return nil
8687
}
8788

@@ -158,6 +159,7 @@ func NewApp() *cli.App {
158159
fmt.Println(" login Authenticate with CreateOS")
159160
}
160161
fmt.Println(" ask Ask the AI assistant to help manage your infrastructure")
162+
fmt.Println(" upgrade Upgrade createos to the latest version")
161163
fmt.Println(" version Print the current version")
162164
fmt.Println()
163165
fmt.Println("Global Flags:")
@@ -185,6 +187,7 @@ func NewApp() *cli.App {
185187
skills.NewSkillsCommand(),
186188
status.NewStatusCommand(),
187189
templates.NewTemplatesCommand(),
190+
upgrade.NewUpgradeCommand(),
188191
users.NewUsersCommand(),
189192
vms.NewVMsCommand(),
190193
auth.NewWhoamiCommand(),

0 commit comments

Comments
 (0)