Skip to content

Commit b893201

Browse files
committed
v0.0.22: windows msi & chocolatey support
1 parent f26a350 commit b893201

File tree

46 files changed

+992
-97
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+992
-97
lines changed

.github/workflows/release.yml

Lines changed: 108 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,70 @@ name: Release
33
concurrency: release
44

55
on:
6+
workflow_dispatch:
67
push:
7-
branches:
8-
- main
8+
tags: ["v*"]
9+
10+
permissions:
11+
contents: write
12+
packages: write
13+
id-token: write
914

1015
jobs:
16+
prepare:
17+
strategy:
18+
matrix:
19+
os: [ubuntu-latest, macos-latest, windows-latest]
20+
runs-on: ${{ matrix.os }}
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
with:
25+
fetch-depth: 0
26+
- name: Set up Go
27+
uses: actions/setup-go@v4
28+
with:
29+
go-version-file: go.mod
30+
- shell: bash
31+
run: |
32+
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
33+
- uses: actions/cache@v4
34+
if: matrix.os == 'ubuntu-latest'
35+
with:
36+
path: cmd/anchor/dist/linux
37+
key: linux-${{ env.sha_short }}
38+
- uses: actions/cache@v4
39+
if: matrix.os == 'macos-latest'
40+
with:
41+
path: cmd/anchor/dist/darwin
42+
key: darwin-${{ env.sha_short }}
43+
- uses: actions/cache@v4
44+
if: matrix.os == 'windows-latest'
45+
with:
46+
path: cmd/anchor/dist/windows
47+
key: windows-${{ env.sha_short }}
48+
enableCrossOsArchive: true
49+
- name: non-windows flags
50+
if: matrix.os != 'windows-latest'
51+
shell: bash
52+
run: echo 'flags=--skip chocolatey' >> $GITHUB_ENV
53+
- name: windows flags
54+
if: matrix.os == 'windows-latest'
55+
shell: bash
56+
run: echo 'flags=--skip homebrew' >> $GITHUB_ENV
57+
- name: Run GoReleaser
58+
uses: goreleaser/goreleaser-action@v4
59+
with:
60+
distribution: goreleaser-pro
61+
version: latest
62+
args: release --clean --split ${{ env.flags }}
63+
workdir: cmd/anchor
64+
env:
65+
GITHUB_TOKEN: ${{ secrets._GITHUB_TOKEN }}
66+
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
1167
release:
1268
runs-on: ubuntu-latest
69+
needs: prepare
1370
steps:
1471
- name: Checkout
1572
uses: actions/checkout@v3
@@ -19,13 +76,61 @@ jobs:
1976
uses: actions/setup-go@v4
2077
with:
2178
go-version-file: go.mod
79+
80+
# Copy Caches
81+
- shell: bash
82+
run: |
83+
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
84+
- uses: actions/cache@v4
85+
with:
86+
path: cmd/anchor/dist/linux
87+
key: linux-${{ env.sha_short }}
88+
- uses: actions/cache@v4
89+
with:
90+
path: cmd/anchor/dist/darwin
91+
key: darwin-${{ env.sha_short }}
92+
- uses: actions/cache@v4
93+
with:
94+
path: cmd/anchor/dist/windows
95+
key: windows-${{ env.sha_short }}
96+
enableCrossOsArchive: true
97+
2298
- name: Run GoReleaser
2399
uses: goreleaser/goreleaser-action@v4
24100
with:
25101
distribution: goreleaser-pro
26102
version: latest
27-
args: release --clean
103+
args: continue --merge
28104
workdir: cmd/anchor
29105
env:
30106
GITHUB_TOKEN: ${{ secrets._GITHUB_TOKEN }}
31107
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
108+
109+
publish-windows:
110+
runs-on: windows-latest
111+
needs: prepare
112+
steps:
113+
- name: Checkout
114+
uses: actions/checkout@v3
115+
with:
116+
fetch-depth: 0
117+
118+
# Copy Caches
119+
- shell: bash
120+
run: |
121+
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
122+
echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
123+
- uses: actions/cache@v4
124+
with:
125+
path: cmd/anchor/dist/windows
126+
key: windows-${{ env.sha_short }}
127+
enableCrossOsArchive: true
128+
- shell: bash
129+
run: |
130+
cp cmd/anchor/dist/windows/anchor.${{ env.RELEASE_VERSION }}.nupkg ./
131+
132+
- shell: pwsh
133+
run: |
134+
choco push --source https://push.chocolatey.org/ --api-key "$env:CHOCOLATEY_API_KEY" anchor.${{ env.RELEASE_VERSION }}.nupkg
135+
env:
136+
CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }}

auth/auth_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"flag"
66
"testing"
77

8+
"github.com/anchordotdev/cli"
89
"github.com/anchordotdev/cli/api/apitest"
910
"github.com/anchordotdev/cli/cmdtest"
1011
)
@@ -27,13 +28,15 @@ func TestMain(m *testing.M) {
2728

2829
func TestCmdAuth(t *testing.T) {
2930
cmd := CmdAuth
30-
root := cmd.Root()
31+
cfg := cli.ConfigFromCmd(cmd)
32+
cfg.Test.SkipRunE = true
3133

3234
t.Run("auth", func(t *testing.T) {
33-
cmdtest.TestOutput(t, root, "auth")
35+
cfg.Test.SkipRunE = false
36+
cmdtest.TestOutput(t, cmd, "auth")
3437
})
3538

3639
t.Run("--help", func(t *testing.T) {
37-
cmdtest.TestOutput(t, root, "auth", "--help")
40+
cmdtest.TestOutput(t, cmd, "auth", "--help")
3841
})
3942
}

auth/signin_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ package auth
33
import (
44
"testing"
55

6+
"github.com/anchordotdev/cli"
67
"github.com/anchordotdev/cli/cmdtest"
78
)
89

910
func TestCmdAuthSignin(t *testing.T) {
1011
cmd := CmdAuthSignin
11-
root := cmd.Root()
12+
cfg := cli.ConfigFromCmd(cmd)
13+
cfg.Test.SkipRunE = true
1214

1315
t.Run("--help", func(t *testing.T) {
14-
cmdtest.TestOutput(t, root, "auth", "signin", "--help")
16+
cmdtest.TestOutput(t, cmd, "auth", "signin", "--help")
1517
})
1618
}
1719

auth/signout_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ func TestCmdAuthSignout(t *testing.T) {
1313
cmd := CmdAuthSignin
1414
cfg := cli.ConfigFromCmd(cmd)
1515
cfg.Test.SkipRunE = true
16-
root := cmd.Root()
1716

1817
t.Run("--help", func(t *testing.T) {
19-
cmdtest.TestOutput(t, root, "auth", "signout", "--help")
18+
cmdtest.TestOutput(t, cmd, "auth", "signout", "--help")
2019
})
2120
}
2221

auth/whoami_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ func TestCmdAuthWhoAmI(t *testing.T) {
1616
cmd := CmdAuthWhoami
1717
cfg := cli.ConfigFromCmd(cmd)
1818
cfg.Test.SkipRunE = true
19-
root := cmd.Root()
2019

2120
t.Run("--help", func(t *testing.T) {
22-
cmdtest.TestOutput(t, root, "auth", "whoami", "--help")
21+
cmdtest.TestOutput(t, cmd, "auth", "whoami", "--help")
2322
})
2423

2524
}

cli.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,12 @@ type Config struct {
3838
} `cmd:"config"`
3939

4040
MkCert struct {
41-
Domains string `flag:"domains"`
42-
SubCa string `flag:"subca"`
41+
Domains []string `flag:"domains"`
42+
SubCa string `flag:"subca"`
4343
} `cmd:"mkcert"`
4444

4545
Setup struct {
46-
PackageManager string `desc:"Package manager to use for integrating Anchor." flag:"package-manager" env:"PACKAGE_MANAGER" json:"package_manager" toml:"package-manager"`
47-
Service string `desc:"Name for lcl.host service." flag:"service" env:"SERVICE" json:"service" toml:"service"`
48-
Subdomain string `desc:"Subdomain for lcl.host service." flag:"subdomain" env:"SUBDOMAIN" json:"subdomain" toml:"subdomain"`
49-
File string `desc:"File Anchor should use to detect package manager." flag:"file" env:"PACKAGE_MANAGER_FILE" json:"file" toml:"file"`
50-
Language string `desc:"Language to use for integrating Anchor." flag:"language" json:"language" toml:"language"`
46+
Language string `desc:"Language to use for integrating Anchor." flag:"language" json:"language" toml:"language"`
5147
} `cmd:"setup"`
5248
} `cmd:"lcl"`
5349

cmd.go

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ var rootDef = CmdDef{
7777
{
7878
Name: "lcl",
7979

80-
Use: "lcl <subcommand> [flags]",
80+
Use: "lcl [flags]",
8181
Short: "Manage lcl.host Local Development Environment",
8282

8383
SubDefs: []CmdDef{
@@ -87,13 +87,77 @@ var rootDef = CmdDef{
8787
Use: "audit [flags]",
8888
Short: "Audit lcl.host HTTPS Local Development Environment",
8989
},
90+
{
91+
Name: "clean",
92+
93+
Use: "clean [flags]",
94+
Short: "Clean lcl.host CA Certificates from the Local Trust Store(s)",
95+
},
96+
{
97+
Name: "config",
98+
99+
Use: "config [flags]",
100+
Short: "Configure System for lcl.host Local Development",
101+
},
102+
{
103+
Name: "mkcert",
104+
105+
Use: "mkcert [flags]",
106+
Short: "Provision Certificate for lcl.host Local Development",
107+
},
108+
{
109+
Name: "setup",
110+
111+
Use: "setup [flags]",
112+
Short: "Setup lcl.host Application",
113+
},
90114
},
91115
},
92116
{
93117
Name: "trust",
118+
119+
Use: "trust [flags]",
120+
Short: "Manage CA Certificates in your Local Trust Store(s)",
121+
Long: heredoc.Doc(`
122+
Install the AnchorCA certificates of a target organization, realm, or CA into
123+
your local system's trust store. The default target is the localhost realm of
124+
your personal organization.
125+
126+
After installation of the AnchorCA certificates, Leaf certificates under the
127+
AnchorCA certificates will be trusted by browsers and programs on your system.
128+
`),
129+
SubDefs: []CmdDef{
130+
{
131+
Name: "audit",
132+
133+
Use: "audit [flags]",
134+
Short: "Audit CA Certificates in your Local Trust Store(s)",
135+
Long: heredoc.Doc(`
136+
Perform an audit of the local trust store(s) and report any expected, missing,
137+
or extra CA certificates per store. A set of expected CAs is fetched for the
138+
target org and (optional) realm. The default stores to audit are system, nss,
139+
and homebrew.
140+
141+
CA certificate states:
142+
143+
* VALID: an expected CA certificate is present in every trust store.
144+
* MISSING: an expected CA certificate is missing in one or more stores.
145+
* EXTRA: an unexpected CA certificate is present in one or more stores.
146+
`),
147+
},
148+
{
149+
Name: "clean",
150+
151+
Use: "clean [flags]",
152+
Short: "Clean CA Certificates from your Local Trust Store(s)",
153+
},
154+
},
94155
},
95156
{
96157
Name: "version",
158+
159+
Use: "version",
160+
Short: "Show version info",
97161
},
98162
},
99163
}

0 commit comments

Comments
 (0)